var eplrnd = (new String(Math.random())).substring(2,8) + (((new Date()).getTime()) & 262143);
var sw = (self.innerWidth ? self.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body ? document.body.clientWidth : "");
var sh = (self.innerHeight ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : "");
var wh = (sw && sh) ? (sw.toString(16) + "x" + sh.toString(16)) : "";

function eplAD(espacio_id) {
	var ad = '<scri' + 'pt language="JavaScript" type="text/javascript" src="http://ads.e-planning.net/eb/3/' + sitio_id + '/' + seccion_id + '/' + espacio_id + '?o=j&rnd=' + eplrnd + (wh ? ('&n=' + wh) : '') + '"></scri' + 'pt>';
	document.write(ad);
}

function valida_webmail(){	
	if (document.mailform.username.value==""){
		alert("Por favor, ingrese su nombre de usuario");
		document.mailform.username.focus();
	} else {
		if (document.mailform.password.value==""){
			alert("Por favor, ingrese su contraseña");
		} else {
			document.mailform.submit();
		}
	}
}

function blockA(e) {
	var passtemp = "";
	var key;
	if (document.all) e = window.event;
	if (document.layers) key = e.which;
	if (document.all) key = e.keyCode;
	if (key==13) { 
		document.mailform.submit();
		return true;
	}
}	

/* VALIDACIÓN BUSCADOR  */
function ValidarPalabraBuscador(estevalor){
	estevalor.value = estevalor.value.split('?').join(' ');
	estevalor.value = estevalor.value.split(',').join(' ');
	while(''+estevalor.value.indexOf('  ') > 0)
	  estevalor.value = estevalor.value.split('  ').join(' ');
	while(''+estevalor.value.charAt(0)==' ')
	  estevalor.value = estevalor.value.substring(1,estevalor.value.length);
	while(''+estevalor.value.charAt(estevalor.value.length-1)==' ')
	  estevalor.value = estevalor.value.substring(0,estevalor.value.length-1);
	if ((estevalor.value=="") || (estevalor.value==" ") ||  (estevalor.value=="  ") || (estevalor.value=="   ")) {
		alert("Debe ingresar una palabra para que inicie la búsqueda.");
		return false;
		}

	//var checkOK = "._-áéíóúÁÉÍÓÚçÇãÃõÕüÜàÀêÊ~`@!#$%^&*()-_=+[]{}''|\/<>,.;:\"";
	var checkOK = "._-~`@!#$%^&*()-_=+[]{}'|\/<>,.;:\"";
	var checkStr = estevalor.value;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j < checkOK.length){
			alert("Ingrese una palabra válida.");
			return false;
		}
		allNum += ch;
	}

	return true;
}

function Valida(esteform,estevalor){
	if (!ValidarPalabraBuscador(estevalor)){
		estevalor.focus();
	} else {
		esteform.action = 'http://www.ubbi.com/resultados.asp';
		esteform.q.value = estevalor.value
		esteform.submit();
	}
}
