// JavaScript Document
var fondoActivo = 0;
var objetoActivo = 0;

window.onload = function(){
	MM_preloadImages('img/tiempo_act.jpg');
	f_inicializa();
	try{inicializaCalendario()}catch(e){};
}

function f_inicializa(){
	// Detecta Alt y agrega la propiedad Title con el mismo valor que el Alt para que funcione con el Netscape
	d = document;
	for(i=0;i<d.images.length;i++){
		alt = d.images[i].alt
		if(alt)d.images[i].title=alt
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/// Objetos Flash -----
function objetoFlash_galeria(lengua, seccion){
	var myFlash = new FlashObject("galeria/galeria.swf", "galeria", "649", "90", "7", "#FFFFFF");
	myFlash.addVariable("lengua", lengua);
	myFlash.addVariable("seccion", seccion);
	myFlash.addParam("wmode", "transparent");
	myFlash.addParam("menu", "false");
	myFlash.write('flash_galeria');
}
function objetoFlash_contenido(hotel,ruta){
	if(!ruta)ruta="";
	var myFlash = new FlashObject(ruta+"img/flash_contenido.swf", "flash_contenido", "649", "82", "7", "#FFFFFF");
	myFlash.addVariable("hotel", hotel);
	myFlash.addVariable("ruta", ruta);
	myFlash.addParam("wmode", "transparent");
	myFlash.addParam("menu", "false");
	myFlash.write('flash_contenido');
}
function objetoFlash_localizacion(hotel){
	var myFlash = new FlashObject("img/flash_localizacion.swf", "flash_localizacion", "300", "250", "7", "#FFFFFF");
	myFlash.addVariable("hotel", hotel);
	myFlash.addParam("wmode", "transparent");
	myFlash.addParam("menu", "false");
	myFlash.write('flash_localizacion');
}
//////////// ---
var	to=0;
function f_menu(id,estado){
	id = String(id);
	switch (estado){
		case 1 :
			document.getElementById("c_menu_0"+id).style.background="#F3F4F8";
			if(id.substr(0,1)=="2"){
				document.getElementById("c_menu_02").style.background="#F3F4F8";
				if(id=="2"){
					xIni = 1;
					if(to)clearTimeout(to);
					if(document.body.clientWidth>778){
						xIni = ((document.body.clientWidth-778)/2)+1;
					}
					document.getElementById("submenu02").style.visibility = "visible";
				}
			}
		break;
		case 0 :
			document.getElementById("c_menu_0"+id).style.background="white";
			if(id.substr(0,1)=="2"){
				if(id.substr(0,2)=="2_"){
					document.getElementById("c_menu_02").style.background="white";
				}
				blockSubmenu = 0;
				to = st();
			}
		break;
	}
}

function st(){
	return setTimeout("cierraSubmenu()",100);
}

function cierraSubmenu(){
	if(!blockSubmenu){
		document.getElementById("submenu02").style.visibility = "hidden";
	}
}

var win=null;
function visor(imagen){
	if(win){
		win.close();
	}
	ancho = 420;
	alto = 480;
	l=(screen.width-ancho)/2;
	t=(screen.height-alto)/2;
	win=window.open(imagen,'','top='+t+',left='+l+',width='+ancho+',height='+alto+', menubar=0, location=0, scrollbars=0, status=0, titlebar=0, resizable=0, toolbar=0');
}

function testListasReserva(op){
	finMesArray = [31,28,31,30,31,30,31,31,30,31,30,31];
	
	fecha = new Date();
	dia0 = fecha.getDate();
	mes0 = fecha.getMonth()+1;
	año0 = String(fecha.getYear());
	año0 = (año0).substr(año0.length-2);
	hoy = Number(año0+("0"+mes0).substr(("0"+mes0).length-2)+("0"+dia0).substr(("0"+dia0).length-2));
	
	for(i=1; i<=2;i++){
		eval("select_dia"+i+" = document.getElementById('dated"+i+"');");
		eval("select_mes"+i+" = document.getElementById('datem"+i+"');");
		eval("select_año"+i+" = document.getElementById('datey"+i+"');");
		
		eval("dia"+i+" = select_dia"+i+".value;");
		eval("mes"+i+" = select_mes"+i+".value;");
		eval("año"+i+" = select_año"+i+".value;");
		
		eval("finMes"+i+" = finMesArray[mes"+i+"-1];");
		
		eval("finMes"+i+" = finMesArray[mes"+i+"-1];");
			
		bisiesto(i);
		
		if(eval("dia"+i)>eval("finMes"+i)){
			eval("dia"+i+" = finMes"+i);
		}
		
		eval("fecha"+i+"= Number(año"+i+"+('0'+mes"+i+").substr(('0'+mes"+i+").length-2)+('0'+dia"+i+").substr(('0'+dia"+i+").length-2));");
	}

	if(fecha1<hoy){
		dia1=dia0;
		mes1=mes0;
		año1=año0;
		finMes1=finMesArray[mes1-1];
		bisiesto(1);
	}
	
	f_topeMes(1);
	
	if(fecha1>=fecha2){
		dia2=Number(dia1)+1;
		mes2=mes1;
		año2=año1;
		finMes2=finMes1;
	}
	
	f_topeMes(2);
	
	for(i = 1; i<=2; i++){
		while(eval("finMes"+i)<eval("select_dia"+i).length)
		{
			eval("select_dia"+i+".options[select_dia"+i+".length-1]=null");
		}
		while(eval("finMes"+i)>eval("select_dia"+i).length){
			nuevoValor = Number(eval("select_dia"+i).options[eval("select_dia"+i).length-1].value)+1;
			eval("select_dia"+i+".options[select_dia"+i+".length] = new Option(nuevoValor, nuevoValor, false, false)");
		}
		dia = eval("dia"+i);
		mes = eval("mes"+i);
		año = eval("año"+i);
		eval("select_dia"+i+".value = dia");
		eval("select_mes"+i+".value = mes");
		eval("select_año"+i+".value = año");
	}
}
function bisiesto(i){
	if(eval("mes"+i)==2 && (eval("año"+i)/4)==Math.floor(eval("año"+i)/4)){
		eval("finMes"+i+"=29")
	}
}
function f_topeMes(op){
	if(eval("dia"+op)>eval("finMes"+op)){
		eval("dia"+op+"= 1;");
		eval("mes"+op+"++;");
		if(eval("mes"+op)>12){
			eval("mes"+op+"=1;");
			eval("año"+op+"++;");
		}
		eval("finMes"+op+" = finMesArray[mes"+op+"-1];");
		bisiesto(op);
	}
}

function f_regimen(lengua){
	switch(lengua){
		case "es":
		ap1 = "Solo Alojamiento";
		ap2 = "Alojamiento y Desayuno";
		ap3 = "Media Pensión";
		ap4 = "Pensión Completa";
		break;
		case "en":
		ap1 = "Only room";
		ap2 = "Room and breakfast";
		ap3 = "Half Board";
		ap4 = "Full Board";
		break;
	}

	select_th = document.getElementById("regimen");
	iFin = select_th.length-1;
	for(i=iFin; i>=0; i--){
		select_th.options[i]=null;
	}

	switch (document.getElementById("lstHotel").value){
		case "280311":
			select_th.options[select_th.options.length] = new Option(ap1, "1", false, false);
			select_th.options[select_th.options.length] = new Option(ap2, "2", false, false);
			select_th.options[select_th.options.length] = new Option(ap3, "3", false, false);
			break;
		case "280312":
			select_th.options[select_th.options.length] = new Option(ap1, "1", false, false);
			select_th.options[select_th.options.length] = new Option(ap2, "2", false, false);
			break;
		case "280313":
			select_th.options[select_th.options.length] = new Option(ap1, "1", false, false);
			select_th.options[select_th.options.length] = new Option(ap2, "2", false, false);
			select_th.options[select_th.options.length] = new Option(ap3, "3", false, false);
			select_th.options[select_th.options.length] = new Option(ap4, "4", false, false);
	}
}

function EnviarReserva(lengua, hotel){
	switch(lengua){
		case "es":
		len = 1;
		break;
		case "en":
		len = 2;
		break;
	}
	
	if(!hotel){
		idHotel = document.getElementById('lstHotel').value;
	}else{
		idHotel = hotel;
	}

	document.frmdatos.action="http://www.cfreservas.com/r_fechas.asp?IDIOMA="+len+"&VCSS="+idHotel+"&SITE=280311&CODHOTEL="+idHotel;
}

var ventana_contacto=null;
function f_abreContacto(id, lengua, alto){
	if(ventana_contacto)ventana_contacto.close();

	ancho = 350;
	if(!alto)alto = 210;
	
	t=(screen.height-alto)/2;
	l=(screen.width-ancho)/2;
	ventana_contacto=window.open('l_'+lengua+'/contactos.asp?id='+id,'','top='+t+',left='+l+',width='+ancho+',height='+alto+', menubar=0, location=0, scrollbars=0, status=0, titlebar=0, resizable=0, toolbar=0');
}

var ventana_noticia=null;
function f_abreNoticia(id,lengua,tipo){
	if(ventana_noticia)ventana_noticia.close();

	ancho = 550;
	alto = 410;

	t=(screen.height-alto)/2;
	l=(screen.width-ancho)/2;
	ventana_contacto=window.open('visor_noticias.asp?id='+id+'&len='+lengua+'&tipo='+tipo,'','top='+t+',left='+l+',width='+ancho+',height='+alto+', menubar=0, location=0, scrollbars=1, status=0, titlebar=0, resizable=1, toolbar=0');
}
function muestraCapa(capa){
	document.getElementById('puertos').style.visibility='hidden';
	document.getElementById('vela').style.visibility='hidden';
	document.getElementById('windsurf').style.visibility='hidden';
	document.getElementById('buceo').style.visibility='hidden';
	capa = document.getElementById(capa);
	document.getElementById('contenedor').style.height=capa.style.height;
	capa.style.visibility='visible';
}
