var proceso=false;
function validarCampo(archivo,variables,campo,tipo,div1,div2){
    if(validarProceso()){
		return;
	}else{
		proceso=true;
	}
	a=new nuevoAjax();
	if(archivo.indexOf("?")==-1)
		var rutad="?random="+aleatorio(1,200000);
	else
		var rutad="&random="+aleatorio(1,200000);
	a.open("POST",archivo+rutad,true);
	a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if((tipo=="background")||(tipo=="combinado")||(tipo=="respuesta")){	
		campo.style.background = "#FFFFFF url(imagenes/cargar.gif)";
		campo.style.backgroundPosition = 'right';
		campo.style.backgroundRepeat = 'no-repeat';
	}else{
		document.getElementById(div1).innerHTML = "<img src='cargar.gif' />";
	}
	a.send(variables);
	a.onreadystatechange=function() {
		if (a.readyState==4) {
			proceso=false;
			validarCampoRespuesta(campo,tipo,a.responseText,div1,div2);
	 	}
	}
}
function validarClaves(){
	var clave1=document.getElementById("clave1");
	var mensajeError="";
	if(clave1.value==""){
		mensajeError="El campo es obligatorio";
	}
	var clave2=document.getElementById("clave2");
	if(clave2.value==""){
		mensajeError="El campo es obligatorio";
	}
	////////////////////////////
	if(mensajeError!=""){
		operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:10px'><h3>Las dos claves son obligatorias </h3></div>","error_grande.png");
		setTimeout("esconderCapa('mensaje',50,'si')",5000);
		return false;
	}else{
		if(clave1.value!=clave2.value){
			operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:10px'><h3>Las contraseñas no coinciden </h3></div>","error_grande.png");
			setTimeout("esconderCapa('mensaje',50,'si')",5000);
			return false;
		}else{
			return true;
		}
	}
}
function validarFormulario(archivo){
	var mensajeError="";
	var dato="<br/>* ";	
	var variables="";
	var universal="";
	//var sexo=document.getElementById("customers_gender");
	
	var nombres=document.getElementById("customers_firstname");
	universal=nombres;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	
	var apellidos=document.getElementById("customers_lastname");
	universal=apellidos;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	
	var correo=document.getElementById("customers_email_address");
	universal=correo;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	///////////////////////////////
	var profesion=document.getElementById("customers_profesion");
	universal=profesion;
	if(universal.value=="Otra"){
		if(document.getElementById("otra").value==""){
			mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
			//universal.className="inputError";
			document.getElementById("otraS").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
		}else{
			variables=variables+"&"+universal.id+"="+document.getElementById("otra").value;
		}
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	////////////////////////////////////
	var empresa=document.getElementById("customers_enterprise");
	universal=empresa;
	variables=variables+"&"+universal.id+"="+universal.value;
	
	////////////////////////
	var pais=document.getElementById("customers_pais");
	universal=pais;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//document.getElementById("pais").className="inputError";
		document.getElementById("paisS").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+document.getElementById("customers_pais").value;
	}
	////////////////////
	var ciudad=document.getElementById("customers_ciudad");
	universal=ciudad;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//document.getElementById("ciudad").className="inputError";
		document.getElementById("ciudadS").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+document.getElementById("customers_ciudad").value;
	}
	/////////////////////////////////////////
	var telefonoPersonal=document.getElementById("customers_telephone");
	universal=telefonoPersonal;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo Telefonos de contácto es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	/////////////////////////////
	var celular=document.getElementById("customers_telefono_celular"); 
	universal=celular;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	var celular=document.getElementById("customers_cedula"); 
	universal=celular;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}
	//////////////////////////////////////////////////
	var direccion=document.getElementById("customers_direccion");
	universal=direccion;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}else{
		variables=variables+"&"+universal.id+"="+universal.value;
	}


	var contrasena1=document.getElementById("customers_password");
	////////////////////////////////
	universal=contrasena1;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}
	////////////////////////////////
	var contrasena2=document.getElementById("clave2");
	universal=contrasena2;
	if(universal.value==""){
		mensajeError=mensajeError+dato+"El campo "+universal.name+" es obligatorio";
		//universal.className="inputError";
		document.getElementById(universal.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
	}
	///////////////////////////////
	var cargo=document.getElementById("customers_cargo");
	universal=cargo;
	variables=variables+"&"+universal.id+"="+universal.value;
	//alert(variables);
	if(mensajeError!=""){
		//operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:20px'><h3>Los campos con <img src='imagenes/mal.gif' class='flotante' /> son obligatorios </h3></div>","error_grande.png");
		alert("Faltan algunos campos obligatorios");
		setTimeout("esconderCapa('mensaje',50,'si')",5000);
	}else{
		mensajeError="";
		if((correo.value.indexOf("@")==-1)||(correo.value.indexOf(".")==-1)){
			alert("El campo E-mail no tiene el formato adecuado");
			//operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:20px'><h3>El campo E-mail no tiene el formato adecuado</h3></div>","alerta_grande.png");
			//correo.className="inputError";
			document.getElementById(correo.name+"S").innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
			setTimeout("esconderCapa('mensaje',50,'si')",5000);
			return;
		}
		if(contrasena1.value!=contrasena2.value){
			//operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:20px'><h3>Las constraseñas no coinciden</h3></div>","error_grande.png");
			alert("La clave y la confirmación son distintas");
			//contrasena2.className="inputError";
			setTimeout("esconderCapa('mensaje',50,'si')",5000);
			return;
		}
		if(document.getElementById("customers_email_address").value == "no"){
			operacionMensaje("<div style='height:80px;overflow:auto;width:500px;margin-top:20px'><h3>E-mail no disponible</h3></div>","alerta_grande.png");
			alert("El E-mail ya lo esta utilizando otro usuario");
			//correo.className="inputError";
			setTimeout("esconderCapa('mensaje',50,'si')",5000);
			return;
		}
		variables=variables+"&customers_password="+document.getElementById("customers_password").value+"&codigo="+document.getElementById('codigo').value;
		linkInformacion("ajax_php/"+archivo,'cargadorSpan',variables,'cargadorSpan','ingresarUsuarioRespuesta("'+archivo+'")','innerHTML');
		
	}
}
function ingresarUsuarioRespuesta(archivo){
	if(document.getElementById("estado").value=="si"){
		//operacionMensaje("<div style='height:80px;overflow:auto;width:500px'><h4>Usuario Creado</h4></div>","bien_grande.png");
		if(archivo=="ingresar_usuario.php"){
			location.href="creacion_exitosa.php";
		}else{
			alert("Datos Guardados Exitosamente ");
			//operacionMensaje("<div style='height:80px;overflow:auto;width:500px'><h4>Datos Guardados Exitosamente</h4></div>","bien_grande.png");
			setTimeout("esconderCapa('mensaje',50,'si')",6000);
		}
	}else{
		operacionMensaje("<div style='height:80px;overflow:auto;width:500px'><h4>"+document.getElementById("estado").value+"</h4></div>","error_grande.png");
	}
}
function validarRestablecimiento(){
	//alert(document.getElementById("correo").value);
	if(document.getElementById("correo").value==""){
		operacionMensaje("<div style='height:80px;overflow:auto;width:500px'><h2>Por favor digite un correo</h2>","error_grande.png");
		setTimeout("esconderCapa('mensaje',50,'si')",5000);
		return false;
	}else{
		return true;
	}
	
}
function otraVentana(){
	//location.href = 'creacion.php';
}
function aleatorio(inferior,superior){
	var numPosibilidades = superior - inferior;
	var aleat = Math.random() * numPosibilidades;
	aleat = Math.round(aleat);
	return parseInt(inferior) + aleat;
}
function nuevoAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function esconderP(){
	document.getElementById('Layer1').style.display = 'none';
	//validarPais();
}
function seleccionarPais(Name,Code){

	document.getElementById("paisExiste").value = "si";
	document.getElementById("customers_pais").value = Code;
	document.getElementById("pais").value = Name;
	document.getElementById("paisS").innerHTML = "<img src='imagenes/bien.png' class='flotante' />";
	esconderP();
}
function seleccionarCiudad(Name,Code){

	document.getElementById("ciudadExiste").value = "si";
	document.getElementById("customers_ciudad").value = Code;
	document.getElementById("ciudad").value = Name;
	document.getElementById("ciudadS").innerHTML = "<img src='imagenes/bien.png' class='flotante' />";
	esconderC();
}
function activarP(){
	var contenedor = document.getElementById('layer1');
	restablecer(document.getElementById("customers_pais"));
	restablecer(document.getElementById("customers_ciudad"));
	document.getElementById("paisExiste").value = "no";
	document.getElementById("paisS").innerHTML = "*";
	document.getElementById("customers_pais").value = "";
	document.getElementById("ciudad").value = "";
	document.getElementById("ciudadExiste").value = "no";
	document.getElementById("customers_ciudad").value = "";
	document.getElementById("ciudadS").innerHTML = "*";
	var pais = document.getElementById("pais").value;
	var ruta = "ajax_php/pais_auto.php?pais="+pais;
	document.getElementById('Layer1').style.display = 'block';
	ajax=new nuevoAjax();
	ajax.open("GET",ruta,true);
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1){
			proceso=true;
            document.getElementById('pais').style.background='#FFFFFF url(imagenes/cargar.gif)';
			document.getElementById("pais").style.backgroundPosition = 'right';
			document.getElementById("pais").style.backgroundRepeat = "no-repeat";
        }
		if (ajax.readyState==4) // ESTATUS 4
		{
			proceso=false;
			document.getElementById('pais').style.background='';
			document.getElementById('Layer1').innerHTML = ajax.responseText;
		} // FINALIZACION DE EL ESTADO 4 AJAX
	}
	ajax.send(null)
}
function esconderC(){
	document.getElementById('Layer2').style.display = 'none';
	//validarPais();
}
function activarC(){
	var contenedor = document.getElementById('layer2');
	var pais = document.getElementById("customers_pais").value;
	restablecer(document.getElementById("customers_ciudad"));
	if(pais==""){
		operacionMensaje("<h4>Por favor dig&iacute;te un pa&iacute;s primero</h4>","alerta_grande.png");
		document.getElementById("pais").focus();
		setTimeout("esconderCapa('mensaje',50,'si')",9000);
		return;
	}
	document.getElementById("ciudadExiste").value = "no";
	document.getElementById("customers_ciudad").value = "";
	document.getElementById("ciudadS").innerHTML = "*";
	var ciudad = document.getElementById("ciudad").value;
	var ruta = "ajax_php/ciudad_auto.php?pais="+pais+"&ciudad="+ciudad;
	document.getElementById('Layer2').style.display = 'block';
	ajax=new nuevoAjax();
	ajax.open("GET",ruta,true);
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1){
			proceso=true;
            document.getElementById('ciudad').style.background='#FFFFFF url(imagenes/cargar.gif)';
			document.getElementById("ciudad").style.backgroundPosition = 'right';
			document.getElementById("ciudad").style.backgroundRepeat = "no-repeat";
        }
		if (ajax.readyState==4) // ESTATUS 4
		{
			proceso=false;
			document.getElementById('ciudad').style.background='';
			document.getElementById('Layer2').innerHTML = ajax.responseText;
		} // FINALIZACION DE EL ESTADO 4 AJAX
	}
	ajax.send(null)
}
function validarF(){
	/*var o1=document.getElementById("o1").checked;
	var o2=document.getElementById("o2").checked;
	var o3=document.getElementById("o3").checked;
	var o4=document.getElementById("o4").checked;
	var mensaje="";
	if((!o1) &&(!o2)&&(!o3)&&(!o4)){
		var mensaje = "Debe seleccionar una edicion";
	}
	var nombres=document.getElementById("nombres").value;
	if(nombres==""){
		var mensaje = mensaje+ "\n- Debe digitar su nombre";
	}
	var apellido=document.getElementById("apellido1").value;
	if(apellido==""){
		var mensaje = mensaje+ "\n- Debe digitar su primer apellido";
	}
	var cedula=document.getElementById("ccnit").value;
	if(cedula==""){
		var mensaje = mensaje+ "\n- Debe digitar su cedula";
	}
	var direccion=document.getElementById("direccion").value;
	if(direccion==""){
		var mensaje = mensaje+ "\n- Debe digitar su direccion de correspondencia";
	}
	var telefono1=document.getElementById("telres").value;
	var telefono2=document.getElementById("telofi").value;
	if((telefono1=="")&&(telefono2=="")){
		var mensaje = mensaje+ "\n- Debe digitar por lo menos un numero telefonico";
	}
	var customers_pais= document.getElementById("customers_pais").value;
	if(customers_pais==""){ 
		var mensaje = mensaje+ "\n- Debe seleccion un pais de la lista desplegable";
	}else{
		if(customers_pais != "COL"){
			if((o1)||(o2)||(o3)){
				var mensaje = mensaje+ "\n- La suscripción impresa solo es valida para Colombia";
			}
		}
	}
	var ciudad = document.getElementById("ciudad");
	if(ciudad==""){
		var mensaje = mensaje+ "\n- Debe digitar la ciudad";
	}
	
	if(mensaje==""){
		return true;
	}else{
		alert("Por favor verifique lo siguiente:\n"+mensaje+"\n");
		return false;
	}
	return false;*/
}
function validarCampoRespuesta(campo,tipo,a,div1,div2){
	document.getElementById(div2).innerHTML = a;
	var id=campo.id;
	var idE=id+"E";
	var error=document.getElementById(idE).value;
	error=error.replace(/ /g,"");
	if( error== "si"){
		if(tipo=="background"){	
			campo.style.background = "#FFFFFF url(imagenes/bien.png)"
			campo.style.backgroundPosition = 'right';
			campo.style.backgroundRepeat = 'no-repeat';
		}else{
			campo.style.background = "#FFFFFF";
			document.getElementById(div1).innerHTML = "<img src='imagenes/bien.png' class='flotante' />";
			if(tipo!="respuesta"){
				document.getElementById(div2).innerHTML = "<input type='hidden' id='"+campo+"E' value='"+document.getElementById(div2).innerHTML+"'  />";
			}
			
		}
	}else{
		if(tipo=="background"){	
			campo.style.background = "#FFFFFF url(imagenes/mal.gif)";
			campo.style.backgroundPosition = 'right';
			campo.style.backgroundRepeat = 'no-repeat';
		}else{
			campo.style.background = "#FFFFFF";
			document.getElementById(div1).innerHTML = "<img src='imagenes/mal.gif' class='flotante' />";
			
		}
		
	}
}
function validarProceso(){
	return false;
}
function validarEmail(){
	var email=document.getElementById("customers_email_address");
	validarCampo("comprobar_email.php","dato="+email.value,email,"respuesta","correoS","customers_email_addressS2");
	//operacionMensaje("<h4>Mensaje almacenado</h4>","error_grande.png");
	//setTimeout("esconderCapa('mensaje',50,'si')",10000);
}
function validarTextField(campo){
	var string=document.getElementById(campo).alt;
	var alt=string.split(",");
	var nn=validarTipo(campo,alt[1],alt[2],alt[3],alt[4],alt[5]);
	if(nn!=""){
		var a=campo;
		var b=campo+"S";
		var c=campo+"S2";
		validarCampoRespuesta(campo,"combinado",nn,b,c);
	}
}
function operacionMensaje(mensaje,imagen){
	mostrarMensajeRapido("<div class='no_transparencia'><table class='tabla_mensje_interno'><tr><td class='tabla_mensje_interno_td1'><img src='imagenes/"+imagen+"' /></td><td class='tabla_mensje_interno_td2'><a >"+mensaje+"</a><input type='hidden' value='si' id='mensaje_auditado' /></td></tr></table><div>","mensaje");
}
function mostrarMensajeRapido(mensaje,capa){
	muestraCapa('100%','100px',capa,mensaje,'imprimir',30,80,'si','si','si');
	//setTimeout("esconderCapa('mensaje',50,'si')",5000);

}
function esconderCapa(c,tiempo,inv){
	if(accion=="mostrando")
		return;
	else
		accion="escondiendo";
	var h=0;
	var w=0;
	var temporal="si";
	var porcentaje1=0;
	var porcentaje2=0;
	pantalla=screen.height;
	if(he[c]==0)
		return;
	if(parseInt(he[c])>h){	
		temporal="no";
		he[c]=he[c]-3;
		var porPantallaH = (pantalla *he[c])/100;
		pantalla=(parseInt(he[c])/parseInt(pantalla))*100;
		pantalla=100-pantalla;
		porcentaje1=(parseInt(he[c])/parseInt(heT[c]))*100;
		porcentaje2=(parseInt(he[c])/parseInt(heT[c]));
		try{document.getElementById(c).style.opacity = porcentaje2;}catch(e){}
		try{document.getElementById(c).style.MozOpacity=porcentaje2;}catch(e){}
		try{document.getElementById(c).filters.alpha.opacity=porcentaje1;}catch(e){}
		if(The[c]=="px"){
			document.getElementById(c).style.height = String(he[c])+The[c];
		}
		else{
			//alert(String(porPantallaH)+"px");
			document.getElementById(c).style.height = String(porPantallaH)+"px";
			var pantallaT=(porPantallaH*100)/screen.height;
			pantalla=pantalla-pantallaT;
		}	
		if(inv=='si'){	
			document.getElementById(c).style.top=pantalla+"%";
		}
		//alert(document.getElementById(c).style.height);
	}
	
	if(String(porPantallaH)<144)
		temporal="si";
	if(parseInt(he[c])==h)
		temporal="si";
	if(temporal=="no"){
		var funcion="esconderCapa('"+c+"','"+tiempo+"','"+inv+"')";
		var tiempo=14;
		setTimeout(funcion,tiempo);
	}else{
		heT[c]=0;
		accion="";	
		document.getElementById(c).style.display='none';
	}
}
var he=new Array();
var we=new Array();
var heT=new Array();
var op=new Array();
var The=new Array();
var Twe=new Array();
var accion="";
function muestraCapa(w,h,c,mensaje,pegar,tiempo,porcentaje,ho,ve,inv){
	var temporal="si";
	var porcentaje1=0;
	var porcentaje2=0;
	var por=parseInt(porcentaje)/100;
	var pantalla=0;
	if(document.getElementById(c).style.display != 'block'){
		document.getElementById(c).style.display ='block';
		document.getElementById(c).style.width = w;
		he[c]=0;
		we[c]=0;
		heT[c]=0;
		op[c]=0;
	}
	document.getElementById(pegar).innerHTML = mensaje;
	The[c]=identificarTipo(h);
	Twe[c]=identificarTipo(w);
	heT[c]=String(h).replace(The[c],"");
	heT[c]=parseInt(heT[c]);
	pantalla=screen.height;
	var porPantallaH = (pantalla *he[c])/100;
	if(he[c]<=heT[c]){
		porcentaje1=(parseInt(he[c])/parseInt(heT[c]))*100;
		porcentaje2=(parseInt(he[c])/parseInt(heT[c]));
		/// Funciones para calcular le wei
					
		//
		temporal="no";
		he[c]=he[c]+3;
		op[c]=porcentaje1;
		if(porcentaje>=porcentaje1){
			try{document.getElementById(c).style.opacity = porcentaje2;}catch(e){}
			try{document.getElementById(c).style.MozOpacity=porcentaje2;}catch(e){}
		}
		if(porcentaje>=porcentaje1){
			try{document.getElementById(c).filters.alpha.opacity=porcentaje1;}catch(e){}
		}
		//pantalla=pantalla.replace("%","");
		pantalla=(parseInt(he[c])/parseInt(pantalla))*100;
		pantalla=100-pantalla;
		if(ve=='si'){
			if(The[c]=="px"){
				document.getElementById(c).style.height = String(he[c])+The[c];
			}
			else{
				document.getElementById(c).style.height = String(porPantallaH)+"px";
				var pantallaT=(porPantallaH*100)/screen.height;
				//alert(pantallaT);
				pantalla=pantalla-pantallaT;
			}	
		}
		if(ho=='si'){
			//document.getElementById(c).style.width = we[c]+"px";
		}
		if(inv=='si'){
			if(ve=="si")
				document.getElementById(c).style.top=pantalla+"%";
			/*if(ho=="si")
				document.getElementById(c).style.right=pantalla+"%";*/
		}
	}
	if(temporal=="no"){
		var funcion="muestraCapa('"+w+String(The[c])+"','"+h+"','"+c+"',\""+mensaje+"\",'"+pegar+"','"+tiempo+"','"+porcentaje+"','"+ho+"','"+ve+"','"+inv+"')";
		setTimeout(funcion,tiempo);
	}else{
		accion="";
	}
}
function identificarTipo(tin){
	var pq=String(tin);
	var posicion =parseInt(pq.length)-1;
	var caracter= pq.charAt(posicion);
	//alert(isNaN(caracter))
	if((isNaN(caracter))&&(caracter!="x"))
		return  caracter;
	else
		return  "px";
}
///////////////////////////////////////////////////////////////////////////////////
function validarTipo(campo,texto,requerido,tipo,minimo,maximo){
	var mensaje='';
	var mensaje2='';
	// Cuando se esta balidando el boton siempre se bloquea
	
	//Valido si no viene un Array de campos para validar
	if(campo.indexOf(",")==-1){
		var camp=document.getElementById(campo);
		/*if((requerido=='si')&&(camp.value=='')){
			mensaje=mensaje+'<br/>El campo '+texto+' no puede estar vacios';
			mensaje2= 'El campo '+texto+' no puede estar vacios';
			document.getElementById(campo+'H').value=texto+' vacio';
		}*/
		if((tipo=='sting')&&(camp.value!='')){
			//mensaje=mensaje+'<br/>El campo'+texto+' no puede estar vacios';
			//document.getElementById(campo+'H').value=texto+' vacio';
		}
		if((tipo=='email')&&(camp.value!='')){
			if((camp.value.indexOf('@')==-1)||(camp.value.indexOf('.')==-1)){
				mensaje=mensaje+'El campo'+texto+' no tiene el formato adecaudo';
				//document.getElementById(campo+'H').value=texto+' no tiene el formato adecuado';
				mensaje2= 'El campo '+texto+' no tiene el formato adecuado';
			}
		}
		//Se valida si es diferente a double
		if(tipo=="double"){
				////// funcion para double /////////
		}else{
			if((parseInt(camp.value.length)<parseInt(minimo))||(parseInt(camp.value.length)>parseInt(maximo))){
				if(minimo=="0"){
					mensaje=mensaje+'El campo '+texto+' no tiene la longitud adecauda ('+(parseInt(minimo)+1)+' a '+maximo+')';
				//document.getElementById(campo+'H').value=texto+' no tiene la longitud adecuada('+(parseInt(minimo)+1)+'-'+maximo+')';
					mensaje2= 'El campo '+texto+' no tiene la longitud adecuada ('+(parseInt(minimo)+1)+' a '+maximo+')';
				}else{
					mensaje=mensaje+'El campo '+texto+' no tiene la longitud adecauda ('+(parseInt(minimo))+' a '+maximo+')';
				//document.getElementById(campo+'H').value=texto+' no tiene la longitud adecuada('+(parseInt(minimo))+'-'+maximo+')';
					mensaje2= 'El campo '+texto+' no tiene la longitud adecuada ('+(parseInt(minimo)+1)+' a '+maximo+')';
					
				}
			}
		}
	}else{
		var campos = campo.split(',');
		var camp;
		for( var indice in campos ) {
			camp=document.getElementById(campos[indice]);
			/*if((requerido=='si')&&(camp.value=='')){
				mensaje='Los campos en azul estan vacios';
				document.getElementById(campos[indice]+'H').value=texto+' Esta vacio';
				document.getElementById(campos[indice]).style.background ='#000066';
				document.getElementById(campos[indice]).style.color = '#FFFFFF';
			}*/
			if((tipo=='clave')&&(camp.value!='')){
				if(indice>0){
					if((document.getElementById(campos[indice]).value!=document.getElementById(campos[indice-1]).value)&&((document.getElementById(campos[indice]).value!="")&&(document.getElementById(campos[indice-1]).value!=""))){																																											  						mensaje='La clave y su confirmación no son iguales';		
						//document.getElementById(campos[indice]+'H').value=texto+' No es igual';
						//document.getElementById(campos[indice]).style.background ='#000066';
						//document.getElementById(campos[indice]).style.color = '#FFFFFF';
					}
				}
			}
			if(tipo=='double'){
				///
			}else{
				if(document.getElementById(campos[indice]).value!=""){
					if((parseInt(document.getElementById(campos[indice]).value.length)<parseInt(minimo))||(parseInt(document.getElementById(campos[indice]).value.length)>parseInt(maximo))){
						mensaje='Los campos en azul no tienen la longitud correcta ('+(parseInt(minimo)+1)+' a '+maximo+')';	
						//if(minimo=="0")
							//document.getElementById(campos[indice]+'H').value=texto+' no tiene la longitud correcta ('+(parseInt(minimo)+1)+' a '+maximo+')';
						//else
							//document.getElementById(campos[indice]+'H').value=texto+' no tiene la longitud correcta ('+(parseInt(minimo))+' a '+maximo+')';
						//document.getElementById(campos[indice]).style.background ='#000066';
						//document.getElementById(campos[indice]).style.color = '#FFFFFF';
					}
				}
			}
			
		}
	}
	if(mensaje!=''){
		document.getElementById(campo).className ='inputError';
	}
	return mensaje;
}
function restablecer(a){
	
}
////////////////////////////////////////////////////////////////////////////////////
function tabulador(e,obj,evento){
  var tecla=(document.all) ? e.keyCode : e.which; 
   var a=1;
   if(tecla!=13){ 
      if(evento!=""){
		  var b=evento;
		  
		   setTimeout(b,1);
	  }
   	 return;
   }
   var frm=obj.form; 
   var f="";
   for(i=0;i<frm.elements.length;i++){
  		if(frm.elements[i]==obj){
			f=frm.elements[i+1];
		}
		if(f!=""){
			
			if((frm.elements[i+1].disabled==false)&&(frm.elements[i+1].style.display!="none")&&(frm.elements[i+1].style.visibility!="hidden")&&(frm.elements[i+1].type!="hidden")){
				frm.elements[i+1].focus(); 
				try{
					frm.elements[i+1].select; 
				}catch(e){}
				f="";
		 	}
		}
   }
   return;
}
function linkInformacion(ruta,contenedor,variables,campo,funcion,tipo){
	if(validarProceso()){
		return;
	}else{
		proceso=true;
	}
	var q=15;
	var cont=document.getElementById(contenedor);
	var camp=document.getElementById(campo);
	a=new nuevoAjax();
	if(ruta.indexOf("?")==-1)
		var rutad="?random="+aleatorio(1,200000);
	else
		var rutad="&random="+aleatorio(1,200000);
	a.open("POST",ruta+rutad,true);
	a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	a.send(variables);
	if(tipo=="background"){	
		camp.style.background = "url(imagenes/cargar.gif)";
		camp.style.backgroundPosition = 'right';
		camp.style.backgroundRepeat = 'no-repeat';
	}else{
		camp.innerHTML = "<img src='imagenes/cargar.gif' />";
	}
	a.onreadystatechange=function() {
		if (a.readyState==4) {
			//alert(a.responseText);
			proceso=false;
			if(tipo=="background"){	
				camp.style.background ='';
			}else{
				camp.innerHTML='';	
			}
			cont.innerHTML = a.responseText;
			if(funcion!="")
				setTimeout(funcion,1);
	 	}
	}

}

