var thisYear = "2005";
var parar = false;
function tdr(obj,clr) {
  obj.style.cursor = 'hand';
  obj.style.backgroundColor = clr;
}
function pintaIconoMiArea() {
  if (getCookie('CN') == "") {
    strHTML = '<a href="javascript:clicklet(\'1006\',false)"><img src="../images/miarea.gif" border="0"></a>';
  } else {
    strHTML = '<a href="javascript:clicklet(\'1007\',false)"><img src="../images/logado.gif" border="0"></a><a href="javascript:clicklet(\'1008\',false)"><img src="../images/cerrarsesion.gif" border="0"></a><img src="../images/spacer.gif" height="7" width="7">';
  }
  document.write(strHTML);
}
var strLateralMiArea = '<a class="menu" href="javascript:clicklet(\'1052\',false)" target="_self"><img src="../images/registro.gif" width="140" height="14" border="0" alt=""></a><br>';
function pintaLateralMiArea() {
  if (getCookie('CN') == "")
    document.write(strLateralMiArea);
}
function clicklet(id,win)
{
  var URL = "/click.asp?PAOL"+id+";"+top.document.location;

  if (win == true)
  {
    window.open(URL,"","directories=yes,hotkeys=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
  }
  else
  {
    //window.parent.FMAIN.location = URL;
    window.parent.location = URL;
  }
}
function redSites(cmb) {
  var URL = cmb[cmb.selectedIndex].value;
  if (URL != "") {
    window.open (URL,"");
    cmb.selectedIndex = 0;
  }
}

function buscar( f ) {
  //var f = document.forms['buscador'];
	//alert('voy a buscar');
	
	if (f == null)
	{
		var f = document.forms['formAvzada'];		
		//alert('paso por aqui');
		if (f == null)
		{
			//alert('form simple');
			f = document.forms['formSimple'];
		}
		/*else
		{
			if (f.nume.value == "" && f.call.value != "")
			{
				f.nume.value = "1";
			}
		}*/
	}
	/*	else
		{
			if (validarExplorer(form))
			{*/
	if (f != null)		
	{
			if (f.mode.value == "simple")
			{
				//alert('mode simple');
				if (f.activ.value == "" && f.nomb.value == "" )
				{
					alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
					return false;
				}
				else
				{		
				//filtrado temporal de ë y Ë.
				f.activ.value = f.activ.value.replace(/Ë/g ,'E');
				f.activ.value = f.activ.value.replace(/ë/g ,'e');		
				f.nomb.value = f.nomb.value.replace(/Ë/g ,'E')
				f.nomb.value = f.nomb.value.replace(/ë/g ,'e')
				f.nomb.value = f.nomb.value.replace('&' ,' ')	
				f.nomb.value = f.nomb.value.replace('?' ,' ')	      
				//f.clno.value = f.clno.value.replace('?' ,' ')	  		
				f.submit();	
				//return false;
				}
			}
			else
			{
				if (f.activ == "" && f.nomb.value == "")
				{
					alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
				} 
				else
				{	
					if (f.qact.value == ""  && f.nomb.value == "" )
					{
						alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
					}
					else 
					{	  
						f.submit();
						//return false;
					}
				}
			}
			//}
		//}
	}
	
}

if (document.all) {
   document.onkeydown = msKeyDown;
} else {
   window.captureEvents(Event.KEYDOWN);
   window.onkeydown = nsKeyDown;
}

function nsKeyDown(e) { if (e.which == 13) 	 { enterPress(); } }
function msKeyDown()  { if (event.keyCode == 13) { enterPress(); } }

function enterPress() {
  //var loc = document.location.pathname;
  //if (loc == "home_ie.html" || loc == "home_ns.html" || loc == "home_avanzada.html") {
	//alert('loc = ' + loc);
	//alert('foco = ' + foco);
	//miro si no viene de contacto ni de alta
	//alert(loc.search("/contacto.asp"));
	
	//if (loc !="/contacto.asp" && loc != "/alta.asp")
	/*if (document.forms['formAvzada'] != null || document.forms['formSimple'] != null)	
	{		
		buscar();		
		return false;
	}*/
	/*else
	{
		if (loc =="/contacto.asp")
		{
			if (document.all)	alert('ie'); chkSendMail();
		}
	}*/
}
function getCookie(Name) {
  var end;
  var search;
  search = Name + "=";

  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
    } else {
      return "";
    }
  } else {
    return "";
  }
}
function setCookie (name, value, expire) {
  document.cookie = name + "=" + escape(value) + ";path=/" +((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}
function navegaCat(cat) {
  top.document.location = "/categoria.asp?no_categoria="+escape(cat);
}
function listarCategoria(bus,txt) {
  var f = document.forms["f"];
  top.document.location = "/functions/pre_search.asp?mode=simple&activ="+escape(bus)+"%23"+escape(txt)+"&no_activ="+escape(txt)+"&prov="+escape(f.prov[f.prov.selectedIndex].value)+"&loca="+escape(f.loca.value)+"&codpost="+escape(f.codpost.value);
}
function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function agregarAgenda(docn) {
  var u = "/functions/agregar_agenda.asp?docn="+ docn;
  window.open(u,"agregarAgenda","width=700,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}
function popupRuta(tipo,docn) {
  var u = "/functions/pop_rutas.asp?tipo="+tipo+"&docn="+ docn;
  window.open(u,"popupRutas","width=380,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}
function mmail() {
  var cn = getCookie("cn");
  var mm = getCookie("MultiEMail");
  if (mm == "") {
    alert("Seleccione al menos uno de los anunciantes a los que desea enviar un mensaje")
  } else {
    setCookie('mmQS',mmQS)
    if (cn == "") {
      window.open("/registro/login.asp?final=multimail","popupLogin","width=400,height=350");
    } else {
      top.location = "/multimail.asp";
    }
  }
}
function clk(i) {
  var sDestinatarios;
  var aDestinatarios;
  var chkbox;
    
  eval ("chkbox=document.lista.email" + String(i));
    
  // Leer la lista de destinatarios desde la cookie en el Array aDestinatarios
  sDestinatarios=getCookie("MultiEMail");
    
  if (sDestinatarios!="")
    {
    aDestinatarios=sDestinatarios.split("`");
  
    if (chkbox.checked)
      sDestinatarios += "`" + chkbox.value
    else
      for (sDestinatarios = "", i=0; i<aDestinatarios.length; i++)
        if (aDestinatarios[i]!=chkbox.value)
          sDestinatarios += (sDestinatarios.length ? "`" : "") + aDestinatarios[i];
      
    setCookie("MultiEMail", sDestinatarios,null);
    }
  else if (chkbox.checked)
    setCookie("MultiEMail", chkbox.value,null);

  return true;
}

function enviarMultimail(){setCookie("mmQS",mmQS);top.document.location = "multimail.asp";}
function mOvr(src,clrOver){if(!src.contains(event.fromElement)){src.bgColor = clrOver;}}
function mOut(src,clrIn){if(!src.contains(event.toElement)){src.bgColor = clrIn;}}

function enterSubmit() {
	document.onkeydown = keyDown;
	if (document.layers) {
	document.captureEvents(Event.KEYDOWN);
	}
}
function keyDown(DnEvents) {
	if (document.all)
	{
	 k=window.event.keyCode;	
	}
	else{
	k = DnEvents.which;
	} 	
	if (k==13) {
		if (typeof defaultForm != "undefined") {
			submitar(defaultForm);
		} else { 
	  	submitar(); 	
	  }
	}
}

function enterBlocked() {
	document.onkeydown = keyDown2;
	if (document.layers) {
	document.captureEvents(Event.KEYDOWN);
	}
}
function keyDown2(DnEvents) {
	if (document.all)
	{
	 k=window.event.keyCode;	
	}
	else{
	k = DnEvents.which;
	} 	
	if (k==13) {
		return false;
	}
}
