// JavaScript Document
var IE = document.all?true:false;

function ajustaCapa(){
	topCentro=dameTop(document.getElementById('textoHotel'))
	pieCentro=topCentro+document.getElementById('textoHotel').offsetHeight;
	topDer=dameTop(document.getElementById('nuestrosHotelesD'))
	pieDer=topDer+document.getElementById('nuestrosHotelesD').offsetHeight;
	if (pieCentro<pieDer){
		//alargar centro
		dife=pieDer-pieCentro;
		document.getElementById('textoHotel').style.height=document.getElementById('textoHotel').offsetHeight+dife;
	}else{ 
		//alargar derecho
		dife=pieCentro-pieDer;
		alert(dife);
		document.getElementById('nuestrosHotelesD').style.height=(document.getElementById('nuestrosHotelesD').offsetHeight+dife)+"px";
	}
}

function dameTop(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent)
		{
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
		}
	}else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}


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);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ponEspera(){
	document.getElementById('capaEspera').style.visibility='visible';
}
function quitaEspera(){
	document.getElementById('capaEspera').style.visibility='hidden';
}

function abreVentana(url,ptop,pleft,ancho,alto){
	if (ptop==0 && pleft==0){ //centrarla
		ptop=parseInt((parseInt(screen.height)-alto)/2);
		pleft=parseInt((parseInt(screen.width)-ancho)/2);
	}
	window.open(url,"","top="+ptop+",left="+pleft+",width="+ancho+",height="+alto+",statusBar=no,resize=no");
}

// Capa del Idioma
desplaza=5; //desplazamiento en pixels
velocidad=20; //milesegundos, mas tiempo=efecto mas lento
leftInicio=690;
leftActual=690; //el que cambia
leftFin=leftInicio-130; //por los idioma
var pande=1; //suma height
function abre(){
	pande=1;
	reloj=setTimeout('meneo()',velocidad);
}
function cierra(){
	pande=-1;
	reloj=setTimeout('meneo()',velocidad);
}
function meneo(){
	leftActual=leftActual-(desplaza*pande);
	document.getElementById('idioma').style.left=leftActual+"px";
	document.getElementById('idioma').style.width=60+(leftInicio-leftActual)+"px";
	if (pande==1){ //sube
		if (parseInt(document.getElementById('idioma').style.left)>leftFin)
			reloj=setTimeout('meneo()',velocidad);
		else {//parar
			document.getElementById('idioma').style.left=leftFin+"px";
			leftActual=leftFin;
			clearTimeout(reloj);
		}
	}else{ //baja
		if (parseInt(document.getElementById('idioma').style.left)<leftInicio)
			reloj=setTimeout('meneo()',velocidad);
		else { //parar
			document.getElementById('idioma').style.left=leftInicio+"px";
			leftActual=leftInicio;
			clearTimeout(reloj);
		}
	}
}

// funciones del menu izquierdo
altoMenu=16;
altoMenuFin=altoMenu;
ultMenu=0;
fondocapa="#E2DAB9";
velocidad2=10; //milesegundos, mas tiempo=efecto mas lento
desplaza2=8; //desplazamiento en pixels
function verSub(ese,cuantos){
	if (ultMenu!=0)
		cierraSub();
	if (ultMenu==ese){
		cierraSub();
		ultMenu=0;
	}else{
		altoMenuFin=(cuantos+1)*altoMenu;
		ultMenu=ese;
		pande=1;
		document.getElementById('capa'+ultMenu).style.height=altoMenu; //inicial
		document.getElementById('capa'+ultMenu).style.backgroundColor=fondocapa; //fondo inicial
		document.getElementById('link'+ultMenu).className="menuMarcado"; //marcado
		reloj=setTimeout('meneoMenu()',velocidad2);
	}
	//document.getElementById('capa'+ese).style.height=((cuantos+1)*altoMenu)+"px";
}
function cierraSub(){
	document.getElementById('capa'+ultMenu).style.height=altoMenu+"px";
	document.getElementById('link'+ultMenu).className="tipoMenu"; //desmarcado
}
function meneoMenu(){
	document.getElementById('capa'+ultMenu).style.height=parseInt(document.getElementById('capa'+ultMenu).style.height)+(desplaza2*pande)+"px";
	if (pande==1){ //sube
		if (parseInt(document.getElementById('capa'+ultMenu).style.height)<altoMenuFin)
			reloj=setTimeout('meneoMenu()',velocidad2);
		else //parar
			document.getElementById('capa'+ultMenu).style.height=altoMenuFin+"px";
	}else{ //baja
		if (parseInt(document.getElementById('capa'+ultMenu).style.height)>altoMenu)
			reloj=setTimeout('meneoMenu()',velocidad2);
		else //parar
			document.getElementById('capa'+ultMenu).style.height=altoMenu+"px";
	}
}

//nº aleatorio para los flash
function aleatorio(inferior,superior){
    numPosibilidades = superior - inferior
    aleat = Math.random() * numPosibilidades
    aleat = Math.floor(aleat)
    return parseInt(inferior) + aleat
} 

//Funcion pa los flash
function runSWF(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess) { // tutorial by IVI CONCEPT - www.ivi-concept.com
if(version!=""){
	var version_data=version;
}else{
	var version_data="6,0,0,0";
}
if(menu!=""){
	menu_data=menu;
}else{
	menu_data=false;
}
if(bgcolor!=""){
	var bgcolor_data=bgcolor;
}else{
	var bgcolor_data="#FFFFFF";
}
if(id!=""){
	id_data=id;
}else{
	id_data="flashMovie";
}
if(quality!=""){
	quality_data=quality;
}else{
	quality_data="high";
}
if(allowScriptAccess!=""){
	allowScriptAccess_data=allowScriptAccess;
}else{
	allowScriptAccess_data="always";
}
var quality="high"; // calidad de visualización de la peli
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width="'+ancho+'" height="'+alto+'">\n');
//alert('<param name="movie" value="'+archivo+'&id='+aleatorio(1,50000)+'">\n');
//document.write('<param name="movie" value="'+archivo+'&id='+aleatorio(1,50000)+'">\n');
document.write('<param name="movie" value="'+archivo+'">\n');
//document.write('<param name= "allowScriptAccess" value= '+allowScriptAccess_data+'>\n');
document.write('<param name="quality" value="high">\n');
//document.write('<param name="FlashVars" value='+FlashVars+'>\n');
//document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
document.write('<param name="wmode" value="transparent">\n');
//document.write('<param name="menu" value='+menu_data+' >\n');
document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+' wmode="transparent"></embed>');
document.write('</object>\n');
}

