﻿var myWindow;

function openCenteredWindow(url) {
}
function OpenShare(url, X, Y)
{
    var width = X;
    var height = Y;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "subWind", windowFeatures);

}


function clickmenut()
{
 window.open("Tabla de recompensas.pdf","_blank");
}

function hoverbotmenu()
{

 if(navigator.appName=='Microsoft Internet Explorer') 
    {     
      document.getElementById('clubMenuBotOFF2').style.backgroundImage = "url(../images/clubHitv/leftm_foot_ON.jpg)";            
      document.getElementById('clubMenuBotOFF2').style.backgroundRepeat = "no-repeat";
      document.getElementById('clubMenuBotOFF2').style.cursor="hand";
    }
 else
    {
      document.getElementById('clubMenuBotOFF2').setAttribute("style","background-image:url(../images/clubHitv/leftm_foot_ON.jpg);background-repeat:no-repeat; width:242px; height:110px;");    
    }
}

function Outbotmenu()
{

if(navigator.appName=='Microsoft Internet Explorer') 
    {     
      document.getElementById('clubMenuBotOFF2').style.backgroundImage = "url(../images/clubHitv/leftm_foot_OFF.jpg)";     
      document.getElementById('clubMenuBotOFF2').style.backgroundRepeat = "no-repeat";
      
      
      
    }
 else
    {
      document.getElementById('clubMenuBotOFF2').setAttribute("style","background-image:url(../images/clubHitv/leftm_foot_OFF.jpg);background-repeat:no-repeat; width:242px; height:110px;");    
    }
}

function SetPostContac()
{
   if(navigator.appName=='Microsoft Internet Explorer') 
    {    
      var browser=parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5));      
       if (browser == 6)
        {                       
           document.getElementById('txtNombre').style.position =  "absolute";           
           document.getElementById('txtNombre').style.top = 17;
         
          document.getElementById('txtEdad').style.position =  "absolute";           
          document.getElementById('txtEdad').style.top = 72;
                  
          document.getElementById('txtMail').style.position =  "absolute";           
          document.getElementById('txtMail').style.top = 128;
         
          document.getElementById('txtCp').style.position =  "absolute";           
          document.getElementById('txtCp').style.top = 183;
                   
        }     
    }
}

function SetPostContacTes()
{
   if(navigator.appName=='Microsoft Internet Explorer') 
    {         
    
    
       document.getElementById('labelMaster').style.position = "absolute";
       document.getElementById('labelMaster').style.top = 42;
       //document.getElementById('labelMaster').style.left = 10; 
    }
}
function SetPositcober()
{
  var ua = navigator.userAgent.toLowerCase(); 
  if ( ua.indexOf( "safari" ) != -1 ) 
    {               
    
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.top = "417px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.left = "50px"; 
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.top = "433px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.left = "50px"; 
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.top = "345px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.left = "90px";  
              
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.top = "342px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.left = "80px";  
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgBtnZipCode').setAttribute("style","border-width:0px; z-index :2; position: absolute; top : 459px; left: 228px; height: 34px; width: 37px;");                  
    } 
  if(navigator.appName=='Microsoft Internet Explorer') 
    {  
    
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.top = "343px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.left = "90px";  
       
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.top = "340px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_ImgImput0').style.left = "80px";  
       
       
       /*document.getElementById('ctl00$ContentPlaceHolder1$MainContent$ImgBtnZipCode').style.position = "absolute";
       document.getElementById('ctl00$ContentPlaceHolder1$MainContent$ImgBtnZipCode').style.top = "455px";
       document.getElementById('ctl00$ContentPlaceHolder1$MainContent$ImgBtnZipCode').style.left = "228px";  
       */
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.top = "420px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober6').style.left = "50px"; 
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.top = "435px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_lblcober7').style.left = "50px"; 
            
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobosi').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobosi').style.top = "100px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobosi').style.left = "350px"; 
       
       
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobono').style.position = "absolute";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobono').style.top = "100px";
       document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobono').style.left = "350px"; 
       
             
    }
    
    
}

function RuncoberContac(vr)
{
   if (vr.keyCode == 13)
    {           
        window.open('int_Puedo.aspx?Invent='+ document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCodeContac').value,'_parent');
    }
  var s = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCodeContac').value;
   if(s== '0' || s== '00' || s== '000' || s== '0000' || s== '00000')
    {          
    }
    else
    {
     if (! Number(document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCodeContac').value ))
        {
            document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCodeContac').value = s.substring(0,s.length-1);    
        }
    }
}

function runcober()
{

 var valzip = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode').value;
 if (valzip == "" | valzip.length <5 )
 {
   //alert ("ingrese Código Postal correcto.");
 }
 else
 {
 if(navigator.appName=='Microsoft Internet Explorer') 
   {     
     document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_HlkZip').href="int_Puedo.aspx?Invent="+ valzip;
    }
    
    else
    {      
     
     document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_HlkZip').setAttribute("href","int_Puedo.aspx?Invent="+ valzip);    
    }
 }
 
}







function zipval(vr)
{
	var s = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode').value;
	var fieldS = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode');
	var formSub = document.getElementById('Form');
	var valid_bol = true;
	if (vr.keyCode == 13)
	{
		ValidaCP();
		return false;
	}
	if (isNaN(s))
	{
	  //Valida que sea numérico el CP, en caso contrario elimina el último caracter ingresado
		fieldS.value = s.substring(0,s.length-1);    
	}
	return false;
}

function SetPosition()
{
if(navigator.appName=='Microsoft Internet Explorer') 
   {
  
  
    document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.position ='absolute';                                                
    document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.left=264;     
    document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').style.top= 484;  
  }
  
}
function NuevaValZip()
{

	var s = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').value;
	//alert(s)
	var fieldS = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode');
	var valid_bol = true;
    if (s.length>0)
	{    
	 	if (s.length < 5)
		{
		  //valida que sean los 5 numeros
			alert("El Código Postal no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
			fieldS.focus();
			valid_bol = false;
		}
		else
		{
			if (parseInt("10", s) == 0 || s=='00000')
			{
			   //restringe el CP 00000
				alert("El Código Postal "+ s +" no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
				fieldS.focus();
				valid_bol = false;
				return false;
			}
			else
			{
				//document.aspnetForm.submit(valid_bol);
				//alert(s);
				getCP(s);
				return false;
			}
		}
	}



}

function HideZipCode(vr)
{
	var s = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode').value;
	var fieldS = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_TxtZipCode');
	
    if (vr.keyCode == 13)
	{
		NuevaValZip();
		return false;
	}
	else{
		if (isNaN(s))
		{
			fieldS.value = s.substring(0,s.length-1);    
		}
    }
	 if(navigator.appName=='Microsoft Internet Explorer') 
	   {          
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_Pnlsn').style.visibility ='hidden';  
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobono').style.visibility ='hidden';  
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobosi').style.visibility ='hidden';               
	   }
	   else
	   {                           
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_Pnlsn').setAttribute("style","position:absolute;top:465px; left :415px; width: 257px; height: 58px; visibility :hidden");       
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobono').setAttribute("style","background-image:url(imagenes/leftMenu/PuedoGlobo.gif); visibility:hidden ; position:absolute; top:250px; left :365px; width: 274px; height: 177px;");
		 document.getElementById('ctl00_ContentPlaceHolder1_MainContent_PnlGlobosi').setAttribute("style","background-image:url(imagenes/leftMenu/PuedoGlobo.gif); visibility:hidden ; position:absolute; top:250px; left :365px; width: 274px; height: 177px;");      
	   }
}

function HideZipCode2(evt,Whois)
{
	var s = Whois.value;
	var fieldS = Whois;
	
	var e = evt
	if(window.event){ // IE
		var charCode = e.keyCode;
	} else if (e.which) { // Safari 4, Firefox 3.0.4
		var charCode = e.which
	}

	if (charCode == 13)
	{
		NuevaValZip();
		return false;
	}
	else{
		if (isNaN(s))
		{
			fieldS.value = s.substring(0,s.length-1);    
		}
    }
	return true;

}
function ImgWait()
{
  var text = "se desdabilito temporalmenrte";
// if(navigator.appName=='Microsoft Internet Explorer') 
//    {
//      document.getElementById('ctl00_ContentPlaceHolder1_MainContent_imgWait').style.visibility  = "visible"; 
//    }
//    else
//    {
//      document.getElementById('ctl00_ContentPlaceHolder1_MainContent_imgWait').setAttribute("style","border-width:0px;position:absolute ; top:260px; left:550px ; visibility:visible;");  
//    }  
}
function ImgBtnZipCode(va)
{
	if(va == "No")
	{
		window.open('int_Puedo_No.aspx','_parent'); 
	}
	else
	{
		window.open('int_Puedo_Si.aspx','_parent');
	}
}

function GetMessageBox(val)
{
    alert(val);
}
  
  
function Mhover(id)
{ 
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById('LeftMenuTopOFF').style.backgroundImage = "url(images/leftm_top_ON.jpg)"; /* background-position:bottom left; width:248px; height:60px;";*/
    else
        document.getElementById('LeftMenuTopOFF').setAttribute("style","background-image:url(images/leftm_top_ON.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
}

function Mhout(id)
{ 
 var s =document.getElementById('LeftMenuTopOFF').style.backgroundImage.split('/');
 var img = s[1].replace(")","");

 if (img= "leftm_top_ON.jpg")
 {
 var u =document.URL.split('/');
 var p = u[u.length -1].replace(")","");
   if (p!="int_Quees.aspx")
   {
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById('LeftMenuTopOFF').style.backgroundImage = "url(images/leftm_top_OFF.jpg)";
    else
        document.getElementById('LeftMenuTopOFF').setAttribute("style","background-image:url(images/leftm_top_OFF.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
   }
  }
}

function Mhover1(id)
{
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById(id).style.backgroundImage = "url(images/leftm_ON.jpg)"; 
    else
        document.getElementById(id).setAttribute("style","background-image:url(images/leftm_ON.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:50px;");
}

function Mhout1(id, page)
{ 
 var s =document.getElementById(id).style.backgroundImage.split('/');
 var img = s[1].replace(")","");
 
 if (img= "leftm_ON.jpg")
 {
    var u =document.URL.split('/');
    var p = u[u.length -1].replace(")","");

    if (p!=page)
        {
        if(navigator.appName=='Microsoft Internet Explorer') 
            document.getElementById(id).style.backgroundImage = "url(images/leftm_OFF.jpg)"; 
        else
            document.getElementById(id).setAttribute("style","background-image:url(images/leftm_OFF.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:50px;");
        }
    } 
}

function Mhover6(id)
{ 
        if(navigator.appName=='Microsoft Internet Explorer') 
            document.getElementById('LeftMenuBotOFF').style.backgroundImage = "url(images/leftm_bot_ON.jpg)"; 
        else
            document.getElementById('LeftMenuBotOFF').setAttribute("style","background-image:url(images/leftm_bot_ON.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
}

function Mhout6(id)
{ 

 var s =document.getElementById('LeftMenuBotOFF').style.backgroundImage.split('/');
 var img = s[1].replace(")","");

 if (img= "leftm_bot_ON.jpg")
 {
    var u =document.URL.split('/');
    var p = u[u.length -1].replace(")","");

    if (p!="int_Testi.aspx")
        {
        if(navigator.appName=='Microsoft Internet Explorer') 
            document.getElementById('LeftMenuBotOFF').style.backgroundImage = "url(images/leftm_bot_OFF.jpg)"; 
        else
            document.getElementById('LeftMenuBotOFF').setAttribute("style","background-image:url(images/leftm_bot_OFF.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
        }
   
 }
}




function MClubhover(id)
{
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById('clubMenuTopOFF').style.backgroundImage = "url(images/clubHitv/leftm_top_ON.jpg)"; 
    else
        document.getElementById('clubMenuTopOFF').setAttribute("style","background-image:url(images/clubHitv/leftm_top_ON.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
}

function MClubhout(id)
{ 
 var s =document.getElementById('clubMenuTopOFF').style.backgroundImage.split('/');
 var img = s[2].replace(")","");

 if (img= "leftm_top_OFF.jpg")
 {
 var u =document.URL.split('/');
 var p = u[u.length -1].replace(")","");
   if (p!="int_ClubQuees.aspx")
   {
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById('clubMenuTopOFF').style.backgroundImage = "url(images/clubHitv/leftm_top_OFF.jpg)"; 
    else
        document.getElementById('clubMenuTopOFF').setAttribute("style","background-image:url(images/clubHitv/leftm_top_OFF.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:60px;");
   }
  }
}

function MClubhover1(id)
{
    if(navigator.appName=='Microsoft Internet Explorer') 
        document.getElementById(id).style.backgroundImage = "url(images/clubHitv/leftm_ON.jpg)"; 
    else
        document.getElementById(id).setAttribute("style","background-image:url(images/clubHitv/leftm_ON.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:50px;");
}

function MClubhout1(id, page)
{ 
 var s =document.getElementById(id).style.backgroundImage.split('/');
 var img = s[2].replace(")","");
 
 if (img= "leftm_OFF.jpg")
 {
    var u =document.URL.split('/');
    var p = u[u.length -1].replace(")","");
    if (p!=page)
        {
        if(navigator.appName=='Microsoft Internet Explorer') 
            document.getElementById(id).style.backgroundImage = "url(images/clubHitv/leftm_OFF.jpg)"; 
        else
            document.getElementById(id).setAttribute("style","background-image:url(images/clubHitv/leftm_OFF.jpg);background-repeat:no-repeat; background-position:bottom left; width:248px; height:50px;");
        }
    } 
}

function menu_select()
{
	try
	{
		if (document.getElementById("id_page"))
		{
			var id_page = document.getElementById("id_page").value;
			document.getElementById("m_" + id_page).className = "leftMenuSelect";
		}
    }
    catch(e){}
}


//  Nuevas funciones

function ValidaCP()
{
	var s = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode').value;
	
	
	var fieldS = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode');
	var formSub = document.getElementById('Form');
	var valid_bol = true;
	if(s.length > 0)
	{
		if (s.length < 5)
		{
		  //valida que sean los 5 numeros
			alert("El Código Postal no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
			fieldS.focus();
			valid_bol = false;
		}
		else
		{
			if (parseInt("10", s) == 0 || s=='00000')
			{
			   //restringe el CP 00000
				alert("El Código Postal "+ s +" no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
				fieldS.focus();
				valid_bol = false;
			}
			else
			{
				// Obtiene mediante Ajax si un CP tiene covertura
				getCP(s);
				/*
				if (zXmlHttp.isSupported()) {        
					UrlAjax = "getCP.aspx?I="+s
					var ua = BrowserDetect.browser; 
					var vers = BrowserDetect.version;
					var oXmlDom = zXmlHttp.createRequest();
					var Nodoss;
					oXmlDom.open("get",UrlAjax,true);
					oXmlDom.onreadystatechange = function () 
					{
						if (oXmlDom.readyState == 4) 
						{
							if (oXmlDom.status == 200) 
							{
								var oRoot = oXmlDom.responseXML;
								var Cobertura;
								if (ua == "Explorer") 
								{
									Nodoss = oRoot.childNodes[1].childNodes[0]; 
									Cobertura = oRoot.childNodes[1].childNodes[0].text; 
								}
								else
								{
									Nodoss = oRoot.childNodes[0].childNodes[0]; 
									Cobertura = Nodoss.firstChild.nodeValue;
								}
								if (Cobertura == 1)
								{
//									alert("tiene cobertura")
									window.location.href="int_Puedo_Si.aspx";
								}
								else
								{
									//alert("Lo sentimos no tiene cobertura");
									window.location.href="int_Puedo_No.aspx";
								}
							}
							else 
							{
								//Se presento un error
								//alert("Intentalo más tarde");
							}
						}
						//oXmlDom = null;
					};
					oXmlDom.send(null);
//					oXmlDom.load(UrlAjax);
				}
				else
				{
					theForm.submit(true);
				}
				*/
			}
		}
	}
}
function zipval0(vr)
{
	var s = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode').value;
	var fieldS = document.getElementById('ctl00_ContentPlaceHolder1_EncuestaContet_TxtZipCode');
	var formSub = document.getElementById('Form');
	var valid_bol = true;
	if (vr.keyCode == 13)
	{
		ValidaCP();
		return false;
	}
	if (isNaN(s))
	{
	  //Valida que sea numérico el CP, en caso contrario elimina el último caracter ingresado
		fieldS.value = s.substring(0,s.length-1);    
	}
	return false;
}
function Trim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}
function validar_contacto_09(Formulario)
{
	var valid_bol = true;
	var Nombre = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_txtNombre');
	var edad = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_txtEdad');
	var CP = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_txtCp');
	var eMail = document.getElementById('ctl00_ContentPlaceHolder1_MainContent_txtMail');
	var eComentarios = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtComentarios;
	//alert(eComentarios);
	if (valid_bol && Trim(Nombre.value).length <= 0){
            alert("Introduce tu nombre.");
            Nombre.value = "";
            Nombre.focus();
            valid_bol = false;
     }
    if (valid_bol && Trim(Nombre.value).length >50)
    {
        alert("Introduce tu nombre con menos de 50 caracteres.");
        Nombre.value = "";
        Nombre.focus();
        valid_bol = false;
    }

    if (valid_bol && isNaN(edad.value))
    {
        alert("Introduce tu edad.");
        edad.value = "";
        edad.focus();
        valid_bol = false;
    }
   else
    {
	    if (valid_bol && (edad.value <= 0 || edad.value >120 ))
		{
            alert("Verifica la Edad.");
            edad.value = "";
            edad.focus();
            valid_bol = false;
         }    
    }
	
    var valor=eMail.value;
    if (valid_bol && (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))))
    {
        //eMail.value = "";
        alert("No es una dirección de correo electrónico válida.");
        eMail.focus();
        valid_bol = false;
    }	
	
	
	var s = CP.value;
	var fieldS = CP;
	if(valid_bol)
	{
		if(s.length > 0)
		{
			if (s.length < 5)
			{
			  //valida que sean los 5 numeros
				alert("El Código Postal no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
				fieldS.focus();
				valid_bol = false;
			}
			else
			{
				if (parseInt("10", s) == 0 || s=='00000')
				{
				   //restringe el CP 00000
					alert("El Código Postal "+ s +" no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
					fieldS.focus();
					valid_bol = false;
				}
				else
				{
					// Obtiene mediante Ajax si un CP tiene covertura
					//	alert("Validación de cobertura para el Código Postal " + s);
					//		ImgWait();
					//alert("buscando");
				}
			}
		}
		else
		{
			alert("Debes de ingresar tu C.P." + s);
			CP.value = "";
			CP.focus();
			valid_bol = false;
		}
}	
    if (valid_bol && (isNaN(CP.value) || CP.value.length > 5))
    {
        alert("Verifica el C.P.");
        CP.value = "";
        CP.focus();
        valid_bol = false;
    }

    if (valid_bol && Trim(eComentarios.value).length <= 0)
    {
        alert("Introduce los Comentarios");
        eComentarios.focus();
        valid_bol = false;
    }
    if (valid_bol)
    {
        //alert("se puede enviar")
        Formulario.submit();
    }
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};


function DisplClub()
{
    if (document.getElementById("id_page"))
    {
		var id_page = document.getElementById("id_page").value;
		if (id_page == 1)
		{
			$(document).ready(function(){
				var COOKIE_NAME = 'Club';
				if ($.cookie(COOKIE_NAME) != null)
				{
					$.cookie('Club', null);
				}
				else
				{
					$.cookie('Club', 'true', {expires: 1});
					tb_show('gana fabulosos regalos', 'club.htm?height=380&amp;width=410&amp;modal=true', null);
				}
			});
		}
    }
	
}


BrowserDetect.init();

function getCP(s)
{
	var WS="getCP_WS.aspx";
	var UrlAjax = WS+"?cp="+s;
	
	var cols = "";
	var ua = BrowserDetect.browser; 
	var vers = BrowserDetect.version;
	if (zXmlHttp.isSupported()) {        
		var oXmlDom = zXmlHttp.createRequest();
		try {
			oXmlDom.open("get",UrlAjax,true);
			oXmlDom.onreadystatechange = function () 
			{
				if (oXmlDom.readyState == 4) 
				{
					if (oXmlDom.status == 200) 
					{
						var oRoot = oXmlDom.responseXML;
						var Status = 0;
						var Nodoss; 
						var Total;
						if (ua == "Explorer") 
						{
							Nodoss = oRoot.childNodes[1].childNodes[0].childNodes[0].firstChild; 
							Total = oRoot.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes.length;
						}
						else
						{
							Nodoss = oRoot.childNodes[0].childNodes[0].childNodes[0].firstChild; 
							Total = oRoot.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes.length;
						}
						for (a=0; a < Total; a++)
						{
							var Internos = Nodoss.childNodes[a].childNodes.length;
							for (b=0; b<Internos;b++)
							{
								if (Nodoss.childNodes[a].childNodes[b].nodeName == "colonia")
								{
									cols  = cols   + "\n" + Nodoss.childNodes[a].childNodes[b].text;
								}
								if (Nodoss.childNodes[a].childNodes[b].nodeName == "idError")
								{
									if (Nodoss.childNodes[a].childNodes[b].text == 1)
									{
										Status = Status + 1;
									}
									cols  = cols   + " " + Nodoss.childNodes[a].childNodes[b+1].text;
								}
							}
						}
						if (Status == 0)
						{
							//alert("Si hay cobertura");
							pageTracker._trackEvent('Cobertura','Resultado','Con cobertura');
							window.location.href="int_Puedo_Si.aspx";
						}
						else
						{
							if (Status == Total)
							{
								//alert("No hay cobertura");
								pageTracker._trackEvent('Cobertura','Resultado','Sin cobertura CP: ' + s);
								window.location.href="int_Puedo_No.aspx?zip=" + s;
							}
							else
							{
								//alert("Cobertura parcial");
								pageTracker._trackEvent('Cobertura','Resultado','Con cobertura parcial');
								window.location.href="int_Puedo_Si.aspx";
							}
						}
					}
					else 
					{
						//Se presento un error
						//alert("Intentalo más tarde" );
					}
				}
			};
			oXmlDom.send(null);
			return false;
		}
		catch (oError) {
			//alert(oError.message);
			throw new Error("Houston we have a problem: " + oError.message); 
			return false; 
		}
		finally 
		{ 
			return false; 
		} 
	}
	else
	{
		alert("No lo soporta");
	}
}


function validar_contacto_0902(Formulario)
{
	//alert(Formulario)
	var valid_bol = true;
	var Nombre = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtName;
	var edad = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtEdad;
	var CP = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtZIP;
	var eMail = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtEmail;
	var eComentarios = Formulario.ctl00$ContentPlaceHolder1$MainContent$txtComentarios;


	if (valid_bol && Trim(Nombre.value).length <= 0){
            alert("Introduce tu nombre.");
            Nombre.value = "";
            Nombre.focus();
            valid_bol = false;
     }
    if (valid_bol && Trim(Nombre.value).length >50)
    {
        alert("Introduce tu nombre con menos de 50 caracteres.");
        Nombre.value = "";
        Nombre.focus();
        valid_bol = false;
    }

    if (valid_bol && isNaN(edad.value))
    {
        alert("Introduce tu edad.");
        edad.value = "";
        edad.focus();
        valid_bol = false;
    }
   else
    {
	    if (valid_bol && (edad.value <= 0 || edad.value >120 ))
		{
            alert("Verifica la Edad.");
            edad.value = "";
            edad.focus();
            valid_bol = false;
         }    
    }
	
    var valor=eMail.value;
    if (valid_bol && (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))))
    {
        //eMail.value = "";
        alert("No es una dirección de correo electrónico válida.");
        eMail.focus();
        valid_bol = false;
    }	
	
	
	var s = CP.value;
	var fieldS = CP;
	if(valid_bol)
	{
		if(s.length > 0)
		{
			if (s.length < 5)
			{
			  //valida que sean los 5 numeros
				alert("El Código Postal no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
				fieldS.focus();
				valid_bol = false;
			}
			else
			{
				if (parseInt("10", s) == 0 || s=='00000')
				{
				   //restringe el CP 00000
					alert("El Código Postal "+ s +" no es válido.\nPor favor ingresa los 5 números de tu Código Postal.");
					fieldS.focus();
					valid_bol = false;
				}
				else
				{
					// Obtiene mediante Ajax si un CP tiene covertura
					//	alert("Validación de cobertura para el Código Postal " + s);
					//		ImgWait();
					//alert("buscando");
				}
			}
		}
		else
		{
			alert("Debes de ingresar tu C.P." + s);
			CP.value = "";
			CP.focus();
			valid_bol = false;
		}
}	
    if (valid_bol && (isNaN(CP.value) || CP.value.length > 5))
    {
        alert("Verifica el C.P.");
        CP.value = "";
        CP.focus();
        valid_bol = false;
    }

    if (valid_bol && Trim(eComentarios.value).length <= 0)
    {
        alert("Introduce los Comentarios");
        eComentarios.focus();
        valid_bol = false;
    }
    if (valid_bol)
    {
        //alert("se puede enviar")
        Formulario.submit();
    }
}