function validarZIPArea()
			{
      cadenaVector = document.getElementById("valZIP").value;
      cadenaVector = cadenaVector.split(",");
      campoValidar = document.getElementById("pcode").value;
      for(var g=0 ;g<cadenaVector.length;g++)
          {
           if (cadenaVector[g]==campoValidar)
					 		{	var resultID=1; return true;}
						else
							{ var resultID=0;  var ncampo=campoValidar; }
          }
      if (result==0)
					{  alert("Require enter valid Code postal. ERROR: ["+ncampo+"]"); return false; }
			}
function validZipFormat(zip)
			{
			zip=zip.toUpperCase();
			if ((zip.length!=3))
				 {			
				 alert ('ERROR: require enter a second postal code'); 
				 setBGColor('pcodeB','wwwform','#ffc6c6');
				 return false; 
				 }
			else if (zip.match(/^[0-9][A-Z][0-9]$/)) 
				 { 		return true; }
			else if (zip.match(/^[0-9][a-z].[0-9]$/)) 
				 {    return true; }
			else
				 {
				 alert('ERROR: Bad Postal code format (Number,Letter,Number: 5d5)');
				 setBGColor('pcodeB','wwwform','#ffc6c6');
				 return false;
				 }
			}

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
function setBGColor(id,nestref,color) 
			 {
				 if (ns4) 
				 		{
						var lyr = (nestref)? eval('document.'+nestref+'.document.'+id):document.layers[id]
						lyr.document.bgColor = color
						}
				else if (ie4) 
					 {
					 document.all[id].style.backgroundColor = color
					 }
			}
function WContacTenos(lang)
  {
          if (wwwform.names.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your NAME!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre nom !'); }
								else
								{ alert ('ALERTA: Ingrese su NOMBRE!'); }
             setBGColor('names','wwwform','#ffc6c6');
             wwwform.names.focus();
             return false;
             }
          if (wwwform.lastname.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your LAST NAME!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre prénom!'); }
								else
								{ alert ('ALERTA: Ingrese sus APELLIDOS!'); }
             setBGColor('lastname','wwwform','#ffc6c6');
             wwwform.lastname.focus();
             return false;
             }
          if (wwwform.pcode.value.replace(/ /g, "") == "") 
             {
             if (lang=="en")
						 		{ alert ('ALERT: enter a POSTAL CODE!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez CODE POSTAL'); }
								else
								{ alert ('ALERTA: Ingrese su CODIGO POSTAL!'); }
             setBGColor('pcode','wwwform','#ffc6c6');
             wwwform.pcode.focus();
             return false;
             }
					if (!validarZIPArea())
						 	{
             if (lang=="en")
						 		{ alert ('ALERT: verify your POSTAL CODE, no was found! '); }
								else if (lang=="fr")
								{ alert ('ALERTE: vérifier votre CODE POSTAL, pas été trouvé!'); }
								else
								{ alert ('ALERTA: Verifique su CODIGO POSTAL, no fue encontrado!'); }
							 setBGColor('pcode','wwwform','#ffcc00');
							 wwwform.pcode.focus();
							return false;
							}
					if (!validZipFormat(wwwform.pcodeB.value))
						 	{
             if (lang=="en")
						 		{ alert ('ALERT: verify your second POSTAL CODE, no was found! '); }
								else if (lang=="fr")
								{ alert ('ALERTE: vérifier votre CODE POSTAL, pas été trouvé!'); }
								else
								{ alert ('ALERTA: Verifique su CODIGO POSTAL, no fue encontrado!'); }
							 setBGColor('pcodeB','wwwform','#ffcc00');
							 wwwform.pcodeB.focus();
							return false;
							}
          if (wwwform.phone.value.replace(/ /g, "") == "") 
             {
             if (lang=="en")
						 		{ alert ('ALERT: enter your PHONE NUMBER!  '); }
						 else if (lang=="fr")
								{ alert ('ALERTE: Entrez Téléphone'); }
							else
								{ alert ('ALERTA: Ingrese su número Teléfono!'); }
             setBGColor('phone','wwwform','#ffc6c6');
             wwwform.phone.focus();
             return false;
             }
          if (wwwform.email.value.replace(/ /g, "") == "") 
             { 
								if (lang=="fr")
								{ alert ('ALERTE: Entrez votre EMAIL!'); }
               else if (lang=="es")
						 		{ alert ('ALERTA: Ingrese su CORREO ELECTRONICO!'); }
								else
								{ alert ('ALERT: enter your EMAIL! '); }
             setBGColor('email','wwwform','#ffc6c6');
             wwwform.email.focus();
             return false;
             }
          if (wwwform.comentarios.value.replace(/ /g, "") == "") 
             {
								if (lang=="fr")
								{ alert ('ALERTE: Entrez vos commentaires!'); }
               else if (lang=="es")
						 		{ alert ('ALERTA: Ingrese sus comentarios!'); }
								else
								{ alert ('ALERT: enter your COMMENTS!   '); }
             setBGColor('comentarios','wwwform','#ffc6c6');
             wwwform.comentarios.focus();
             return false;
             }
  }
function validarPhoneArea(areaPhone)
		{
      cadenaVectorList = document.getElementById("codePHONEarea").value;
		  cadenaVector = document.getElementById("codePHONEarea").value;
      cadenaVector = cadenaVector.split(",");
      campoValidar = areaPhone;
      for(var g=0 ;g<cadenaVector.length;g++)
          {
           if (parseInt(cadenaVector[g])==parseInt(areaPhone))
				  {	var resultID=1; return true;}//alert(cadenaVector[g]);
			  else
				  { var resultID=0;  var ncampo = cadenaVector[g];  }//alert(cadenaVector[g]+'='+areaPhone);
          }
      if (resultID==0)
			 {  alert("Require enter valid area code.\nOnly available for CODES: ["+cadenaVectorList+"], code entered:"+areaPhone); setBGColor('phone','wwwform','#ffc6c6');wwwform.phone.focus();	 return false; }
			 else { return true;}
		 }
function ignoreSpaces(string)
		{
		var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
		return temp;
		}
/*VALIDATION EMAIL*/
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }

 		 return true;				
	}

function ValidateForm(email){
	var emailID=email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false;
	}
	if (echeck(emailID.value)==false){
		//emailID.value=""
		emailID.focus()
		return false;
	}
	//return true
 }
/*CLOSE VALIDATION EMAIL*/
function onlyNUMBERS()
		{
		var key=window.event.keyCode;
		if (key < 48 || key > 57)
			 {	 window.event.keyCode=0; }
		}
function wFORMprizeform(lang)
  {
          if (wwwform.names.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your NAME!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre nom !'); }
								else
								{ alert ('ALERTA: Ingrese su NOMBRE!'); }
             setBGColor('names','wwwform','#ffc6c6');
             wwwform.names.focus();
             return false;
             }
          if (wwwform.lastname.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your LAST NAME!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre prénom!'); }
								else
								{ alert ('ALERTA: Ingrese sus APELLIDOS!'); }
             setBGColor('lastname','wwwform','#ffc6c6');
             wwwform.lastname.focus();
             return false;
             }
          if (wwwform.address.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your Address!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre Adresse!'); }
								else
								{ alert ('ALERTA: Ingrese su Dirección!'); }
             setBGColor('address','wwwform','#ffc6c6');
             wwwform.address.focus();
             return false;
             }
          if (wwwform.city.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your City!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre Ville!'); }
								else
								{ alert ('ALERTA: Ingrese su Ciudad!'); }
             setBGColor('city','wwwform','#ffc6c6');
             wwwform.city.focus();
             return false;
             }
          if (wwwform.pcode.value.replace(/ /g, "") == "") 
             {
             if (lang=="en")
						 		{ alert ('ALERT: enter a POSTAL CODE!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez CODE POSTAL'); }
								else
								{ alert ('ALERTA: Ingrese su CODIGO POSTAL!'); }
             setBGColor('pcode','wwwform','#ffc6c6');
             wwwform.pcode.focus();
             return false;
             }
			  if (!validarZIPArea())
				 {
             if (lang=="en")
						 		{ alert ('ALERT: verify your POSTAL CODE, no was found! '); }
								else if (lang=="fr")
								{ alert ('ALERTE: vérifier votre CODE POSTAL, pas été trouvé!'); }
								else
								{ alert ('ALERTA: Verifique su CODIGO POSTAL, no fue encontrado!'); }
							 setBGColor('pcode','wwwform','#ffcc00');
							 wwwform.pcode.focus();
							return false;
				 }
			  if (!validZipFormat(wwwform.pcodeB.value))
				 {
             if (lang=="en")
						 		{ alert ('ALERT: verify your second POSTAL CODE, no was found! '); }
								else if (lang=="fr")
								{ alert ('ALERTE: vérifier votre CODE POSTAL, pas été trouvé!'); }
								else
								{ alert ('ALERTA: Verifique su CODIGO POSTAL, no fue encontrado!'); }
							 setBGColor('pcodeB','wwwform','#ffcc00');
							 wwwform.pcodeB.focus();
							return false;
							}
/*  phone */
          if (wwwform.phone.value.replace(/ /g, "") == "") 
             {
             if (lang=="en")
						 		{ alert ('ALERT: enter your PHONE NUMBER!  '); }
						 else if (lang=="fr")
								{ alert ('ALERTE: Entrez Téléphone'); }
							else
								{ alert ('ALERTA: Ingrese su número Teléfono!'); }
             setBGColor('phone','wwwform','#ffc6c6');
             wwwform.phone.focus();
             return false;
             }

				 var extensionNUMphone, str;
				 str= wwwform.phone.value;
				 str = str.split(/ */); 
				 extensionNUMphone = str[1]+str[2]+str[3];
				 validarPhoneArea(extensionNUMphone);

          if (wwwform.email.value.replace(/ /g, "") == "") 
             { 
								if (lang=="fr")
								{ alert ('ALERTE: Entrez votre EMAIL!'); }
               else if (lang=="es")
						 		{ alert ('ALERTA: Ingrese su CORREO ELECTRONICO!'); }
								else
								{ alert ('ALERT: enter your EMAIL! '); }
             setBGColor('email','wwwform','#ffc6c6');
             wwwform.email.focus();
             return false;
             }
			  ingreso = new String()
          ingreso = wwwform.email.value 
          if (!ingreso.match("@")) 
          { alert("Invalid E-mail ID (missing: @)")
			  wwwform.email.focus();
          return false 
          } 
          ingreso = wwwform.email.value 
          if (!ingreso.match(".")) 
          { alert("Invalid E-mail ID (missing: dot)")
			  wwwform.email.focus();
          return false 
          }
          if (wwwform.HumanDect.value.replace(/ /g, "") == "") 
             {
								if (lang=="fr")
								{ alert ('ALERTE: Entrez le code!'); }
               else if (lang=="es")
						 		{ alert ('ALERTA: Ingrese el codigo de seguridad!'); }
								else
								{ alert ('ALERT: enter security code!   '); }
             setBGColor('HumanDect','wwwform','#ffc6c6');
             wwwform.HumanDect.focus();
             return false;
             }
  }
function valSuscriptoresFORM(lang)
  {
          if (wwwform.nombre.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your NAME!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre nom !'); }
								else
								{ alert ('ALERTA: Ingrese su NOMBRE!'); }
             setBGColor('nombre','wwwform','#ffc6c6');
             wwwform.nombre.focus();
             return false;
             }
          else if (wwwform.email.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter your EMAIL!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez votre COURRIEL !'); }
								else
								{ alert ('ALERTA: Ingrese su CORREO ELECTRONICO!'); }
             setBGColor('email','wwwform','#ffc6c6');
             wwwform.email.focus();
             return false;
             }
          else if (wwwform.HumanDect.value.replace(/ /g, "") == "") 
             { 
             if (lang=="en")
						 		{ alert ('ALERT: enter the SECURITY CODE!'); }
								else if (lang=="fr")
								{ alert ('ALERTE: Entrez SECURE CODE !'); }
								else
								{ alert ('ALERTA: Ingrese el CODIGO DE SEGURIDAD!'); }
             setBGColor('HumanDect','wwwform','#ffc6c6');
             wwwform.HumanDect.focus();
             return false;
             }
					else
						 {
						 return true;
						 }
		}
