
function PressEnter(event)
{		
	//debugger
	eK=event.keyCode; 
	var buscador=false;
			
	if (eK==13)
	{
		if(event.srcElement)
		{
			if(event.srcElement.id=="txtTextoBuscar")
				buscador=true;
		}
		else
		{
			if(event.target.id=="txtTextoBuscar")
				buscador=true;
		}
			
		if(!buscador)
		{			
			if (!Validar())					
				return false					
		}
		else
		{
			/*if(event.srcElement)
			{
				document.getElementById("aBuscador").click();
			}
			else
			{*/	
				var inicio = document.getElementById("aBuscador").href.indexOf("(");
				var fin = document.getElementById("aBuscador").href.indexOf(",");
				var idpais= document.getElementById("aBuscador").href.substring((inicio+1),fin);
				Buscar(idpais,1); 
			//}
			
			return false;
		
		}
	}
	else
	{
		return true				
	}
} 	

function Buscar(idPais, pagina)
{
	var texto = document.Form1.txtTextoBuscar.value;
	texto = trim(texto);
	var ok = true;	
	var aux = new String();	
	
	if(texto.length<3)
	{
		ok=false;
		alert("El texto a buscar debe contener al menos 3 letras.");
		document.Form1.txtTextoBuscar.focus();
	}
	
	if(ok)
	{
		Navegar("./PlantillaBuscador.aspx", {idPais: idPais, pagina: pagina, texto: texto});
	}
}

function Validar()
{	
	var ok = true;				
	if (eval(document.getElementById("trUsuario")))
	{
			if (eval(document.getElementById("txtUsuario")))
				if (document.getElementById("txtUsuario").value=="")
				{
					alert(mensajes[0]);
					document.getElementById("txtUsuario").focus();
					ok = false;		
				}
								
			if (eval(document.getElementById("txtClave")))
				if (ok && document.getElementById("txtClave").value=="")
				{
					alert(mensajes[1]);
					document.getElementById("txtClave").focus();
					ok = false;			
				}
							
			if (ok)
				linkea('LOG');				
							    
	}
}

function PedirContrasena()
{					
	var ok=true;
				
	if(document.getElementById("txtUsuario").value=="")
	{
		ok=false;
		alert(mensajes[2]);
		document.getElementById("txtUsuario").focus();
	}				
					
	if(ok)
		linkea('OLV');
}

function linkea(intpaso)
{
	if(document.Form1.__VIEWSTATE)
	{
		document.Form1.__VIEWSTATE.disabled=true;
	}
	if(document.Form1.__EVENTTARGET)
	{
		document.Form1.__EVENTTARGET.disabled=true;
	}
	if(document.Form1.__EVENTARGUMENT)
	{
		document.Form1.__EVENTARGUMENT.disabled=true;
	}	
	document.Form1.intPaso.value=intpaso;			
	document.Form1.submit();			
}

function NavegarSeccion(idSeccion)
{
	Navegar("./PlantillaSeccion.aspx", {idSeccion: idSeccion});
	window.focus();
}

function VisualizarContenido(contenido)
{
	Navegar("./PlantillaNota.aspx",  {idContenido: contenido});
	window.focus();
}


function LinkContenido(contenido)
{
	Navegar("./PlantillaNota.aspx",  {NombreContenido: contenido});
	window.focus();
}


function ActualizarHtml(data)
{
	document.getElementById("tdCentro").innerHTML = data;
}


createXhrHistoryTracker = function(url, parametros){
	var request = new dojo.io.Request(url, 'text/html', null, false);
	dojo.lang.mixin(request, {
		data: null,
		sync: true,
		method: "post",
		encoding: "utf-8",
		content: parametros,
		load: function(type, evaldObj){ 
			if(type == "load")
			{
				this.data = evaldObj;
				ActualizarHtml(this.data);
			}
		},
		back: function(){ActualizarHtml(this.data);},
		forward: function(){ActualizarHtml(this.data);},
		error: function() {MensajeError(parametros.idPais, this.data);}
	});
	
	return request;
}

function GetCountry(){
	var url = document.URL.toLowerCase();
	if(url.indexOf("/ar/")>0){
		return "/ar/";
	}
	else if(url.indexOf("/bo/")>0){
		return "/bo/";
	}
	else if(url.indexOf("/ca/")>0){
		return "/ca/";
	}
	else if(url.indexOf("/cam/")>0){
		return "/cam/";
	}
	else if(url.indexOf("/cl/")>0){
		return "/cl/";
	}
	else if(url.indexOf("/co/")>0){
		return "/co/";
	}
	else if(url.indexOf("/ec/")>0){
		return "/ec/";
	}
	else if(url.indexOf("/py/")>0){
		return "/py/";
	}
	else if(url.indexOf("/pe/")>0){
		return "/pe/";
	}
	else if(url.indexOf("/uy/")>0){
		return "/uy/";
	}
	else if(url.indexOf("/vz/")>0){
		return "/vz/";
	}
	else{
		return "";
	}
}

function GeneratePaginaNavForWebTrend(paginaNav,country){
	String.prototype.startsWith = function(str){return (this.match("^"+str)==str)}
	if(paginaNav.startsWith("./")){
		return country+paginaNav.substr(2)
	}
	else if(paginaNav.startsWith("/")){
		return country+paginaNav.substr(1)
	}
	else{
		return country+paginaNav;
	}
}

function Navegar(paginaNav, parametros, me){
var country = GetCountry();
//alert(country);
var paginaNev2 = GeneratePaginaNavForWebTrend(paginaNav,country);
dcsMultiTrack('DCS.dcssip', 'www.descubrepoise.com', 'DCS.dcsuri',paginaNev2);

var paginaGoogleAnalytic = paginaNav;
var titulo="";
	
	if(me)
	{
	paginaGoogleAnalytic = me.href;
	}
	else
	{		
		if(parametros)
		{
			if(parametros.idContenido || parametros.idSeccion || parametros.texto || parametros.NombreContenido)
			paginaGoogleAnalytic +="?";

			if(parametros.idContenido)
			{
			paginaGoogleAnalytic += "idContenido=" + parametros.idContenido;
			document.title = "Contenido=" + parametros.idContenido;
			}

			if(parametros.idSeccion)
			{
			paginaGoogleAnalytic += "idSeccion=" + parametros.idSeccion;
			document.title = "Seccion=" + parametros.idSeccion;
			}
			
			if(parametros.texto)
			{
			paginaGoogleAnalytic += "texto=" + parametros.texto;
			document.title = "Buscador";
			}
			if(parametros.NombreContenido)
			{
			paginaGoogleAnalytic += "NombreContenido=" + parametros.NombreContenido;
			document.title = parametros.NombreContenido;
			}
		}
	}	



	dojo.io.bind(createXhrHistoryTracker(paginaNav, parametros));
	
	var elems = document.getElementsByTagName('input')
	for (i = 0; i < elems.length; i++) 
	{
		if(elems[i].id.indexOf('tituloPagina')>=0)
			document.title = otitulo=elems[i].value;
	}
		
	if(poisecom)
		poisecom._trackPageview(paginaGoogleAnalytic);
	if(poisecomtemp)
		poisecomtemp._trackPageview(paginaGoogleAnalytic);
	if(poisepais)
		poisepais._trackPageview(paginaGoogleAnalytic);

	
	window.scrollTo(0,0);
}


function MensajeError(idPais, data){	
	alert(mensajes[8]);	
}

function AumentarLetra(titulo, texto)
{
	var otitulo;
	var otexto;
	
	var elems = document.getElementsByTagName('a')
	for (i = 0; i < elems.length; i++) 
	{
		if(elems[i].id.indexOf(titulo)>=0)
			otitulo=elems[i];
	}
	
	elems = document.getElementsByTagName('div')
	for (i = 0; i < elems.length; i++) 
	{
		if(elems[i].id.indexOf(texto)>=0)
			otexto=elems[i];
	}
	
	if(otitulo.style.fontSize=="")
		otitulo.style.fontSize=22;
	if(otexto.style.fontSize=="")
		otexto.style.fontSize=12;
	
	if(parseInt(otitulo.style.fontSize.substring(0,otitulo.style.fontSize.length-2))<=26)
		otitulo.style.fontSize=parseInt(otitulo.style.fontSize.substring(0,otitulo.style.fontSize.length-2))+2
	if(parseInt(otexto.style.fontSize.substring(0,otexto.style.fontSize.length-2))<=16)
		otexto.style.fontSize=parseInt(otexto.style.fontSize.substring(0,otexto.style.fontSize.length-2))+2
}

function DisminuirLetra(titulo, texto)
{
	var otitulo;
	var otexto;
	
	var elems = document.getElementsByTagName('a')
	for (i = 0; i < elems.length; i++) 
	{
		if(elems[i].id.indexOf(titulo)>=0)
			otitulo=elems[i];
	}
	
	elems = document.getElementsByTagName('div')
	for (i = 0; i < elems.length; i++) 
	{
		if(elems[i].id.indexOf(texto)>=0)
			otexto=elems[i];
	}
	
	if(otitulo.style.fontSize=="")
		otitulo.style.fontSize=22;
	if(otexto.style.fontSize=="")
		otexto.style.fontSize=12;
	
	if(parseInt(otitulo.style.fontSize.substring(0,otitulo.style.fontSize.length-2))>22)
		otitulo.style.fontSize=parseInt(otitulo.style.fontSize.substring(0,otitulo.style.fontSize.length-2))-2
	if(parseInt(otexto.style.fontSize.substring(0,otexto.style.fontSize.length-2))>12)	
		otexto.style.fontSize=parseInt(otexto.style.fontSize.substring(0,otexto.style.fontSize.length-2))-2
}


function EnviarClaves(idPais)
{
	var ok = true;

	if (document.getElementById("txtDestinatario").value=="")
	{
		alert(mensajes[5]);
		document.getElementById("txtDestinatario").focus();
		ok = false;	
	}
	
	if(!ValidarMail(document.getElementById("txtDestinatario").value))
	{
		alert(mensajes[5]);
		document.getElementById("txtDestinatario").focus();
		ok=false;
	}
	

	if(ok)
	{
		Navegar("./FrmOlvido.aspx",{intPaso: "E", idPais: idPais, EMail: document.getElementById("txtDestinatario").value});
	}
}