//<script language="javascript">
var tpi_thisYear = "2009";
var tpi_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>';
var idTieneElFoco = "";
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);
}

function pintaLateralMiArea() {
  if (getCookie('CN') == ""){
    document.write(tpi_strLateralMiArea);}
}

function clicklet(id,win)
{
  var sUrl = "/click.asp?PAOL"+id+";"+top.document.location;
  var sUrlParameters = "directories=yes,hotkeys=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes";
  if (win == true){
  	window.open(sUrl,"",sUrlParameters);}
  else {
  	window.parent.location = sUrl;}
}

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'];
	if (f.mode.value == "simple" || f.mode.value == "listaindir" || f.mode.value == "listadir") {
		if (f.activ.value == "" && f.nomb.value == "" && f.clno.value == "" ) {
			alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
    		}else {
		      f.nomb.value = f.nomb.value.replace('&' ,' ')	
		      f.nomb.value = f.nomb.value.replace('?' ,' ')	      
		      f.nomb.value = f.nomb.value.replace('¿' ,' ')	   
		      f.nomb.value = f.nomb.value.replace('!' ,' ')
		      f.nomb.value = f.nomb.value.replace('¡' ,' ')
		      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.clno.value = f.clno.value.replace('?' ,' ')	      
		      f.clno.value = f.clno.value.replace('¿' ,' ')	      
		      f.clno.value = f.clno.value.replace('!' ,' ')	 
		      f.clno.value = f.clno.value.replace('¡' ,' ')		      		      
		      f.submit();
		}
  	} else {
		if ( f.activ == "" && f.clno && f.clno.value == "" && f.nomb && f.nomb.value == "") {
      			alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
    		} else {
			if ( f.qact && f.qact.value == "" && f.nomb && f.nomb.value == "" && f.clno && f.clno.value == "") {
				alert("Debe seleccionar al menos una actividad o nombre de empresa para poder buscar");
			} else {
				f.submit();
			}
    		}
  	}
}

function buscar_restaurantes(f) 
{
	if (f.mode.value == "simple"){	
		if (f.nomb.value == "" && f.tico.options.selectedIndex == 0 && f.prec.options.selectedIndex == 0 && f.prov.options.selectedIndex == 0 && f.loca.value == ""){
			alert("Debe introducir algún criterio de búsqueda");
		}else{
			var b = f.elements;
			b["nomb"].value = b["nomb"].value.replace(/&/g,' ');
			b["nomb"].value = b["nomb"].value.replace(/\?/g,' ');
			b["nomb"].value = b["nomb"].value.replace(/'/g,'');
			f.submit();
		}
	}else if (f.mode.value == "boolean"){
		if (!seleccionConjuntoCheck("RSERV") && f.nomb.value == "" && f.tico.options.selectedIndex == 0 && f.prec.options.selectedIndex == 0 && f.prov.options.selectedIndex == 0 && 
				f.loca.value == "" && 
				f.ties.options.selectedIndex == 0 && 
				f.VMI.options.selectedIndex == 0 &&
				f.codpost.value == ""){
		    alert("Debe introducir algún criterio de búsqueda");
		}else{
			f.nomb.value = f.nomb.value.replace(/&/g,' ');
			f.nomb.value = f.nomb.value.replace(/\?/g,' ');
			f.nomb.value = f.nomb.value.replace(/'/g,'');
			f.submit();
		}	    
	} 
}

function buscar_guia( f ){
	/*if ( f.desde.options.selectedIndex == 0 && f.hasta.options.selectedIndex == 0 && (f.prov.options.selectedIndex == 0 || f.loca.options.selectedIndex == 0 )){
	    alert("Debe introducir algún criterio de búsqueda");
	}
	else{*/
		sGuia  = f.guia.value 		
		sDesde = f.desde.options[f.desde.options.selectedIndex].value;
		sHasta = f.hasta.options[f.hasta.options.selectedIndex].value;
		if (f.guia.value == "VMI" ){
			f.VMI.value = sDesde + "-" + sHasta
		}
		else if (f.guia.value == "VMO" ){
			f.VMO.value = sDesde + "-" + sHasta
		}
		else if (f.guia.value == "VCA" ){
			f.VCA.value = sDesde + "-" + sHasta
		}
		f.submit();
	//}	    
}

function buscar_hoteles (f){
	// NOTA:
	//		f.tial.options.selectedIndex == 0 es el índice de TODOS los tipos de alojamiento. Ver combo_tipos.js.
	//		Si viene relleno, hay que introducirle en su value el texto que marca.
	
	if (f.mode.value == "simple"){
		if (f.nomb.value == "" && 
				f.tial.options.selectedIndex == 0 && 
				f.catg.options.selectedIndex == 0 && 
				f.prov.options.selectedIndex == 0 && 
				f.loca.value == ""){
			alert("Debe introducir algún criterio de búsqueda");
		}
		else{
			var a = f.elements["tial"].options;
			var b = f.elements;
			b["nomb"].value = b["nomb"].value.replace(/&/g,' ');
			b["nomb"].value = b["nomb"].value.replace(/\?/g,' ');
			b["nomb"].value = b["nomb"].value.replace(/'/g,'');
			// Corregimos el código.
			/*if ( a.selectedIndex == 0 ){
				a[a.selectedIndex].value = "";
			}
			else{
				a[a.selectedIndex].value = a[a.selectedIndex].text;
			}*/
			f.submit();
		}
	}
	else if (f.mode.value == "boolean")
	{
		if (!seleccionConjuntoCheck("aserv") && 
				!seleccionConjuntoCheck("actividades") && 
				f.nomb.value == "" && 
				f.tial.options.selectedIndex == 0 && 
				f.catg.options.selectedIndex == 0 && 
				f.prov.options.selectedIndex == 0 && 
				f.loca.value == "" && 
				f.zona.options.selectedIndex == 0 && 
				f.situ.options.selectedIndex == 0 &&
				f.codpost.value == ""){
		    alert("Debe introducir algún criterio de búsqueda");
		}
		else{
			// Corregimos el valor del código.
			/*if ( f.tial.options.selectedIndex == 0 ){
				f.tial.options[f.tial.options.selectedIndex].value = "";
			}
			else{
				f.tial.options[f.tial.options.selectedIndex].value = f.tial.options[f.tial.options.selectedIndex].text;
			}*/
			
			f.nomb.value = f.nomb.value.replace(/&/g,' ');
			f.nomb.value = f.nomb.value.replace(/\?/g,' ');
			f.nomb.value = f.nomb.value.replace(/'/g,'');
			f.submit();
		}		    
	}
}


//if (document.all) {
//   document.onkeydown = msKeyDown;
//} else {
//   window.captureEvents(Event.KEYDOWN);
//   window.onkeydown = nsKeyDown;
//}


//firefox
function nsKeyDown(e) { if (e.which == 13) 	 { enterPress(); } }
//iexplorer
function msKeyDown()  { if (window.event.keyCode == 13) {  enterPress(); } }

document.onkeydown = keyDownPrueba;
if (document.layers)
{
			document.captureEvents(Event.KEYDOWN);
}
	
	
	function keyDownPrueba(DnEvents) {
		if (document.all){
		 k=window.event.keyCode;	
		}
		else{
			k = DnEvents.which;
		} 	
		if (k==13)
		{			
			enterPress();		
		}
	}





function enterPress()
{
  var loc = document.location.pathname;
  var focusOwner = idTieneElFoco;
  switch (focusOwner)
  {
	  case 'frmerror': //form superior amarillas simple					
					fnBusq();					
					break;
		case 'frmerrorExp': //form superior amarillas simple iexplorer
					if (document.all)
					{
						fnBusq();	
						return false;
					}
					break;
	  case 'frmerrorHot':  //form superior hoteles simple
					fnBusq(siteHot);
					return false;
					break;
		case 'frmerrorHotExp':  //form superior hoteles simple explorer
					if (document.all)
					{
						fnBusq(siteHot);
						return false;
					}
					break;					
	  case 'frmerrorInferior': //form inferior amarillas simple
					fnBusqInferior();
					break;
		case  'frmerrorInferiorExp': //form inferior amarillas simple ieplorer
					if (document.all)
					{
						fnBusqInferior();
					}
					break;
	  case 'frmerrorInferiorHot': //form inferior hoteles simple
					fnBusqInferior(siteHot); 
					return false;
					break;
		case 'frmerrorInferiorHotExp': //form inferior hoteles simple explorer
					if (document.all)
					{
						fnBusqInferior(siteHot); 
						return false;
					}
					break;
	  case 'REFINAR_HotExp': //form filtrar por localidad para hoteles simple
					if (document.all)
					{
						refinarLoc(document.getElementById('REFINAR').loca2.value,'ref_loc',moRequestSite);						
						return false;
					}
					break;
		 case 'REFINAR_ResExp': //form filtrar por localidad para restaurantes simple
					if (document.all)
					{
						refinarLoc(document.getElementById('REFINAR').loca2.value,'ref_loc',moRequestSite);						
						return false;
					}
					break;
					
	  case 'REFINARAmarillas':  //form filtrar por localidad para amarillas simple
					refinarLoc(document.getElementById('REFINAR').loca2.value, 'ref_loc');
					return false;
					break;
	  case 'busq4': //home amarillas simple					
					submitar();
					return false;		
					break;
	  case 'busq4Exp': //home amarillas simple explorer
					if (document.all)
					{						
						submitar();
						return false;					
					}																																												
					break;
	  case 'busq4ErrorAmarillas': //form error para amarillas simple
					fnSubmitar(document.busq4);
					break;
		case 'busq4ErrorAmarillasExp': //form error para amarillas simple explorer
					if (document.all)
					{
						fnSubmitar(document.busq4);
					}
					break;					
						  
	  case 'busq4ErrorHot': //form error para hoteles simple
					fnSubmitarHot(document.busq4);
					return false;
					break;
		case 'busq4ErrorHotExp': //form error para hoteles simple ie
					if (document.all)
					{
						fnSubmitarHot(document.busq4);
						return false;
					}
					break;
	  case 'busq4ErrorRes': //form error para restaurantes simple
					fnSubmitarRest(document.busq4);
					return false;
					break;
		 case 'busq4ErrorResExp': //form error para restaurantes simple
					if (document.all)
					{
						fnSubmitarRest(document.busq4);
						return false;
					}
					break;
	  case 'frmerrorRes': //form superior restaurantes
					fnBusq(siteRes);
					return false;
					break;
		case 'frmerrorResExp': //form superior restaurantes explorer
					if (document.all)
					{
						fnBusq(siteRes);
						return false;
					}
					break;								
	  case 'frmerrorInferiorRes': //form inferior restaurantes
					fnBusqInferior(siteRes);
					break;
		 case 'frmerrorInferiorResExp': //form inferior restaurantes explorer
					if (document.all)
					{
						fnBusqInferior(siteRes);
					}
					break;					
	  case 'frmerrorAvzada':  //form buscador superior amarillas avanzada
					fnCambiarmode(document.frmerror);
					return false;	  
					break;
		 case 'frmerrorAvzadaExp':  //form buscador superior amarillas avanzada
					if (document.all)
					{					
						fnCambiarmode(document.frmerror);
						return false;
					}	  
					break;					
	  case 'busq4ErrorAvzada':  //form error para amarillas avanzada
	  				fnCambiarmode(document.busqavan);
					return false;
					break;	
		case 'busq4ErrorAvzadaExp':  //form error para amarillas avanzada
					if (document.all)
					{
	  				fnCambiarmode(document.busqavan);
						return false;
					}
					break;			
					  
	  case 'xProxErrorProxHot': //form error proximidad hoteles
					fnCambiarmode(document.xProx, siteHot);
					return false;
					break;
		 case 'xProxErrorProxHotExp': //form error proximidad hoteles explorer
					if (document.all)
					{
						fnCambiarmode(document.xProx, siteHot);
						return false;
					}
					break;			
		case 'frmerrorAvzadaHot': //form superior error avanzada hoteles
					fnCambiarmode(document.frmerror, siteHot);
					return false;
					break;		
		case 'frmerrorAvzadaHotExp': //form superior error avanzada hoteles
					if (document.all)
					{
						fnCambiarmode(document.frmerror, siteHot);
						return false;
					}
					break;	
	  case 'busqavanErrorHot':  //form error hoteles avanzada
					fnCambiarmode(document.busqavan, siteHot);
					break;
		case 'busqavanErrorHotExp':  //form error hoteles avanzada
					if (document.all)
					{
						fnCambiarmode(document.busqavan, siteHot);										  
					}
					break;		
	  case 'xProxBusqErrorRest': //formulario superior error proximidad restaurantes					
					fnCambiarmode(document.xProxBusc, siteRes);
					return false;
					break;
		case 'xProxBusqErrorRestExp': //formulario superior error proximidad restaurantes explorer					
					if (document.all)
					{						
						fnCambiarmode(document.xProxBusc, siteRes);
						return false;
					}
					break;
	  case 'xProxBusqErrorHot': //formulario superior error busqueda proximidad hoteles
						fnCambiarmode(document.xProxBusc, siteHot);
						return false;					
						break;
		case 'xProxBusqErrorHotExp': //formulario superior error busqueda proximidad hoteles explorer					
					if (document.all)
					{					
						fnCambiarmode(document.xProxBusc, siteHot);
						return false;
					}
					break;
	  case 'busqAvanErrorAvzadaRes': //form error avanzada restaurantes
					fnCambiarmode(document.busqavan, siteRes);
					return false;
					break;
		 case 'busqAvanErrorAvzadaResExp': //form error avanzada restaurantes
					if (document.all)
					{
						fnCambiarmode(document.busqavan, siteRes);
						return false;
					}
					break;
	  case 'frmerrorAvzadaRes': // form superior error busqueda avanzada en restaurantes
					fnCambiarmode(document.frmerror,siteRes);
					return false;
					break;	
		case 'frmerrorAvzadaResExp': // form superior error busqueda avanzada en restaurantes
					if (document.all)
					{
						fnCambiarmode(document.frmerror,siteRes);
						return false;
					}	
					break;				
					  
	  case 'busqavan': //home avanzada amarillas firefox y explorer
					submitar();
					return false;
					break;
	  case 'busqAvanExp': //home avanzada amarillas explorer
					if (document.all)
					{																												
						submitar();
						return false;
					}
					break;
	  case 'busq4hot': //form home hoteles para firefox y explorer
					submitar();
					return false;
					break;
	  case 'busq4hotExp': //form home hoteles para explorer
					if (document.all)
					{
						submitar();
						return false;
					}
					break;
	  case 'xProxHotExp': //form home hoteles proximidad explorer
					if (document.all)
					{
						submitar();
						return false;
					}
					break;
	  case 'xProxHot': //form home hoteles proximidad explorer y firefox					
					submitar();
					return false;					
					break;
	  case 'xProxRes' : //form home restaurantes proximidad firefox y explorer					
					submitar();
					return false;
					break;
	  case 'xProxResExp': //form home restaurantes proximidad explorer
					if (document.all)
					{
						submitar();
						return false;
					}
					break;
	  case 'busq4Res': //form home restaurantes firefox y explorer	  
					submitar();
					return false;																	
					break;
	  case 'busq4ResExp': //form home restaurantes explorer
					if (document.all)
					{
						submitar();
						return false;																																	
					}																		
					break;
	  case 'busqAvanRes': //form home avanzada restaurantes firefox y explorer	  
					submitar();
					return false;	
					break;
	  case 'busqAvanResExp': //form home avanzada restaurantes explorer 	  
					if (document.all)
					{
						submitar();
						return false;
					}																				
					break;
	  case 'xProxVueltaErrorExp': //form vuelta error proximidad explorer																			
					if (document.all)
					{
						submitar();
						return false;
					}																					
					break;
	  case 'xProxVueltaError': //form vuelta error proximidad explorer y firefox
					submitar();
					return false;													
					break;
	  case 'xProxCallVueltaCalle': //form vuelta error callejero explorer y firefox
					cambiarDireccion();
					return false;													
					break;
	  case 'xProxCallVueltaCalleExp': //form vuelta error callejero explorer
					if (document.all)
					{																																									
						cambiarDireccion();
						return false;
					}
					break;
	  case 'busqAvanHotExp': //form home avanzada hoteles explorer 								
					if (document.all)
					{
						submitar();
						return false;
					}																								
					break;
	  case 'busqAvanHot': //form home avanzada hoteles explorer y firefox																										
					submitar();
					return false;
					break;
	  case 'xProxBusc': //form superior error proximidad  												
					fnCambiarmode(document.xProxBusc);
					return false;																											
					break;
		 case 'xProxBuscExp': //form superior error proximidad  
					if (document.all)
					{												
						fnCambiarmode(document.xProxBusc);
						return false;																											
					}
					break;							
	  case 'xProx': //home proximidad																		
					submitar();
					return false;																												
					break;
		case 'xProxExp': //home proximidad amarillas explorer
					if (document.all)
					{
						submitar();																									
						return false;
					}	
					break;
		case 'busq4ErrorProx': //form error para amarillas proximidad
					fnCambiarmode(document.xProx);
					return false;
					break;
	  case 'busq4ErrorProxExp': //form error proximidad amarillas explorer													
					if (document.all)
					{										
						fnCambiarmode(document.xProx);
						return false;
					}																													
					break;
		case 'xProxErrorProxRes': //formulario central error proximidad restaurantes
					fnCambiarmode(document.xProx,siteRes);
					return false;
					break;
	  case 'xProxErrorProxResExp': //formulario central error proximidad restaurantes explorer					
					if (document.all)
					{
						fnCambiarmode(document.xProx,siteRes);
						return false;
					}																														 	
					break; 
		case 'proximidadExp':  //formulario buscar proximos a desde la pagina de resultados para explorer
					if (document.all)
					{						
						submitar();
						return false;
					}
					break;
		case 'proximidad': //formulario buscar proximos a desde la pagina de resultados
					submitar();
					return false;
					break;
		case 'frmErrorLoca': //formulario error localidad
					submitar(document.busq4);
					break;
		case 'frmErrorLocaExp': //formulario error localidad iexplorer
					if (document.all)
					{
						submitar(document.busq4);
					}
					break;
		//default: enterBlocked(); break;
  }
}

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);
	}
}
//manejador antiguo del enter
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;
	}
}

// Función que devuelve true si se ha seleccionado algún check de un conjunto de
// checks con el mismo nombre.

function seleccionConjuntoCheck(nombreConjunto){
	var seleccionado = false;

	// Buscamos el array con los checks pertenecientes al conjunto.	
	var arr = document.getElementsByName(nombreConjunto);
	for (i=0; i<arr.length; i++){
		if (arr[i].checked){
			seleccionado = true;
			break;
		}
	}
	return seleccionado;
}

// Función que selecciona un campo cuyo identificador es el parámetro id.
function setSelectedId(id){
 	if (id != ""){
 		var obj = document.getElementById(id);
 		if (obj != null){
 			obj.selected = true;
 		}
	}
}

// +----------------------------------------------------------------------------+
// | Cookies																																		|
// +----------------------------------------------------------------------------+

// Objetos que simulan arrays asociativos
var oFormPaol = { "nomb":null, "activ":null, "loca":null, "prov":null, "tv":null, "call":null};
var oFormRest = { "nomb":null, "tico":null,  "loca":null, "prov":null, "prec":null};
var oFormHot  = { "nomb":null, "tial":null,  "loca":null, "prov":null, "catg":null};

/*var oFormPaol = { "nomb":null, "activ":null, "prov":null, "loca":null, "tv":null, "call":null};
var oFormRest = { "nomb":null, "tico":null,  "prov":null, "loca":null, "prec":null};
var oFormHot  = { "nomb":null, "tial":null,  "prov":null, "loca":null, "catg":null};*/

// Funcion para escribir las cookies de los datos que se introducen en las homes de amarillas
// Crea una cookie con los valores de busqueda de resultados y 
// llama a su click

function fn_PreClicklet(tclick,tboolean,homeType,formulario){
	var oForm = formulario;	
	var sNameCookie;
	var values = "";
	var valor;
	var oValues;
	var i;
	// Controlamos el tipo de home
	if 	(homeType == "paol")			{oValues = oFormPaol; sNameCookie = "preclicklet";} 
	else if (homeType == "res")		{oValues = oFormRest; sNameCookie = "preclickletrest";} 
	else if (homeType == "hotel")	{oValues = oFormHot;  sNameCookie = "preclicklethot";} 
	
	// Leemos los datos del formulario
	i=0;
	for( sParam in oValues ) {
		try {			
			//if (sParam != "" && sParam !="Selecciona primero provincia"){
			if (sParam != ""){
				valor = oForm[sParam].value;
			}	
			else {
				valor="";
			}
			
			if (i == 0){
				values = values + valor
			}
			else {
				values = values + "¬" + valor
			}		
		} 
		catch(e) {}
		i++;
	}

	// Grabamos la cookie
	if( sNameCookie != "" &&  values != ""){
		setCookie (sNameCookie, values);
	} 
	
	// Realizamos el click
	clicklet(tclick,tboolean);
}

function Getcookieprov()
{
	var valcookieprov = getCookie('cookieprov');
  if (valcookieprov && valcookieprov.length > 0 )
  {	
  	valcookieprov = unescape(valcookieprov).replace(/\+/ig , ' ');
  	/*alert( "valcookieprov: >" + valcookieprov + "<\n" +
	  	"document.forms[0].name:" + document.forms[0].name + "\n" +
	  	"document.forms[0].[\"prov\"]: " + document.forms[0].prov + "\n" +
	  	"document.forms[0].[\"prov\"].value: " + document.forms[0].prov.value + "\n" 
  	);*/
		document.forms[0]["prov"].value = valcookieprov;
  	/*alert( "valcookieprov: >" + valcookieprov + "<\n" +
	  	"document.forms[0].name:" + document.forms[0].name + "\n" +
	  	"document.forms[0].[\"prov\"]: " + document.forms[0].prov + "\n" +
	  	"document.forms[0].[\"prov\"].value: " + document.forms[0].prov.value + "\n" 
  	);*/
  }
}

function fn_loadValues(oValues, formulario/*,prox*/)
{	
	var oForm = formulario;			
	// Recogemos el parametro opcion prox
	var sProx = arguments[2];	
	 // Valores que debemos actualizar si viene prox
	var aProxUpdateValues	= new Array("prov","loca","tv","call"); 
	// Boolean que indica si debemos escribir los datos de oValues en el formulario
	var bUpdateValue = true;	
	//si hay valores que cargar
	if( oValues )
	{
		//alert("en loadvalues recibo la actividad: " + oValues["activ"] );
		i=0;
 		for( sParam in oValues )
		{
			try {	
					// Si viene sProx es que viene del RadioButton de Proximidad, por lo que miramos los 
					// campos que tenemos que actualizar, el resto los dejamos como estan
					if ( typeof(sProx) != "undefined")
					{							
						for(var ind=0; ind < aProxUpdateValues.length; ind++)
						{
							bUpdateValue = (oForm[sParam].name == aProxUpdateValues[ind])
							if (bUpdateValue) { break;}
						}	
					}			
					if (bUpdateValue)
					{		
						//alert("hay que actualizar el campo = '" + sParam + "' con el valor = '" + oValues[sParam]);
						// Cargamos el valor en el campo del formulario
						//alert(oValues[sParam]);
						if ( oValues[sParam]  != null)
						{
							oForm[sParam].value = oValues[sParam];	
							//alert("cargo en el campo del formulario = '" +  oForm[sParam].name + "' el valor = '" + oValues[sParam] +"'");
						}
						if (oForm[sParam].name == "prov" && typeof(sProx) != "undefined")
						{							
							oForm["prov"].onchange();
						}						
					}
				} 
			catch(e)
			{
			}
			i++;
		}	
	}	
	
}  
// +----------------------------------------------------------------------------+
// | Funcion para introducir en los formularios los valores de la cookie y para	|
// | introducir los valores en el array asociativo															|
// | El parametro homeType indica que array de objetos tenemos que cargar, que  |
// | indica que campos debemos actualizar y que de que coohie tenemos que leer  |
// | los valores																																|
// | El parametro formulario indica el nombre del formukario donde debemos 			|
// | escribir los datos																													|
// | Si lleva el parámetro prox indica que viene del check de "Otra direccion"  |
// | que esta en las homes de proximidad y que hace que se carge la informacion	|
// | de la direccion que esta en la cookie de preclicklet, por ello solo 				|
// | actualizamos los datos de la direccion que son los que estan inicados en 	|
// | el array aProxUpdateValues  																								|
// | La variable booleana bUpdateValue indica si se deben actualizar los valores|
// | de la cookie en el formulario, por defecto esta a true para que cambie			|
// | todos los campos, pero cuando viene prox indica que campos se deben cambiar|
// | y cuales debe dejar como estan. En las homes de verticales no funciona bien|
// | porque de la direccion solo se guardan la localidad y la provincia					| 
// +----------------------------------------------------------------------------+

function fn_UsarPreClicklet(homeType,formulario/*,prox*/){
	var oResult = null;
	var valoresPreclick;
	var oForm = formulario;	
	var sNameCookie;
	var oValues;
	// ----------------------------
	var sProx = arguments[2];	// Recogemos el parametro opcion prox
	var aProxUpdateValues	= new Array("prov","loca","tv","call");  // Valores que debemos actualizar si viene prox
	var bUpdateValue = true;	// Boleana que indica si debemos escribir los datos de la cookie el el formulario
	// ----------------------------

	// Controlamos el tipo de home
	if (homeType == "paol"){
		oValues = oFormPaol;
		sNameCookie = "preclicklet";
	} 
	else if (homeType == "res"){
		oValues = oFormRest;
		sNameCookie = "preclickletrest";
	} 
	else if (homeType == "hotel"){
		oValues = oFormHot;
		sNameCookie = "preclicklethot";
	} 	
	
	// Cargamos los valores de la cookie
	valoresPreclick = getCookie(sNameCookie);

	if( valoresPreclick )
	{
		if ( valoresPreclick.length > 0 ) {
			valoresPreclick = unescape(valoresPreclick).replace(/\+/ig , ' ');
		}		

  	a_valoresPreclick = valoresPreclick.split("¬");
 		i=0;

 		for( sParam in oValues ) {
			try {				
			
					var valorcookie = "";
				
					if ( typeof( a_valoresPreclick[i] ) != "undefined") {
						valorcookie = a_valoresPreclick[i];						
					}
					
					// Si viene sProx es que viene del RadioButton de Proximidad, por lo que miramos los 
					// campos que tenemos que actualizar, el resto los dejamos como estan
					if ( typeof(sProx) != "undefined"){							
						for(var ind=0; ind < aProxUpdateValues.length; ind++){
							bUpdateValue = (oForm[sParam].name == aProxUpdateValues[ind])
							if (bUpdateValue) { break;}
						}	
					}	
								
					if (bUpdateValue){						
						//oValues[sParam] 		= valorcookie;	// Cargamos el valor en el array asociativo
						oForm[sParam].value = valorcookie;	// Cargamos el valor en el campo del formulario
							
						if (oForm[sParam].name == "prov" && typeof(sProx) != "undefined"){
							oForm["prov"].onchange();
						}						
					}
				} 
			catch(e) {}
			i++;
		}	
	}	
	
	// Si tiene cookie devolvemos los valores de la cookie, 
	// si no tiene devolvemos valores igualados a nulo tal y como están
	// inicializados
	
	 //oResult = oValues;	
	return oValues;
	//return oResult;
}                                         

function fn_Crear_oValuesPreClicklet(homeType,formulario){
	var oResult = null;
	var valoresPreclick;
	var oForm = formulario;	
	var sNameCookie;
	var oValues = null;
	
	// Controlamos el tipo de home
	if (homeType == "paol"){
		oValues = oFormPaol;
		sNameCookie = "preclicklet";
	} 
	else if (homeType == "res"){
		oValues = oFormRest;
		sNameCookie = "preclickletrest";
	} 
	else if (homeType == "hotel"){
		oValues = oFormHot;
		sNameCookie = "preclicklethot";
	} 
	
	// Cargamos los valores de la cookie
	valoresPreclick = getCookie(sNameCookie);
			
	if( valoresPreclick )
	{ 	
		//if (sNameCookie == "preclicklet") {alert("esta preclicket");}
		if (valoresPreclick && valoresPreclick.length > 0 ){		
			valoresPreclick = unescape(valoresPreclick).replace(/\+/ig , ' ');			
		}

  	a_valoresPreclick = valoresPreclick.split("¬");
	
 		i=0;

 		for( sParam in oValues ) {
			try {				
					if ( typeof( a_valoresPreclick[i] ) != "undefined") {
						oValues[sParam] = a_valoresPreclick[i];
						//alert (sParam + " -> " + oValues[sParam]);
					}
					
				} 
			catch(e) {}
			i++;
		}	
	} else {
		//Si no tiene valor en la provincia lo recupera de cookie de provincia
		//Solo lo hace para restaurantes y para amarillas
		if (oValues["prov"] == null && homeType != "hotel" ){
			//alert (" Cookie: " + getCookie('cookieprov'));
			oValues["prov"] = getCookie('cookieprov');
			if( oValues["prov"] != null ) {
				oValues["prov"] = oValues["prov"].replace( "+", " " );
			}
			//alert (" Prov (-) -> " + oValues["prov"]);
		}
	}	
	
	// Si tiene cookie devolvemos los valores de la cookie, 
	// si no tiene devolvemos valores igualados a nulo tal y como están
	// inicializados
	
return oValues;
}                                                                                                                                                           
//</script>