
function isEmpty(str)
{
    if(str=="undefined" || str==null || !str) return true;
    return false;
}

function getRefToDivNest( divID, oDoc )
{
     if( !oDoc ) { oDoc = document; }
     if( document.layers )
     {
     	if( oDoc.layers[divID] ) { return oDoc.layers[divID]; }
     	else
     	{
     		for( var x = 0, y; !y && x < oDoc.layers.length; x++ )
     		{
     			y = getRefToDivNest(divID,oDoc.layers[x].document);
     		}
     		return y;
     	}
     }
     if( document.getElementById ) { return document.getElementById(divID); }
     if( document.all ) { return document.all[divID]; }
     return document[divID];
}

function showdiv(thisdiv) {
     cdiv = getRefToDivNest(thisdiv);
     if(!cdiv) { return; }
     if(cdiv.style) { cdiv.style.visibility = 'visible'; cdiv.style.display = 'inline'; }
     else
     {
        if( cdiv.visibility ) { cdiv.visibility = 'show'; cdiv.style.display = 'inline'; }
        else { return; }
     }
}

function hidediv(thisdiv)
{
 	cdiv = getRefToDivNest(thisdiv);
    if( cdiv.style ) { cdiv.style.visibility = 'hidden'; cdiv.style.display = 'none'; }
 	else { cdiv.visibility = 'hide'; cdiv.display = 'none'; }
}

function updateId(elem)
{
    id=elem.getAttribute('id').split('_');
    $('id_destino').value=id[1];
    $('destino').value=elem.innerHTML;
}

function showDestinosMenu(titulo, e)
{
   if(isObject(panel_destinos)) destruirObjeto(panel_destinos);
   
   posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
   posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;

   panel_destinos = new YAHOO.widget.Panel("panel_destinos",
   {
       width:'500px',//300px
       height:'305px',
       underlay:"none",
       close:true,
       draggable:true,
       fixedcenter:true,
       constraintoviewport: true,
       zIndex:1000
   }
   );
   var url_base = document.buscador.url_base.value;
   load_url = url_base + 'index.php?pg=do_ajax&pg_action=destinos_con_marca_home_buscador&tipo='+titulo,
   YAHOO.util.Connect.asyncRequest("get",load_url, {
         timeout: 10000,
         success: function(o) {
         	//#29836         	
            titulo = "<table width='100%'><tr><td width='45%'>destinos nacionales</td><td width='55%'>destinos internacionales</td></tr>";
            panel_destinos.setHeader(titulo.toUpperCase());
            panel_destinos.setBody(o.responseText);
            panel_destinos.render(document.body);
         },
         failure: function() {
            return false;
         }
       });
}

function showCategoriasMenu(titulo, e)
{
   if(isObject(panel_destinos)) destruirObjeto(panel_destinos);
   
   posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
   posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;

   panel_destinos = new YAHOO.widget.Panel("panel_destinos",
   {
              width:'300px',
              height:'305px',
              underlay:"none",
              close:true,
              draggable:true,
              x:posx,
              y:posy,
              constraintoviewport: true,
              zIndex:1000
   }
   );
   var url_base = document.buscador.url_base.value;
   load_url = url_base + 'index.php?pg=do_ajax&pg_action=categorias&tipo='+titulo,
   YAHOO.util.Connect.asyncRequest("get",load_url, {
         timeout: 10000,
         success: function(o) {
            panel_destinos.setHeader(titulo.toUpperCase());
            panel_destinos.setBody(o.responseText);
            panel_destinos.render(document.body);
         },
         failure: function() {
            return false;
         }
       });
}

/*
function showCategoriasMenu(titulo, do_submit)
{
    $('popup1_title').innerHTML=titulo;

    $('popup1_lista').innerHTML="<li>Cargando ...<"+"/li>";

    var url_base = document.buscador.url_base.value;

    new Ajax.Request(url_base + 'index.php', {
        method:'get',
        parameters:'pg=do_ajax&pg_action=categorias&tipo='+titulo,
        onSuccess: function (response)
        {
            $('popup1_lista').innerHTML=response.responseText;
        }
    });
    $('popup1').style.display='block';
    $('popup2').style.display='block';
}
*/
function showMostrarSala(divObj)
{
	if(divObj.style.visibility=='visible')
		divObj.style.visibility='hidden';
	else
		divObj.style.visibility='visible';
	
}

//--- nuevo menu cabecero v3 (nov-08)
//en esta version ya no se utiliza el urlHeader() sino que hay una version mas simplificada
//ya no se utiliza el niftycorners para los tabs. todo por css
//menu cabecero 3
var Menu3 = function() {
	this.estiloHover = 	'hover';
	this.idIframe =		'mnu_iframe';
	this.marcado = 		'';
	this.overlayOn =	false;

	this.marcar = function(pes) {
		var YUD = YAHOO.util.Dom;
		var pest = "mnu_" + pes;
		if(!YUD.hasClass(pest,this.estiloHover))
		{
			YUD.addClass(pest,this.estiloHover);
			this.marcado = pest;
		}
	},
	// cuando se navega en el menu desplegable, mantener la pestana negra
	this.ov = function(mnu, accion) {
		var YUD = YAHOO.util.Dom;
		var estiloHover = this.estiloHover;
		if(mnu != this.marcado)
		{
			if(accion == 'ov') {
				if(!YUD.hasClass(mnu,estiloHover)) YUD.addClass(mnu,estiloHover);
				if(this.overlayOn) this.overlayFix(mnu);
			}
			if(accion == '') {
				if(YUD.hasClass(mnu,estiloHover)) YUD.removeClass(mnu,estiloHover);
				if(this.overlayOn) this.overlayFixOut();
			}
		}
	},
	this.overlayFix = function(mnu) {
		$(this.idIframe).style.display = 'block';

		var YUD = YAHOO.util.Dom;
		var smnu = "s" + mnu;
		var x  = YUD.getX(mnu) + 1;
		var y  = YUD.getY(mnu) + 25;
		var width = $(smnu).clientWidth - 12;
		var height = $(smnu).clientHeight - 10;

		if(YUD.getX(this.idIframe) != x)
		{
			YUD.setX(this.idIframe,x);
			YUD.setY(this.idIframe,y);
			$(this.idIframe).width = width;
			$(this.idIframe).height = height;
			this.overlayFixCasoEspecial(mnu);
		}
	},
	this.overlayFixCasoEspecial = function(mnu) {
		var x = '';
		var YUD = YAHOO.util.Dom;
		switch(mnu)
		{
			case 'mnu_coc': x = YUD.getX(mnu) - 110; break;
			case 'mnu_extra': x = YUD.getX(mnu) - 87; break;
		}
		if(x != "")
		{
			YUD.setX(this.idIframe,x);
		}
	},
	this.overlayFixInit = function(pestanas) {
		var YUE = YAHOO.util.Event;
		var vPest = new Array();

		vPest = pestanas.split(",");
		var othis = this;
		this.overlayOn = true;
		for(i=0 ; i<vPest.length ; i++)
		{
			oElement = document.getElementById(vPest[i]);
			YUE.addListener(oElement, "mouseover", function(e,pest) {
				othis.overlayFix(pest);
			},vPest[i]);
			YUE.addListener(oElement, "mouseout", function(){
				othis.overlayFixOut();
			});
		}
	},
	this.overlayFixOut = function() {
		$(this.idIframe).style.display = 'none';
	},
	// marcar la pestana activa segun producto
	this.pestanaActiva = function(dominio) {
		if(dominio == 'afferralo.com' || dominio == 'atrapalo.it') {
	        if 		(location.href.indexOf('/hotel/index.php?pg=frame&pg_action=2') > -1)  this.marcar('cva');
	        else if (location.pathname.indexOf('/hotel') > -1)  this.marcar('hot');
	        else if (location.href.indexOf('http://agriturismo.atrapalo.it/') > -1)  this.marcar('hot');
	        else if (location.pathname.indexOf('/voli+hotel') > -1)  this.marcar('vmh');
	        else if (location.pathname.indexOf('/voli') > -1)  this.marcar('vue');
	        else if (location.pathname.indexOf('/attivita') > -1)  this.marcar('act');
	        else if (location.pathname.indexOf('/spettacoli') > -1)  this.marcar('esp');
	        else if (location.href.indexOf('http://autonoleggio.atrapalo.it/') > -1)  this.marcar('aut');
	        else  this.marcar('hom');
	    }else{
	        if (location.pathname.indexOf('/espectaculos') > -1) this.marcar('esp');
	        else if(location.pathname.indexOf('/entradas') > -1) this.marcar('esp');
       else if(location.pathname.indexOf('/home') > -1) this.marcar('hom');
       else if(location.pathname.indexOf('/restaurantes') > -1) this.marcar('res');
       else if(location.pathname.indexOf('/hoteles/playa/') > -1) this.marcar('extra');
       else if(location.pathname.indexOf('/hoteles') > -1) this.marcar('hot');
       else if(location.pathname.indexOf('/actividades/escapadas') > -1) this.marcar('esc');
       else if(location.pathname.indexOf('/actividades') > -1) this.marcar('act');            
       else if(location.pathname.indexOf('/vuelos') > -1) this.marcar('vue');
       else if(location.pathname.indexOf('/vuelo+hotel') > -1) this.marcar('vmh');
       else if(location.pathname.indexOf('/viajes') > -1) this.marcar('via');
       else if(location.pathname.indexOf('/coches') > -1) this.marcar('coc');
       else if(location.hostname.indexOf('hostales') > -1) this.marcar('hos');
       else if(location.pathname.indexOf('/Ofertas/Vuelos') > -1) this.marcar('vue');
       else if(location.pathname.indexOf('/Ofertas/Coches') > -1) this.marcar('coc');
       else if(location.pathname.indexOf('/OpAct') > -1) this.marcar('act');
       else if(location.pathname.indexOf('/opiniones/ver/ESP') > -1) this.marcar('esp');
       else if(location.pathname.indexOf('/opiniones/ver/RES') > -1) this.marcar('res');
       else if(location.pathname.indexOf('/opiniones/ver/HOT') > -1) this.marcar('hot');
	        else {
	            if($('es_home')) this.marcar('hom');
	            else this.marcar('gen');
	        }
	    }
	    //Atrapalo.header.setNumCartItems();
	}
}
try
{
	if (self != top && framed!=1)
	{
		if (document.images)
			top.location.replace(window.location.href);
		else
			top.location.href = window.location.href;
	}
}
catch(err)
{
	if(self!=top)
	{
		if (document.images)
			top.location.replace(window.location.href);
		else
			top.location.href = window.location.href;
	}
}
