// JavaScript Document

var iden_actual = 0;

function change_photo(foto) {
	document.getElementById('ampliacio').src= 'img/fotos_interiors/' + foto;
}

function canvi_botons(iden) {
	if ( iden_actual!=0 ) {
		document.getElementById('boto'+iden_actual).style.display = 'block';
		document.getElementById('boto'+iden_actual+'_actiu').style.display = 'none';
	}
	if (iden!=0) {
		document.getElementById('boto'+iden+'_actiu').style.display = 'block';
		document.getElementById('boto'+iden).style.display = 'none';
	}

	iden_actual = iden;
}

function loader(url) {
	document.getElementById('contingut').src = url;
}

function loader_in(url) {
	window.location.href = url;
	
	window.parent.document.getElementById('boto3').style.display = 'block';
	window.parent.document.getElementById('boto3_actiu').style.display = 'none';
	
	window.parent.document.getElementById('boto7').style.display = 'none';
	window.parent.document.getElementById('boto7_actiu').style.display = 'block';
	window.parent.iden_actual = 7;
}

function loader_in_reserva(url) {
	window.location.href = url;
	
	window.parent.document.getElementById('boto4').style.display = 'block';
	window.parent.document.getElementById('boto4_actiu').style.display = 'none';
	
	window.parent.document.getElementById('boto5').style.display = 'none';
	window.parent.document.getElementById('boto5_actiu').style.display = 'block';
	window.parent.iden_actual = 5;
}

function credits()
{
	LeftPosition = (screen.width) ? (screen.width-300)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-200)/2 : 0;
	window.open ('credits.asp','','width=300, height=200, scrollbars=no, statusbar=no, toolbar=no, mainbar=no, left='+LeftPosition+', top='+TopPosition+'');
}

function zoom(url,model) {
	LeftPosition = (screen.width) ? (screen.width-497)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-298)/2 : 0;
	window.open ('zoom.asp?foto='+url+'&model='+model,'','width=497, height=280, scrollbars=no, mainbar=no, statusbar=no, left='+LeftPosition+', top='+TopPosition+'');
}

function introtext(text,textb)
{
	LeftPosition = (screen.width) ? (screen.width - 505) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - 453) / 2 : 0;
	editor = window.open('intro.asp?text='+text+'&textb='+textb+'','','width=505, height=453, scrollbars=no, mainbar=no, statusbar=no, left='+LeftPosition+', top='+TopPosition+'');
}

function show(id) {
	document.getElementById(id).style.display = 'block';
}

function cerrar(id) {
	document.getElementById(id).style.display = 'none';
}

function open_w(url,w,h) {
	LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
	
	window.open (url,'','width='+w+', height='+h+', statusbar=no,mainbar=no,toolbar=no,left='+LeftPosition+',top='+TopPosition+'');
}

function open_ws(url,w,h) {
	LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
	
	window.open (url,'','width='+w+', height='+h+', scrollbars=yes, statusbar=no,mainbar=no,toolbar=no,left='+LeftPosition+',top='+TopPosition+'');
}

function total_f() {
	adultos = document.buscador_f.adultos;
	nens = document.buscador_f.nens;
	
	adultos_v = adultos.options[adultos.selectedIndex].value;
	nens_v = nens.options[nens.selectedIndex].value;
	adultos_v = parseInt(adultos_v);
	nens_v = parseInt(nens_v);
	var total;
	total = adultos_v + nens_v;
	
	return total;
}

function calcula() {
	var total = total_f();
	
	if (total>6) {
		alert('El numero máximo de personas es 6.');
	} else {
		document.getElementById('total').innerHTML = total;
		document.buscador_f.total.value = total;
	}
}

function valida() {
	var total = total_f();
	
	if (total>6) {
		alert('El numero máximo de personas es 6.');
	} else {
		document.buscador_f.submit();
	}
}