var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

function VerEmision() {
    var x = readCookie('1');
    var w = 600;
	var h = 400;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,status=yes,menubar=no,resizable=no';
	//if (x != '1')
	   //var win = window.open("suscripcion/default.asp?origen=emision", "edicion", settings);
	//else
	   var win = window.open("portal_emision/home.html", "edicion", settings);	
	win.focus();
}

function VerClasificados(){
    var x = readCookie('1');
    var w = 600;
	var h = 400;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,status=yes,menubar=no,resizable=no';
	//if (x != '1')
	   //var win = window.open("suscripcion/default.asp?origen=clasificado", "edicion", settings);
	//else
	   var win = window.open("portal_clasificados/home.html", "edicion", settings);	
	win.focus();
}

function VerSuplemento(cod_suplemento) {
    var x = readCookie('1');
    var w = 600;
	var h = 400;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,status=yes,menubar=no,resizable=no';
	//if (x != '1')
	   //var win = window.open("suscripcion/default.asp?origen=suplemento&cod_suplemento=" + cod_suplemento, "edicion", settings);
	//else
	   var win = window.open("portal_suplementos/home.html?cod_suplemento=" + cod_suplemento, "edicion", settings);	
	win.focus();
}

function checkearPopup () {
	 var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');

	 if(mine) {
	   var popUpsBlocked = false
	 }
	 else {
	    var popUpsBlocked = true
	 	mine.close()
		alert('Se ha detectado que el navegador esta bloqueando las ventanas emergentes.\npor favor desactivalo...');
	}
} 

 //Funcion utilizada para la validaciones de las cajas de texto
//Valida que una caja de texto no este en blanco
function RemoverEspacios(inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return returnString;
}

//Funcion que la valida que el string sean solo numeros
function onlyNumbers(inputString)
{
  var searchForNumbers = /\D+/;
  return (searchForNumbers.test(inputString)) ? false : true;
} 

//Funcion que valida la direccion de correo electronico
function ValidaEmail(objeto)
{
	// validar el Campo Correo Electrónico.  Opcional.  Debe ser de la forma xx@xx.xx
	var patron = /\w+@\w+\.\w+/
	objeto.value = RemoverEspacios(objeto.value,' ');
	if ((howManyWords(objeto.value)==1)&&((patron.test(objeto.value)||(objeto.value==''))))
	{
		return true;
	}
	else
	{
		if (howManyWords(objeto.value)>1)
			alert("El campo Correo electrónico no puede contener espacios en blanco");
		else
			alert("Correo electrónico no es válido");
		objeto.focus();
		return false;
	}
}

//Funcion utilizada por la funcion ValidaEmail
function howManyWords(inputString)
{
  return inputString.split(' ').length;
}

var timeoutID;
var frameValues = ['portada/LPR310308D001-1001.jpg', 'portada/LPR310308D048-1001.jpg'];

function rotar_imagenes(i) {
	document.getElementById('image').src = frameValues[i];
	i = (++i == frameValues.length) ? 0 : i
	timeoutID = setTimeout('rotar_imagenes(' + i + ')', 3500)
}	

function createCookie(name,value,hours) {
	if (hours) {
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
