// JavaScript Document
function validaCamposCV(form)
{
	if (form.nombre.value == "")
	{	alert("Introduce tu Nombre completo");
        form.nombre.focus();
        return false;
	}
	if (form.dia.value == "Día")
	{	alert("Selecciona tu día de nacimiento");
        form.dia.focus();
        return false;
	}
	if (form.mes.value == "Mes")
	{	alert("Selecciona tu mes de nacimiento");
        form.mes.focus();
        return false;
	}
	if (form.anio.value == "Año" || form.anio.value.length<4)
	{	alert("Introduce ó verifica el año en que naciste (4 dígitos)");
        form.anio.focus();
        return false;
	 }
 	if (form.region.value == "México")
	{
		if (form.estado.value == "Selecciona")
		{	alert("Selecciona el estado dónde vives");
            form.estado.focus();
            return false;
	    }
		if (form.poblacion.value == "")
		{	alert("Introduce la población ó municipio dónde vives");
            form.poblacion.focus();
            return false;
	    }
	}
	else if(form.region.value == "Otro")
	{
		if (form.pais.value == "")
		{	alert("Introduce el país dónde vives");
            form.pais.focus();
            return false;
	    }
		if (form.ciudad.value == "")
			{	alert("Introduce la ciudad dónde vives");
                form.ciudad.focus();
                return false;
	       	}
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)))
	{	alert ("Introduce ó verifica tu dirección de correo electrónico");
		form.email.focus();
		return false;
	}
	if ((form.tel.value == "tel.") && (form.cel.value == ""))
	{	alert("Introduce al menos un número telefónico para contactarte");
        form.lada.focus();
        return false;
	}
	if (form.estudios.value == "Selecciona")
	{	alert("Selecciona tu nivel máximo de estudios");
        form.estudios.focus();
        return false;
	}
	if (form.escuela.value == "")
	{	alert("Introduce el nombre de la Institución/Escuela en dónde realizaste tus últimos estudios");
        form.escuela.focus();
        return false;
	}
	if (form.carrera.value == "Selecciona")
	{	alert("Selecciona la carrera que estudiaste");
        form.carrera.focus();
        return false;
	}
	
	if (form.sueldo.value == "Selecciona")
	{	alert("Selecciona el sueldo mensual deseado");
        form.sueldo.focus();
        return false;
	}
	if (form.archivo.value == "")
	{	alert("Es necesario que adjuntes tu Currículum");
        form.archivo.focus();
        return false;
	}
	if (form.archivo.value != "") 
	{ 
		ext_perm = new Array(".gif", ".jpg", ".doc", ".pdf", ".xls", ".ppt", ".pps", ".bmp", ".rtf", ".txt");
    	extension = (form.archivo.value.substring(form.archivo.value.lastIndexOf("."))).toLowerCase();
    	permitida = false;
    	for (var i = 0; i < ext_perm.length; i++) {
        	if (ext_perm[i] == extension) {
        	permitida = true;
        	break;
        	}
   		}
   		if (!permitida) {
         	error = "Comprueba la extensión del archivo. \nSólo se pueden anexar archivos con extensiones: " + ext_perm.join();
		 	alert (error);
			form.archivo.focus();
         	return false;
    	}
	}
	if ( !form.Ca.checked &&!form.Di.checked &&!form.Ex.checked &&!form.Fi.checked &&!form.Im.checked &&!form.Ju.checked &&!form.Me.checked &&!form.In.checked &&!form.Pl.checked &&!form.Mu.checked &&!form.Rh.checked &&!form.Se.checked &&!form.Si.checked &&!form.Ve.checked &&!form.Ot.checked &&!form.Mt.checked)
	{	alert("Selecciona al menos 1 área de interés");
        return false;
	}
	if (form.tmptxt.value == "" || form.tmptxt2.value == "")
	{	alert("Captura los caracteres de las imágenes");
        form.tmptxt.focus();
        return false;
	}

form.boton.value="Enviando";
form.boton.disabled=true;
form.submit();
}
//-------------------------------------------------------------------------------------------------------------------------
function escondeCV(form)
{
	dis= true ? '' : 'none';
	dis2= false ? '' : 'none';
	var txt1=document.getElementById("txt1");
	var txt2=document.getElementById("txt2");
	if (form.region.value == "México")
	{
  		form.estado.style.display=dis;
		form.poblacion.style.display=dis;
		form.pais.style.display=dis2;
		form.ciudad.style.display=dis2;
		txt1.firstChild.nodeValue="Estado";
		txt2.firstChild.nodeValue="Población";
	}

    else 
	{
		form.estado.style.display=dis2;
		form.poblacion.style.display=dis2;
		form.pais.style.display=dis;
		form.ciudad.style.display=dis;
		txt1.firstChild.nodeValue="Especifica";
		txt2.firstChild.nodeValue="Ciudad";
		form.pais.focus();
	}
}
//-------------------------------------------------------------------------------------------------------------------------
function getFocus(fieldChk, fieldId)
{
	var check=document.getElementById(fieldChk);
	var campo=document.getElementById(fieldId);
	if (check.checked==true)
	{  campo.focus(); }
}
//-------------------------------------------------------------------------------------------------------------------------
var maxi=3;
var contador=0;

function validaAreasCV(check)
{
	if (check.checked==true)
	{	contador++;
		if (contador>maxi)
		{	alert('Puedes elegir máximo '+maxi+' áreas de interés.');
			check.checked=false;
			contador--;
		}
	}
	else {  contador--;  }
}
//-------------------------------------------------------------------------------------------------------------------------
function clearField(fieldId)
{
	var field = document.getElementById(fieldId);
	field.value = "";
}
//-------------------------------------------------------------------------------------------------------------------------
function setField(fieldId, originalValue)
{
	var field = document.getElementById(fieldId);
	if(field.value == "")
	{	field.value = originalValue;  }
}
//-------------------------------------------------------------------------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-------------------------------------------------------------------------------------------------------------------------
function MM_jumpMenu(targ,selObj,restore,seccion)
{
	if (seccion=="cliente")
	{	eval(targ+".location='clienteN.php?area="+selObj.options[selObj.selectedIndex].value+"'"); }
	else if (seccion=="clienteIng")
	{	eval(targ+".location='cliente_ing.php?area="+selObj.options[selObj.selectedIndex].value+"'"); }
	else if (seccion=="manuales")
	{	
		if (selObj.options[selObj.selectedIndex].value==""){m=1;}
		else {m=0;}
		eval(targ+".location='manuales.php?m="+m+"&categoria="+selObj.options[selObj.selectedIndex].value+"'"); }
	else if (seccion=="manualesIng")
	{	
		if (selObj.options[selObj.selectedIndex].value==""){m=1;}
		else {m=0;}
		eval(targ+".location='manuales_ing.php?m="+m+"&categoria="+selObj.options[selObj.selectedIndex].value+"'"); }
  if (restore) selObj.selectedIndex=0;
}
//-------------------------------------------------------------------------------------------------------------------------
function escondeClt(form,elemento)
{
	
	if (elemento=="edo")
	{
		var txt=document.getElementById("rengMun");
		dis= true ? '' : 'none';
		dis2= false ? '' : 'none';
		if (form.estado.value == "Edo. Méx.")
		{
			form.entidad.value= "";
			form.entidad.style.display=dis2;
			form.delegacion.style.display=dis2;
			form.entidad2.style.display=dis;
			if (form.entidad2.value == "Otro")
			{	form.municipio.style.visibility= "visible";
				form.municipio.focus();
				txt.style.visibility= "visible";  }
			else
			{	form.municipio.style.visibility= "hidden";
				txt.style.visibility= "hidden";
				form.municipio.value= "";}
		}

		else if (form.estado.value == "D.F.")
		{
			form.entidad.value= "";
			form.entidad.style.display=dis2;
			form.entidad2.style.display=dis2;
			form.delegacion.style.display=dis;
			form.municipio.style.visibility= "hidden";
			txt.style.visibility= "hidden";
			form.municipio.value= "";
		}

    	else 
		{
			form.entidad.style.display=dis;
			form.entidad2.style.display=dis2;
			form.municipio.style.visibility= "hidden";
			form.delegacion.style.display=dis2;
			txt.style.visibility= "hidden";
			form.municipio.value= "";
		}
	}
	else if (elemento=="alta")
	{
		var txtRfc=document.getElementById("rengRFC");
		if (form.alta[0].checked)
		{	form.rfc.style.visibility=txtRfc.style.visibility="visible";
			form.rfc.focus();  }
		
		else if (form.alta[1].checked)
		{	form.rfc.style.visibility=txtRfc.style.visibility="hidden";
			form.rfc.value= "";}
	}
	else if (elemento=="negocio")
	{
		var txtNeg=document.getElementById("rengNeg");
		var rengPOP=document.getElementById("trPOP");
		if (form.negocio.value=="Otro")
		{	form.negocio2.style.visibility=txtNeg.style.visibility="visible";
			form.negocio2.focus();
			rengPOP.style.visibility="hidden";}
		
		else if (form.negocio.value=="Comercializadora")
		{	form.negocio2.style.visibility=txtNeg.style.visibility="hidden";
			form.negocio2.value= "";
			rengPOP.style.visibility="visible";
			form.POP[0].checked=true;
		}
		
		else
		{	form.negocio2.style.visibility=txtNeg.style.visibility=rengPOP.style.visibility= "hidden";
			form.negocio2.value= "";}
	}
}
//-------------------------------------------------------------------------------------------------------------------------
function validaCamposClt(form)
{
	if (form.region.value=="Mex")
	{	var nombre=document.getElementById("nombreMex");
		var lada=document.getElementById("ladaMex");
		var tel=document.getElementById("telMex");
		var ext=document.getElementById("extMex");
		var email=document.getElementById("emailMex");
		var asunto=document.getElementById("asuntoMex");
		var coment=document.getElementById("comentMex");	}
	else
	{	var nombre=document.getElementById("nombreLA");
		var lada=document.getElementById("ladaLA");
		var tel=document.getElementById("telLA");
		var ext=document.getElementById("extLA");
		var email=document.getElementById("emailLA");
		if (form.region.value=="LA")
		{	var pais=document.getElementById("pais");	}
		else { var pais=document.getElementById("paisE");	}
		var asunto=document.getElementById("asuntoLA");
		var coment=document.getElementById("comentLA");
	}
	
	if (form.region.value!="EUA")
	{	if (asunto.value == "Selecciona")
		{	alert("Selecciona el asunto del mensaje");
            asunto.focus();
            return false;	}
	}

	if (nombre.value == "")
	{	alert("Introduce tu nombre completo");
        nombre.focus();
        return false;	}
	if (tel.value == "")
	{	if (form.region.value == "Mex")
		{ 	if (form.cel.value == "")
			{	alert("Introduce al menos un número telefónico para contactarte");
        		lada.focus();
        		return false;	}
		}
		else
		{	alert("Introduce un número telefónico para contactarte");
        	lada.focus();
        	return false;	}
	}
	if (form.region.value == "Mex")
	{
		if (form.calle.value == "")
		{	alert("Introduce la calle y número para contactarte");
            form.calle.focus();
            return false;
	    }
		if (form.colonia.value == "")
		{	alert("Introduce la colonia");
            form.colonia.focus();
            return false;
	    }
		if (form.codpost.value == "")
		{	alert("Introduce tu código postal");
            form.codpost.focus();
            return false;
	    }						
 		if (form.estado.value == "Selecciona")
		{	alert("Selecciona el estado en dónde vives");
            form.estado.focus();
            return false;
	    }
		else if (form.estado.value == "Edo. Méx.")
		{
			if (form.entidad2.value == "Selecciona")
			{	alert("Introduce la población o municipio en dónde vives");
                form.entidad2.focus();
                return false;	}
			else if (form.entidad2.value == "Otro" && form.municipio.value == "")
			{	alert("Especifica la población o municipio en dónde vives");
                form.municipio.focus();
                return false;
			}
		}
		else if (form.estado.value == "D.F.")
		{
			if (form.delegacion.value == "Delegación")
			{	alert("Selecciona la delegación en dónde vives");
                form.delegacion.focus();
                return false;	}
		}
		else if (form.entidad.value == "")
		{	alert("Introduce la población o municipio dónde vives");
            form.entidad.focus();
            return false;	}
		if (form.negocio.value=="Selecciona")
		{	alert("Selecciona el tipo de negocio");
            form.negocio.focus();
            return false;	}
		else if (form.negocio.value == "Otro" && form.negocio2.value == "")
		{	alert("Especifica el tipo de negocio");
            form.negocio2.focus();
            return false;	}
		if (form.alta[0].checked && form.rfc.value == "")
		{	alert("Introduce RFC");
            form.rfc.focus();
            return false;	}
		if (form.asuntoMex.value=="Quiero ser distribuidor directo y cuento con establecimiento de venta al público")
		{	
			if (form.negocio.value=="Comercializadora" && form.POP[1].checked)
			{	alert("Para ser distribuidor directo es necesario tener establecido un punto de venta al público");
            	form.POP[0].checked=true;
				form.POP[1].checked=false;
				return false;	}

			if (form.alta[1].checked)
			{	alert("Para ser distribuidor directo es necesario estar dado de alta en hacienda");
            	form.alta[0].checked=true;
				form.alta[1].checked=false;
				form.rfc.style.visibility= "visible";
				form.rfc.focus();
				txtRfc=document.getElementById("rengRFC");
				txtRfc.style.visibility= "visible";
            	return false;	}
		}
	}
	else
	{	if (form.direccion.value=="")
		{	alert("Introduce la dirección dónde vives");
            form.direccion.focus();
            return false; 	}
	
		if (pais.value == "" || pais.value == "Selecciona")
		{	alert("Introduce el país dónde vives");
            pais.focus();
            return false; 	}
		if (form.ciudad.value == "")
			{	alert("Introduce la ciudad dónde vives");
                form.ciudad.focus();
                return false;	}
	}
	if (form.region.value!="EUA")
	{	if (coment.value == "")
		{	alert("Escribe tu comentario");
            coment.focus();
            return false;	}
	}
	if (form.tmptxt.value == "")
	{	alert("Captura los caracteres de la imagen");
        form.tmptxt.focus();
        return false;
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)))
	{
		alert ("Introduce o verifica tu dirección de correo electrónico");
		email.focus();
		return false;
	}
	

form.boton.value="Enviando...";
form.boton.disabled=true;
form.submit();
}
//-------------------------------------------------------------------------------------------------------------------------
function validaCamposCltIng(form)
{
	if (form.nombre.value == "")
	{	alert("Enter your name");
        form.nombre.focus();
        return false;	}
	if (form.tel.value == "")
	{	alert("Enter a telephone number");
        form.lada.focus();
        return false;	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)))
	{
		alert ("Enter a valid e-mail address");
		form.email.focus();
		return false;	}
	if (form.pais.value == "")
	{	alert("Enter your Country");
        form.pais.focus();
        return false; 	}
	if (form.ciudad.value == "")
	{	alert("Enter your City");
        form.ciudad.focus();
        return false;	}
	if (form.direccion.value=="")
	{	alert("Enter your Address");
        form.direccion.focus();
        return false; 	}
	if (form.region.value=="LA")
	{	if (form.asunto.value == "")
		{	alert("Select the message subject");
            form.asunto.focus();
            return false;	}
		if (form.coment.value == "")
		{	alert("Write a message");
            form.coment.focus();
            return false;	}
	}
	
form.boton.value="Sending...";
form.boton.disabled=true;
form.Reset.disabled=true;
form.submit();
}
//-------------------------------------------------------------------------------------------------------------------------
function recargaCaptcha(seccion)
  {
   document.images.cap1.src="";
   document.images.cap1.src="captcha.php?im=1&"+Date();
   if (seccion=="cv")
   {	document.images.cap2.src="";
   		document.images.cap2.src="captcha.php?im=2&"+Date();  }
  }
//-------------------------------------------------------------------------------------------------------------------------
function escondeTabla(area)
  {
	var tabla1=document.getElementById("tablaMex");
	var tabla2=document.getElementById("tablaLat");
	var titulo=document.getElementById("tdTit");
	var tr=document.getElementById("trAsuntoLat");
	var tabla3=document.getElementById("tablaReq");
	var campo1=document.getElementById("paisE");
	var campo2=document.getElementById("pais");
	var campo3=document.getElementById("region");
	dis= true ? '' : 'none';
	dis2= false ? '' : 'none';
	if (area=="Asunto")
	{	var asunto=document.getElementById("asuntoMex");
		if (asunto.value=="Quiero ser distribuidor directo y cuento con establecimiento de venta al público")
		{	tabla3.style.display=dis; }
		else { tabla3.style.display=dis2; }
	}
	else if (area.value=="Mex")
	{
		tabla1.style.display=dis;
		tabla2.style.display=dis2;
		titulo.firstChild.nodeValue="  DISTRIBUIDOR MÉXICO  ";
		campo3.value="Mex";
	}
	else 
	{
		if (area.value=="EUA")
		{	titulo.firstChild.nodeValue="  DISTRIBUIDOR EUROPA, EUA Y CANADÁ  ";
			tr.style.display=campo2.style.display=dis2;
			campo1.style.display=dis;
			campo3.value="EUA";
		}

		else 
		{	titulo.firstChild.nodeValue="  DISTRIBUIDOR LATINOAMÉRICA  ";
			tr.style.display=campo2.style.display=dis;
			campo1.style.display=dis2;
			campo3.value="LA";
		}
		tabla1.style.display=dis2;
		tabla2.style.display=dis;
	}
  }
