function enviar_form(){
	document.getElementById("form1").submit();	
	
}
var alto=600;
function mostrar_login(){
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	//$("#Fondoo").css("height",alto+"px");
	//document.getElementById("login").style.display="block";
	$("#Fondoo").slideDown("slow",function(){
			$("#login").slideDown("slow");						   
	});

}
function mostrar_instrucciones(){
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	//$("#Fondoo").css("height",alto+"px");
	//document.getElementById("login").style.display="block";
	$("#Fondoo").slideDown("slow",function(){
			$("#instrucciones").slideDown("slow");						   
	});

}
function cerrar_login(){
	//document.getElementById("login").style.display="none";
		$("#login").slideUp("slow",function(){
			$("#Fondoo").slideUp("slow");						   
	});

}
function mostrar_login_antes(){
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	//$("#Fondoo").css("height",alto+"px");
	//document.getElementById("login").style.display="block";
	$("#Fondoo").slideDown("slow",function(){
			$("#login_antes").slideDown("slow");						   
	});
	esconder_carro();
}
function registrarte2(){
		$("#login_antes").slideUp("slow",function(){
			$("#Registro").slideDown("slow");						   
	});
	
}
function cerrar_login_antes(){
	//document.getElementById("login").style.display="none";
		$("#login_antes").slideUp("slow",function(){
			$("#Fondoo").slideUp("slow");						   
	});

}

function cerrar_login_antes2(){
	//alert("iniciando");
	//document.getElementById("login").style.display="none";
		$("#login_antes").slideUp("slow",function(){
			//document.getElementById("login").style.display="block";
			$("#login").slideDown("slow");						   
	});

}

function agregar_carro(codigo,ids){
	//alert(ids+ " == "+codigo);
	ajax2=objetoAjax();
	ajax2.open("POST", "fphp/agregar_carrito.php");
	//divi2=document.getElementById("contendor_carro4");
	ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax2.send("ids="+ids+"&codigo="+codigo);
	ajax2.onreadystatechange=function() {
		if (ajax2.readyState==4) {
			dat2=ajax2.responseText;
		//	alert(dat2);
		//	divi2.innerHTML=dat2;
			mostrar_carro2(ids);
		}
	}
} 

function agregar_carrom(codigo,ids){
//	alert(ids+ " == "+codigo);
	ajax2=objetoAjax();
	ajax2.open("POST", "fphp/agregar_carritom.php");
	//divi2=document.getElementById("contendor_carro4");
	ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax2.send("ids="+ids+"&codigo="+codigo);
	ajax2.onreadystatechange=function() {
		if (ajax2.readyState==4) {
			dat2=ajax2.responseText;
		//	alert(dat2);
		//	divi2.innerHTML=dat2;
			mostrar_carro2m(ids);
		}
	}
} 

function mostrar_carrom(ids){
	//alert(ids)
	ajax=objetoAjax();
	ajax.open("POST", "fphp/mostrar_carritom.php");
	divi=document.getElementById("Carro_compra");
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("ids="+ids);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			dat=ajax.responseText;
			
			divi.innerHTML=dat;
			document.getElementById("Carro_compra").style.display="block";
			location.href="#super_carrito";
		}
	}
}
function mostrar_carro(ids){
	//alert(ids)
	ajax=objetoAjax();
	ajax.open("POST", "fphp/mostrar_carrito.php");
	divi=document.getElementById("Carro_compra");
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("ids="+ids);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			dat=ajax.responseText;
			
			divi.innerHTML=dat;
			document.getElementById("Carro_compra").style.display="block";
			location.href="#super_carrito";
		}
	}
}

function mostrar_carro2(ids){
	
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	$("#Fondoo").slideDown("slow",function(){
		mostrar_carro(ids);
		
	});
}
function mostrar_carro2m(ids){
	
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	$("#Fondoo").slideDown("slow",function(){
		mostrar_carrom(ids);
		
	});
}
function propiedad_fondo(){
		
	$('#Fondoo').css("opacity", 0.5);

	//alto=document.height;
	$('#Fondoo').css("height", 1200);
	//return alto;	
}
function esconder_carro(){
	//$('#Fondoo').css("opacity", 1.0);
	$("#Carro_compra").fadeOut("slow",function(ids){
	//document.getElementById("Carro_compra").style.display="none";
	$("#Fondoo").slideUp("slow");
	});
}

function cambiar_cantidad(ids,codigo,cantidad){
	/*
	if (cantidad>1 && cantidad<120){
	
	}else{
		alert("cantidad debe estar entre 2 y 120");	
		cantidad=1;
	}
	*/
	ajax3=objetoAjax();
	ajax3.open("POST", "fphp/update_carrito.php");
	//divi2=document.getElementById("contendor_carro4");
	//alert(codigo + " == " + ids + " == " +cantidad);
	ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax3.send("ids="+ids+"&codigo="+codigo+"&cantidad="+cantidad);
	ajax3.onreadystatechange=function() {
		if (ajax3.readyState==4) {
			dat3=ajax3.responseText;
			mostrar_carro(ids);
			//alert(dat3);
		//	divi2.innerHTML=dat2;
		}
	}
	
}
function cambiar_cantidadm(ids,codigo,cantidad){
	//alert(ids)
	/*
	if (cantidad>1 && cantidad<120){
	
	}else{
		alert("cantidad debe estar entre 2 y 120");	
		cantidad=1;
	}
	*/
	ajax3=objetoAjax();
	ajax3.open("POST", "fphp/update_carrito.php");
	//divi2=document.getElementById("contendor_carro4");
	//alert(codigo + " == " + ids + " == " +cantidad);
	ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax3.send("ids="+ids+"&codigo="+codigo+"&cantidad="+cantidad);
	ajax3.onreadystatechange=function() {
		if (ajax3.readyState==4) {
			dat3=ajax3.responseText;
			mostrar_carrom(ids);
			//alert(dat3);
		//	divi2.innerHTML=dat2;
		}
	}
	
}

function borrarpr_carrito(ids,codigo){
	msg=confirm("Esta seguro de eliminar esto del carro");
	if (msg==true){
		ajax4=objetoAjax();
		ajax4.open("POST", "fphp/borrarpr_carrito.php");
	//divi2=document.getElementById("contendor_carro4");
	//alert(codigo);
		ajax4.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4.send("ids="+ids+"&codigo="+codigo);
		ajax4.onreadystatechange=function() {
			if (ajax4.readyState==4) {
				dat4=ajax4.responseText;
				//alert(dat4);
			//	divi2.innerHTML=dat2;
				mostrar_carro(ids);
			}
		}
	}
}
function datos_facturacion(ids){
	//alert(ids);
	ajax4f=objetoAjax();
	var cant_cajas=document.getElementById("cant_cajas").value;
	var total_peso=document.getElementById("total_peso").value;
	//alert(cant_cajas);
	if (cant_cajas>=2 ){
		if (cant_cajas>30){
				alert("Para compras superiores a 30 cajas favor comunicarse con un ejecutivo al tel\u00e9fono 7562500\ngastos de envios regi\00f3n metropolitana para estas cantidades es gratis");
		}
	ajax4f.open("POST", "fphp/datos_facturacion.php");
	divi2=document.getElementById("Carro_compra");
	//alert(codigo);
		ajax4f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f.send("ids="+ids+"&cant_cajas="+cant_cajas+"&total_peso="+total_peso);
		ajax4f.onreadystatechange=function() {
			if (ajax4f.readyState==4) {
				dat4=ajax4f.responseText;
				//alert(dat4);
				divi2.innerHTML=dat4;
				
			}else{
				divi2.innerHTML="<center><img src='imagenes/preloading.gif'></center>";	
			}
		}
	}else{
		//alert("La cantidad de cajas debe estar entre 2 y 30. para compras superiores favor comunicarse con un ejecutivo al tel\u00e9fono 7562500");
		alert("La cantidad de cajas debe ser supeior a 2");
	}
	
	
}
function datos_facturacion2(ids){
	var nombre="";
	var fono="";
	var direccion="";
	var region="";
	var comuna="";
	var contacto="";
	var calle_ref="";
	var permite_doc="no";
	var msg2="";
	fono=document.getElementById("txt_fono").value;
	direccion=document.getElementById("txt_direccion").value;
	region=document.getElementById("sel_region").value;
	documento=document.getElementById("sel_documento").value;
	comuna=document.getElementById("sel_comuna").value;
	contacto=document.getElementById("txt_contactoentrega").value;
	calle_ref=document.getElementById("txt_referencia").value;
	flete=document.getElementById("valor_flete").value;
	rs=document.getElementById("txt_razon_social").value;
	giro=document.getElementById("txt_giro").value;
	rute=document.getElementById("txt_rute").value;
	var cant_cajas=document.getElementById("cant_cajas").value;
	var total_peso=document.getElementById("total_peso").value;
	//alert(rs + " ... "+giro);
	if (documento==""){
		msg2="debe Escoger tipo de documento";
		permite_doc="no";	
	}
	if (documento=="F"){
		if (rs!="" && giro!="" && rute!=""){
			permite_doc="si";	
		}else{
			msg2="Complete razon social, giro y Rut de empresa";
			permite_doc="no";	
		}
	}
	//alert(comuna);
	var permite_doc2="no";
	if (comuna==-1){
		msg2="debe Escoger comuna";
		permite_doc2="no";	
	}else{
		permite_doc2="si";	
	}
	
	if (documento=="B"){
		permite_doc="si";	
	}
	if (fono!="" && direccion!="" && permite_doc=="si" && permite_doc2=="si" ){
		ajax4f=objetoAjax();
		ajax4f.open("POST", "fphp/datos_facturacion2.php");
		divi2=document.getElementById("Carro_compra");
		divi2.innerHTML="<center><img src='imagenes/preloading.gif'></center>";	
	//alert(codigo);
		ajax4f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f.send("ids="+ids+"&fono="+fono+"&direccion="+direccion+"&region="+region+"&comuna="+comuna+"&contacto="+contacto+"&referencia="+calle_ref+"&flete="+flete+"&razon_social="+rs+"&giro="+giro+"&rute="+rute+"&total_peso="+total_peso);
		ajax4f.onreadystatechange=function() {
			if (ajax4f.readyState==4) {
				dat4=ajax4f.responseText;
				//alert(dat4);
				divi2.innerHTML=dat4;
				
			}else{
				divi2.innerHTML="<center><img src='imagenes/preloading.gif'></center>";	
				
			}
		}
	
	}else{
		var msg='';
		if (fono==""){
			msg+="Fono, ";	
		}
		if (direccion==""){
			msg+="Direccion, ";	
		}
		if (comuna==-1){
			msg+="Comuna, ";	
		}

		if (permite_doc!="si"){
			if (documento==""){
				msg+=" Tipo de documento";
			}
			if (documento=="F"){
			  if (rs!="" && giro!="" && rute!=""){
				  msg+="";
			  }else{
				  msg+="  giro, raz\u00F3n social y Rut Empresa";
			  }
			}
		}else{
			
		}
		alert("Revise "+msg);	
	}
}
function boletaFactura(valor){
	var divi=document.getElementById("boletita");
	//var divi2=document.getElementById("boletita2");
	//var divi3=document.getElementById("boletita3");
	rz=document.getElementById("txt_razon_social");
	giro=document.getElementById("txt_giro");
	rute=document.getElementById("txt_rute");
	if (valor=="F"){
		divi.style.display="block";
	//	divi2.style.display="block";
	//	divi3.style.display="block";
		rz.disabled="";
		giro.disabled="";
		rute.disabled="";

	}
	if (valor=="B"){
		divi.style.display="none";
	//	divi2.style.display="none";
	//	divi3.style.display="none";
		rz.disabled="disabled";
		giro.disabled="disabled";
		rute.disabled="disabled";
	}
	
}

function calculaFlete(valor,cajas){
	ajax5af=objetoAjax();
	ajax5af.open("POST", "fphp/valorflete.php");
	divi2=document.getElementById("valor_flete");
	//alert(codigo);
		ajax5af.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5af.send("idregion="+valor+"&cajas="+cajas);
		ajax5af.onreadystatechange=function() {
			if (ajax5af.readyState==4) {
				dat5=ajax5af.responseText;
				//alert(dat5);
				divi2.value=dat5;
				
			}
		}
	
	
}
function calculaFlete2(valor){
	ajax5af2=objetoAjax();
	var cajas=document.getElementById("cant_cajas").value;
	ajax5af2.open("POST", "fphp/valorflete2.php");
	divi22=document.getElementById("valor_flete");
	//alert(codigo);
		ajax5af2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5af2.send("idcomuna="+valor+"&cajas="+cajas);
		ajax5af2.onreadystatechange=function() {
			if (ajax5af2.readyState==4) {
				dat52=ajax5af2.responseText;
				alert(dat52);
				divi22.value=dat52;
				
			}
		}
	
	
}

function cambiar_tarifa(valor){
	ajax5af2=objetoAjax();
	document.getElementById("paso_datos_fac2").style.display="none";
	var cajas=document.getElementById("cant_cajas").value;
	var total_peso=document.getElementById("total_peso").value;
	ajax5af2.open("POST", "fphp/valorflete3.php");
	divi22=document.getElementById("valor_flete");
	//alert(codigo);
		ajax5af2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5af2.send("idcomuna="+valor+"&cajas="+cajas+"&total_peso="+total_peso);
		ajax5af2.onreadystatechange=function() {
			if (ajax5af2.readyState==4) {
				dat52=ajax5af2.responseText;
				//alert(dat52);
				divi22.value=dat52;
				document.getElementById("paso_datos_fac2").style.display="block";
				
			}
		}
	
	
	
}

function carga_comunas(valor){
	ajax5f=objetoAjax();
	ajax5f.open("POST", "fphp/cargarcomunas.php");
	divi2a=document.getElementById("Ccomuna");
	//alert(codigo);
		ajax5f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5f.send("idregion="+valor);
		ajax5f.onreadystatechange=function() {
			if (ajax5f.readyState==4) {
				dat5a=ajax5f.responseText;
				//alert(dat4);
				divi2a.innerHTML=dat5a;
				
			}
		}
	

	
	
}
function carga_comunas2(valor){
	alert("comunas2");
	ajax5f=objetoAjax();
	ajax5f.open("POST", "fphp/cargarcomunas2.php");
	divi2a=document.getElementById("Ccomuna");
	//alert(codigo);
		ajax5f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5f.send("idregion="+valor);
		ajax5f.onreadystatechange=function() {
			if (ajax5f.readyState==4) {
				dat5a=ajax5f.responseText;
				//alert(dat4);
				divi2a.innerHTML=dat5a;
				
			}
		}
	

	
	
}
function mostrar_registro(){
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	document.getElementById("Mensaje_conf").innerHTML='<marquee direction="left" truespeed="truespeed"   ></marquee>';
	$("#Fondoo").slideDown("slow",function(){
		$("#Registro").slideDown("slow");								   
										   
});
	
	//document.getElementById("Registro").style.display="block";
	
}
function cerrar_registro(){
	$("#Registro").slideUp("slow",function(){
				$("#Fondoo").slideUp("slow");						   
	});
	
	//document.getElementById("Registro").style.display="none";
	
}
	var error="mal";
	var ok="ok";
	var mensajes=Array("<img src='images/ok.png' width='24' height='24'>","<img src='images/mal.png' width='24' height='24'>");
function registrarse(){

	
	var veri_img_email=document.getElementById("veri_img_email");
	var veri_img_rut=document.getElementById("veri_img_rut");
	var veri_img_user=document.getElementById("veri_img_user");
	var veri_img_clave=document.getElementById("veri_img_clave");
	var rut=document.getElementById("REG_rut").value;
	var email=document.getElementById("REG_email").value;
	var user=document.getElementById("REG_user").value;
	var clave=document.getElementById("REG_clave").value;
	var confirme=document.getElementById("REG_confirme").value;
	var es_mayor=document.getElementById("es_mayor").value;
	if (es_mayor=="no"){
		
	}else{
		cambiar_mensaje("Espere un momento");
	}
	var msg="";
	if (clave==confirme && clave.length>=6){
		permite="si";
		error=0;	
	}else{
		error=1;
		if (clave!=confirme){
			msg+="Claves Distintas";
			
		}
		if (clave.length<6){
			msg+="Clave contiene menos de 6 caracteres";	
		}
		permite="no";	
	}
	ajax5f1=objetoAjax();
	ajax5f1.open("POST", "fphp/permite_datos.php");
	//divi2a=document.getElementById("Ccomuna");
	//alert(codigo);
		ajax5f1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5f1.send("rut="+rut+"&email="+email+"&user="+user);
		ajax5f1.onreadystatechange=function() {
			if (ajax5f1.readyState==4) {
				dat5a1=ajax5f1.responseText;
				
				auxd=dat5a1.split("_");
				
				veri_img_rut.innerHTML=mensajes[parseInt(auxd[0])];
				veri_img_email.innerHTML=mensajes[parseInt(auxd[1])];
				veri_img_user.innerHTML=mensajes[parseInt(auxd[2])];
				veri_img_clave.innerHTML=mensajes[error];
				if (auxd[0]==0 && auxd[1]==0 && auxd[2]==0 && error==0  ){
					document.form_reg.submit();
				
				}else{
					if (es_mayor!="no"){
						cambiar_mensaje("se presentaron problemas");
					}else{
						cambiar_mensaje_m("Debe ser mayor de edad para registrarte");
					}
				}
				
		//		divi2a.innerHTML=dat5a1;
				
			}
		}

	
}
function cambiar_mensaje(mensaje){
	document.getElementById("Mensaje_conf").innerHTML='<marquee direction="left" truespeed="truespeed"   >'+mensaje+'</marquee>';
	
}
function cambiar_mensaje_m(){
		
				$("#Div_mayor").slideDown("slow");						   
	

	
}
function cerrar_mensaje_m(){
				$("#Div_mayor").slideUp("slow");						   
	
}
function cambiar_mensaje_edt(mensaje){
	document.getElementById("Mensaje_edt").innerHTML='<marquee direction="left" truespeed="truespeed"   >'+mensaje+'</marquee>';
	
}
function limpiar_regi(){
	document.getElementById("REG_rut").value="";
	document.getElementById("REG_nombre").value="";
	document.getElementById("REG_app").value="";
	document.getElementById("REG_apm").value="";
	//REG_region
	document.getElementById("REG_region").value=-1;
	document.getElementById("REG_comuna").value=-1;
	document.getElementById("REG_email").value="";
	document.getElementById("REG_direccion").value="";
	document.getElementById("REG_cod").value="";
	document.getElementById("REG_telefono").value="";
	document.getElementById("REG_user").value="";
	document.getElementById("REG_clave").value="";
	document.getElementById("REG_confirme").value="";
	document.getElementById("veri_img_email").innerHTML="";
	document.getElementById("veri_img_rut").innerHTML="";
	document.getElementById("veri_img_user").innerHTML="";
	document.getElementById("veri_img_clave").innerHTML="";


	
}
function mostrar_recuperar(){
	propiedad_fondo();
	//document.getElementById("Fondoo").style.height=alto+"px";
	//document.getElementById("Recupera_clave").style.display="block";
	$("#Fondoo").slideDown("slow",function(){
				$("#Recupera_clave").slideDown("slow");						   
	});
}
function cerrar_recuperar(){
	//document.getElementById("Recupera_clave").style.display="none";
	$("#Recupera_clave").slideUp("slow",function(){
				$("#Fondoo").slideUp("slow");						   
	});

	
}
function recuperar_clave(){
	var correo=document.getElementById("REC_email").value;
	ajax4f=objetoAjax();
	ajax4f.open("POST", "fphp/recup_clave.php");
	//divi2a=document.getElementById("Ccomuna");
	//alert(correo);
	document.getElementById("REC_men").innerHTML='<marquee direction="left" truespeed="truespeed"   >Espere un momento</marquee>';
		ajax4f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f.send("email="+correo);
		ajax4f.onreadystatechange=function() {
			if (ajax4f.readyState==4) {
				dat4a=ajax4f.responseText;
				//alert(dat4a);
				aux5=dat4a.split("@@@@@");
				
				if (aux5[0]=="ok"){
					limpiar_recu();
					cambiar_mensaje_recu(aux5[1]);
				}else{
					limpiar_recu();
					cambiar_mensaje_recu(aux5[1]);
				}
		//		divi2a.innerHTML=dat4a;
				
			}
		}

}
function limpiar_recu(){
	document.getElementById("REC_email").value="";
}
function cambiar_mensaje_recu(mensaje){
	document.getElementById("REC_men").innerHTML='<marquee direction="left" truespeed="truespeed"   >'+mensaje+'</marquee>';
	
}
function cambiar_comuna_reg(valor){
	ajax4f1=objetoAjax();
	ajax4f1.open("POST", "fphp/cargarcomunas_reg.php");
	divi2a=document.getElementById("Cont_reg_comuna");
	//alert(correo);
		ajax4f1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f1.send("idregion="+valor);
		ajax4f1.onreadystatechange=function() {
			if (ajax4f1.readyState==4) {
				dat4a1=ajax4f1.responseText;
				divi2a.innerHTML=dat4a1;
				
			}
		}
}
function editar_datos(usuario){
	propiedad_fondo();
//	document.getElementById("Fondoo").style.height=alto+"px";
	ajax4f11=objetoAjax();
	ajax4f11.open("POST", "fphp/editar_datos.php");
	divi2a=document.getElementById("Editar_datos");
	
		ajax4f11.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f11.send("usuario="+usuario);
		ajax4f11.onreadystatechange=function() {
			if (ajax4f11.readyState==4) {
				dat4a11=ajax4f11.responseText;
			
				divi2a.innerHTML=dat4a11;
				$("#Fondoo").slideDown("slow",function(){
					$("#Editar_datos").slideDown("slow");						   
				});
				
			}
		}
	
	
}

function cerrar_edt_datos(){
	$("#Editar_datos").slideUp("slow",function(){
				$("#Fondoo").slideUp("slow");						   
	});
	
	//document.getElementById("Registro").style.display="none";
	
}


function cerrar_instrucciones(){
	$("#instrucciones").slideUp("slow",function(){
				$("#Fondoo").slideUp("slow");						   
	});
	
	//document.getElementById("Registro").style.display="none";
	
}
function mostrar_qclay(){
	propiedad_fondo();
	//alert("asd");
	//document.getElementById("Fondoo").style.height=alto+"px";
	//document.getElementById("Recupera_clave").style.display="block";
	$("#Fondoo").slideDown("slow",function(){
				$("#qclay").slideDown("slow");						   
	});
}

function cerrar_qclay(){
	$("#qclay").slideUp("slow",function(){
				$("#Fondoo").slideUp("slow");						   
	});
	
	//document.getElementById("Registro").style.display="none";
	
}


function cambiar_comuna_edt(valor){
	ajax4f1=objetoAjax();
	ajax4f1.open("POST", "fphp/cargarcomunas_edt.php");
	divi2a=document.getElementById("Cont_edt_comuna");
	//alert(correo);
		ajax4f1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4f1.send("idregion="+valor);
		ajax4f1.onreadystatechange=function() {
			if (ajax4f1.readyState==4) {
				dat4a1=ajax4f1.responseText;
				divi2a.innerHTML=dat4a1;
				
			}
		}
}

function editar_datos_usuario(){
		cambiar_mensaje("Espere un momento");
	var veri_img_email=document.getElementById("veri_img_email2");
	var veri_img_rut=document.getElementById("veri_img_rut2");
	var veri_img_user=document.getElementById("veri_img_user2");
	var veri_img_clave=document.getElementById("veri_img_clave2");
	var rut=document.getElementById("EDT_rut").value;
	var email=document.getElementById("EDT_email").value;
	var user=document.getElementById("EDT_user").value;
	var clave=document.getElementById("EDT_clave").value;
	var confirme=document.getElementById("EDT_confirme").value;
	var msg="";
	if (clave==confirme && clave.length>=6){
		permite="si";
		error=0;	
	}else{
		error=1;
		if (clave!=confirme){
			msg+="Claves Distintas";
			
		}
		if (clave.length<6){
			msg+="Clave contiene menos de 6 caracteres";	
		}
		permite="no";	
	}
	ajax5f1=objetoAjax();
	ajax5f1.open("POST", "fphp/permite_datos_edt.php");
	//divi2a=document.getElementById("Ccomuna");
	//alert(codigo);
		ajax5f1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax5f1.send("rut="+rut+"&email="+email+"&user="+user);
		ajax5f1.onreadystatechange=function() {
			if (ajax5f1.readyState==4) {
				dat5a1=ajax5f1.responseText;
		
				auxd=dat5a1.split("_");
			
				veri_img_rut.innerHTML=mensajes[0];
				veri_img_email.innerHTML=mensajes[parseInt(auxd[1])];
				veri_img_user.innerHTML=mensajes[0];
				veri_img_clave.innerHTML=mensajes[error];
				if (auxd[0]==0 && auxd[1]==0 && auxd[2]==0 && error==0  ){
					document.form_edt.submit();
					
				}else{

					cambiar_mensaje_edt("se presentaron problemas");
				}
				
		//		divi2a.innerHTML=dat5a1;
				
			}
		}

	

	
	
}
function cerrar_editar_seg(){
	$("#aux").fadeOut("slow").delay(5000).fadeOut("slow",function(){
				cerrar_edt_datos();
		
			});	
	/*
	$("#aux").fadeOut("slow",function(){
		$("#aux").fadeIn("slow",function(){
			$("#aux").fadeOut("slow",function(){
				cerrar_edt_datos();
		
			});	
		})
	});
	*/
	
}
function cerrar_reg_seg(){
	$("#aux").fadeOut("slow").delay(5000).fadeOut("slow",function(){
				cerrar_registro();
		
			});	
	/*
	$("#aux").fadeOut("slow",function(){
		$("#aux").fadeIn("slow",function(){
			$("#aux").fadeOut("slow",function(){
				cerrar_edt_datos();
		
			});	
		})
	});
	*/
	
}
function limpiar_edt(){
		document.getElementById("EDT_rut").value="";
	document.getElementById("EDT_nombre").value="";
	document.getElementById("EDT_app").value="";
	document.getElementById("EDT_apm").value="";
	//REG_region
	//document.getElementById("REG_region").selectedIndex=0;
	//document.getElementById("REG_comuna").selectedIndex=0;
	document.getElementById("EDT_email").value="";
	document.getElementById("EDT_user").value="";
	document.getElementById("EDT_clave").value="";
	document.getElementById("EDT_confirme").value="";
	document.getElementById("veri_img_email2").innerHTML="";
	document.getElementById("veri_img_rut2").innerHTML="";
	document.getElementById("veri_img_user2").innerHTML="";
	document.getElementById("veri_img_clave2").innerHTML="";

	
}
function cambiar_mayor(valor){
	//
	document.getElementById("es_mayor").value=valor;
	if (valor=="si"){
		if (document.getElementById("Div_mayor").style.display=="block"){
			cerrar_mensaje_m();	
		}
	}
}
