/*************************************** mostrar y ocultar Varias capas  ***************************************/

function multiFlipContenidos() {
		var arg=multiFlipContenidos.arguments;
		for(i=0; i<arg.length/2;i++ ){
			var contName = document.getElementById(arg[i*2]);
			var tipo = arg[(i*2)+1];
			if(tipo == "on")valor = "block"; else if(tipo == "off")valor = "none";
			if(contName)contName.style.display = valor;
		}
}

/*************************************** efecto de pestanas   ***************************************/

function multiFlipPestanyas() {
		var arg=multiFlipPestanyas.arguments;
		for(i=0; i<arg.length/2;i++ ){
			var pestaName = document.getElementById(arg[i*2]);
			var nombreClase = arg[(i*2)+1];
			if (pestaName.setAttribute("class", nombreClase)) pestaName.setAttribute("class", nombreClase);
    	if (pestaName.setAttribute("className", nombreClase))pestaName.setAttribute("className", nombreClase);
		}
}

/************************************* parpadeo pestanas en la home  **************************************/
var prTime;
function destacaPestanas(pName, claseOn, claseOf, ini){
		clearTimeout(prTime);
		if(pName!="stop"){
			if(ini%2==0)multiFlipPestanyas(pName, claseOn);
			else multiFlipPestanyas(pName, claseOf);
			ini++;
			if(ini<18)prTime=setTimeout("destacaPestanas('"+pName+"', '"+claseOn+"', '"+claseOf+"', "+ini+")",800);
		}
}

/*************************************** listas desplegables ************************************************/

var listaCargada = "";
var botonCargado = "";
var alto=20;
var listaTime;
var btScrollColor= "";
var agt = navigator.userAgent.toLowerCase();
var IE = agt.indexOf("msie") != -1;
var Version = parseInt(navigator.appVersion);

function desplegaLista(listaName, altoLista, botonName, miColor){
	clearTimeout(listaTime);
	if(listaCargada == ""){
		var lista = document.getElementById(listaName);
		var boton = document.getElementById(botonName);
		if(alto==20){
			lista.scrollTop=0;
			if(listaName=="lista-modlos" && botonCargado != "" && IE && (Version < 7)) {
				lista.style.margin="-22px 0 0 -163px"
			}
			lista.style.display="block";
			boton.src="/imagenes/local/comunes/ico_plega_azul.gif";
		}
		alto +=(altoLista - alto)/3;
		lista.style.height=alto+"px";
		if(alto<(altoLista-1))listaTime = setTimeout("desplegaLista('"+listaName+"', "+altoLista+", '"+botonName+"', '"+miColor+"',50)");
		else {
			alto=20, lista.style.height=altoLista+"px", listaCargada = listaName, botonCargado=botonName, btScrollColor=miColor;
		}
	}else cierraLista();
}

function cierraLista(){
	var lista = document.getElementById(listaCargada);
	var boton = document.getElementById(botonCargado);
	if(lista){
		lista.style.display = "none", listaCargada = "";
		boton.src="/imagenes/local/comunes/ico_desple_azul.gif";
	}
}


/*************************************** cambio de imagen en breves   ***************************************/

function precargaImgs(imgArray){
		if (document.images)
    {
      preload_image_object = new Image();
      var i = 0;
      for(i=0; i<imgArray.length; i++) {
      	preload_image_object.src = imgArray[i];
      }
    }
}

function imgEnlace(linkArray, ind){		document.location = linkArray[ind]; }

function cargaImgBreve(imgArray, dire){
		var imgBreve = document.getElementById("fotoActiva");
		var cntBreve = document.getElementById("counter");
		if(dire=="der"){
			if(imgCargada<(imgArray.length-1)){
				imgCargada++;
				imgBreve.src=imgArray[imgCargada];
				multiFlipPestanyas(imgCargada,'activo');
				multiFlipPestanyas((imgCargada-1),'');
				//imgBreve.style.margin = "0 0 0 "++"px";
			}
		}else{
			if(imgCargada>0){
				imgCargada--;
				imgBreve.src=imgArray[imgCargada];
				multiFlipPestanyas(imgCargada,'activo');
				multiFlipPestanyas((imgCargada+1),'');
			}
		}
		cntBreve.innerHTML='<span>' + (imgCargada+1)+ ' of ' + imgArray.length + '</span>';
}


/*************************************** efecto persiana para el bloque de video   ***************************************/

var timeCloseVideo;

function parsianaVideo( obID , tot ) {
		var videoClick = document.getElementById("cajavideo" + obID);
		var btClick = document.getElementById("btV" + obID);
		clearTimeout(timeCloseVideo);
		if(obID ==  SlctdVideo){
			if(tot==0)tot=55;
			tot += (17 - tot)/3; 
			videoClick.style.height = tot +"px";
    	if(tot>18)timeCloseVideo = setTimeout("parsianaVideo("+obID+","+tot+")",30);
    	else {
    		SlctdVideo = 100;
    		videoClick.style.height = "19px";
    		videoClick.setAttribute("class", "cerrado");
	    	videoClick.setAttribute("className", "cerrado");
    		btClick.setAttribute("class", "abre");
    		btClick.setAttribute("className", "abre");
    		btClick.setAttribute("title", "Desplegar");
    	}
		}else{
			var videoAbierto = document.getElementById("cajavideo" + SlctdVideo);
			var btAbierto = document.getElementById("btV" + SlctdVideo);
			if(tot==0){
				tot=19;
				if(videoAbierto){
					videoAbierto.setAttribute("class", "cerrado");
		    	videoAbierto.setAttribute("className", "cerrado");
		    	btAbierto.setAttribute("class", "abre");
		    	btAbierto.setAttribute("className", "abre");
		    	btAbierto.setAttribute("title", "Desplegar");
		    }
		    
		    videoClick.setAttribute("class", "abierto");
	    	videoClick.setAttribute("className", "abierto");
	    	btClick.setAttribute("class", "cierra");
	    	btClick.setAttribute("className", "cierra");
	    	btClick.setAttribute("title", "Cerrar");
			}
			tot += (57 - tot)/5;
			tit = (57 - tot)+19;
			if(videoAbierto)videoAbierto.style.height = tit +"px";
			videoClick.style.height = tot +"px";
    	if(tot<56)timeCloseVideo = setTimeout("parsianaVideo("+obID+","+tot+")",30);
    	else {
    		videoClick.style.height = "55px";
				if(videoAbierto)videoAbierto.style.height = "19px";
				SlctdVideo = obID;
    	}
    }
}
/*************************************** Buscador de viajes   ***************************************/

function selectBuscador(nBuscador,tipo){
	var icoImg = document.getElementById("imgBuscador");
	var titleTexto = document.getElementById("tituloBuscador");
	if (nBuscador=="rural") {
		fBuscador.action='http://www.hola.com/buscador/hotelesrurales/buscar';
		titleTexto.innerHTML='BUSCAR HOTELES RURALES';
	}
	if(nBuscador=="hoteles") {
		fBuscador.action='http://www.hola.com/buscador/hoteles/buscar';
		titleTexto.innerHTML='BUSCAR HOTELES';
	}
	if(nBuscador=="viajes") {
		fBuscador.action='http://www.hola.com/buscador/viajes/buscar';
		titleTexto.innerHTML='BUSCAR VIAJES';
	}
	if(tipo)nBuscador+=tipo;
	icoImg.setAttribute("class", nBuscador);
	icoImg.setAttribute("className", nBuscador);
}



function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

/***************************************  CONTADOR ********************************************************/
function contador(des){
	var url="http://servicios.hola.com/contador/contador.php";
			url=url+"?destino="+des;
			url=url+"&sid="+Math.random();
	var imagen = document.getElementById('imgcontador');
			imagen.src=url;	
}


