function change(id, valor) {
	document.getElementById(id).value = valor;
}
	
function confirmar(id, valor, msg) {
	if(confirm(msg)) {
		document.getElementById(id).value = valor;
	} else {
		document.getElementById(id).value = '';
	}
}

function mostrar_habitaciones(j, max) {
	
	for (i = 0; parseInt(j) > i; i++) {
		document.getElementById('adulto_' + i).style.display = 'block';
		document.getElementById('nino_' + i).style.display = 'block';
	}
	for (i = parseInt(j); parseInt(max) > i ; i++) {
		document.getElementById('adulto_' + i).style.display = 'none';
		document.getElementById('nino_' + i).style.display = 'none';
	}
}

function mostrar_habitaciones_ofertas(j, max) {
	
	for (i = 0; parseInt(j) > i; i++) {
		document.getElementById('adulto_oferta_' + i).style.display = 'block';
		document.getElementById('nino_oferta_' + i).style.display = 'block';
	}
	for (i = parseInt(j); parseInt(max) > i ; i++) {
		document.getElementById('adulto_oferta_' + i).style.display = 'none';
		document.getElementById('nino_oferta_' + i).style.display = 'none';
	}
}

function enviar(lng) {
	location.href = "index.xhtml?lng="+lng;
}

/*********** Funciones para la capa trasparente *************************/
fileLoadingImage="img_lightbox/loading.gif";     
overlayOpacity=0.8;
// -----------------------------------------------------------------------------------


function ocultar(){
	var capa1 = document.getElementById('sobre');
	capa1.style.display= "none";
	var capa_light = document.getElementById('caja_sobre');
	capa_light.style.display= "none";
}

function mostrar(){

	var arrayPageSize = getPageSize();     
    	
	var lightboxLeft='';
	var capa1 = document.getElementById('sobre');   
	capa1.style.width = arrayPageSize[0] + 'px';
	capa1.style.height= arrayPageSize[1] + 'px';
	capa1.style.display= "block";
	
	var lightboxTop = arrayPageSize[0]/6;
	if(navigator.appName=='Microsoft Internet Explorer'){
		lightboxLeft = arrayPageSize[1]/3 - 250;
	}else{
		lightboxLeft = 0;
	}
	
	var capa_light = document.getElementById('caja_sobre');
	capa_light.style.top= lightboxTop + 'px';
	capa_light.style.left=lightboxLeft + 'px';
	capa_light.style.display= "block";
	
	
	if(navigator.appName=='Microsoft Internet Explorer'){ document.getElementById("cargando").innerHTML = '<img src="/img/loading.gif" />';}
	
}           
   

function getPageSize() {
	 var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

/************************************************************************/


function reservar(hotel, destino) {
	document.getElementById('header:reservar:destino').value = destino;
	document.getElementById('header:reservar:hotel').value = hotel;
}

function seleccionar_fecha(valor) {
	var fecha = valor.split('/');
	var dia = parseInteger(fecha[0]);
	var mes =  (parseInt(parseInteger(fecha[1])) - 1) + "";
	var meses = mes + " - " + fecha[2];
	document.getElementById('header:reservar:dia').value = dia;
	document.getElementById('header:reservar:meses').value = meses;
}

function seleccionar_fecha_oferta(valor) {
	var fecha = valor.split('/');
	var dia = parseInteger(fecha[0]);
	var mes =  (parseInt(parseInteger(fecha[1])) - 1) + "";
	var meses = mes + " - " + fecha[2];
	document.getElementById('form1:dia').value = dia;
	document.getElementById('form1:meses').value = meses;
}

function parseInteger(valor) {
	var res = valor;
	if (valor.charAt(0) == '0') {
		res = valor.substring(1, valor.length);
	}
	return res;
}