var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;
var ver = navigator.appVersion.substr(0, 1);

  function check(f) {
    v = f.p_fedicion.value;
    if (v.match(/\d\d\/\d\d\/\d\d/) == null) {
      alert('Debe ingresar la fecha en la forma dd/mm/aa');
      return false;
    }
	return true;
  }
  
  function check2(f) {
     if (f.q.value.length < 4) {
	 	alert("Error! El número mínimo de caracteres es 4!");
		return false;
	 }
	 return true;
  }

function setAlternativa(valor){
    if (valor > 0){ 
	   document.formencuesta.voto_opt[valor - 1].checked = true;
	}
	var dest = 'http://www.prensalibre.com/servicios/NE/vistarapida/resultsurvey.jsp?a='+valor+'&cod='+document.formencuesta.cod.value;
    open(dest, 'PLsurveys', 'width=440,height='+(244+(document.formencuesta.nad.value*23))+',top=75,left=120,resizable=no,scrollbar=no');
}

function verResultados(){
   setAlternativa(0);
}

function showPress(evt) {
    evt = (evt) ? evt : ((event) ? event : null);
    if (evt) {
        var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
		if (charCode == 13) doArch();
    }
}


function convert8d(numero) {
	var tel = numero.value;
	var nuevo_tel = numero.value;
	if (tel>=2000000 && tel<=2199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=2200000 && tel<=2899999) {
	  nuevo_tel = "2"+nuevo_tel;
	} else if (tel>=2900000 && tel<=3199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=3200000 && tel<=3899999) {
	  nuevo_tel = "2"+nuevo_tel;
	} else if (tel>=3900000 && tel<=4199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=4200000 && tel<=4899999) {
	  nuevo_tel = "2"+nuevo_tel;
	} else if (tel>=4900000 && tel<=4999999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=5000000 && tel<=6199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=6200000 && tel<=6899999) {
	  nuevo_tel = "6"+nuevo_tel;
	} else if (tel>=6900000 && tel<=7199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=7200000 && tel<=7899999) {
	  nuevo_tel = "7"+nuevo_tel;
	} else if (tel>=7900000 && tel<=8199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=8200000 && tel<=8899999) {
	  nuevo_tel = "7"+nuevo_tel;
	} else if (tel>=8900000 && tel<=9199999) {
	  nuevo_tel = "5"+nuevo_tel;
	} else if (tel>=9200000 && tel<=9899999) {
	  nuevo_tel = "7"+nuevo_tel;
	} else if (tel>=9900000 && tel<=9989999) {
	  nuevo_tel = "5"+nuevo_tel;
	}
	document.ca8d.numero.style.color="#ff0000";
	return nuevo_tel;
}

function checknum8d(numero){
   //  check for valid numeric strings	
   var blnResult = true;
   if (!numero.value.length==0) {
	   var strValidChars = "0123456789";
	   var strChar;
	   for (i = 0; i < numero.value.length && blnResult == true; i++) {
	      strChar = numero.value.charAt(i);
	      if (strValidChars.indexOf(strChar) == -1)  {
	         blnResult = false;
			 numero.focus();
			 alert("Porfavor ingrese solo números, sin comas ni guiones ni otros signos");
	      }
	   }
   }
   if (blnResult && numero.value.length!=7) {
	   alert("Porfavor ingrese su numero de 7 digitos");
	   numero.focus();
	   blnResult = false;
   }
   if (blnResult && numero.value.length==7) {
     numero.value = convert8d(numero);
   }
   return false;
}
function this_select(myobj) {
   myobj.select();
   myobj.style.color="#000000";
}

function ad_venture() {
   var rnd = (new String(Math.random())).substring(2,8) + (((new Date()).getTime()) & 262143);
   document.write('<scri' + 'pt language=JavaScript1.1 type=text/javascript src=http://ads.us.e-planning.net/eb/3/a75/c4b82d61dbba8684?o=j&rnd=' + rnd + '></scr' + 'ipt>');
}

