var ancho = screen.availWidth;
var alto = screen.availHeight;
var ventanaImagen;
var ventanaMapa;
var ventanaVacaciones;
var orientacion = "horizontal"
a=new Image(110,20);
a.src="imagenes/Bienvenido.gif";
b=new Image(110,20);
b.src="imagenes/Bienvenido2.gif";
c=new Image(110,20);
c.src="imagenes/Welcome.gif";
d=new Image(110,20);
d.src="imagenes/Welcome2.gif";
flaga=false, flagb=false, flagc=false, flagd=false;
function generaDiv(){
	if (ancho>800){
		var x = parseInt((ancho - 687)/2);
		var y = parseInt((alto - 400)/4);
		document.writeln('<div style="position:absolute;top:' + y + 'px;left:' + x + 'px">');
	} else {
		document.writeln('<div align="center">');
	}
}

/************************************************************************************
To change where the menu appears change the left and top values of the divCont
in the stylesheets, it's currently placed relative so you can
place this menu in tables or similar if you want. Change the 
text colors and size in the A.clMain and A.clSubb classes.
************************************************************************************/

/************************************************************************************
Change this to false if you want all the submenus to get unfold when you
foldout a new one.
************************************************************************************/
var stayFolded=false

/************************************************************************************
Browsercheck
************************************************************************************/
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;
var browser=((n || ie) && parseInt(navigator.appVersion)>=4)  

/************************************************************************************
Making cross-browser objects
************************************************************************************/
function makeMenu(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'										
	this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')					
   	this.ref=(n) ? eval(nest+'document.'+obj+'.document'):eval('document');		
	this.height=n?this.ref.height:eval(obj+'.offsetHeight')
	this.x=(n)? this.css.left:this.css.pixelLeft;this.y=(n)? this.css.top:this.css.pixelTop;							
	this.hideIt=b_hideIt;	this.showIt=b_showIt; this.vis=b_vis; this.moveIt=b_moveIt											
	return this
}
function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}
function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
/************************************************************************************
Initiating the page. Just add to the arrays here to get more menuitems
and add divs in the page
************************************************************************************/
function init(){
	oTop=new Array()
	oTop[0]=new makeMenu('divTop1','divCont')
	oTop[1]=new makeMenu('divTop2','divCont')
	oTop[2]=new makeMenu('divTop3','divCont')
	oTop[3]=new makeMenu('divTop4','divCont')
	oTop[4]=new makeMenu('divTop5','divCont')
	oTop[5]=new makeMenu('divTop6','divCont')
	oSub=new Array()
	oSub[0]=new makeMenu('divSub1','divCont.document.divTop1')
	oSub[1]=new makeMenu('divSub2','divCont.document.divTop2')
	oSub[2]=new makeMenu('divSub3','divCont.document.divTop3')
	oSub[3]=new makeMenu('divSub4','divCont.document.divTop4')
	oSub[4]=new makeMenu('divSub5','divCont.document.divTop5')
	oSub[5]=new makeMenu('divSub6','divCont.document.divTop6')
	for(i=0;i<oSub.length;i++){ oSub[i].hideIt() }
	for(i=1;i<oTop.length;i++){ oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height) }
}
/************************************************************************************
This is the function that changes the sub menus to folded or unfolded state.
************************************************************************************/
function menu(num){
	if(browser){
		if(!stayFolded){
			for(i=0;i<oSub.length;i++){
				if(i!=num){
					oSub[i].hideIt()
				}
			}
			for(i=1;i<oTop.length;i++){
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
			}
		}
		if(oSub[num].vis()){
			oSub[num].showIt()
		}else{
			oSub[num].hideIt()
		}
		for(i=1;i<oTop.length;i++){ 
			if(!oSub[i-1].vis()) oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height+oSub[i-1].height) 
			else oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
		}
	}
}
//Initiating the menus onload, if it's a 4.x+ browser.

var ancho = screen.availWidth;
var alto = screen.availHeight;
function generaDiv(){
	if (ancho>800){
		var x = parseInt((ancho - 687)/2);
		var y = parseInt((alto - 400)/4);
		document.writeln('<div style="position:absolute;top:' + y + 'px;left:' + x + 'px">');
	} else {
		document.writeln('<div align="center">');
	}
}
function reiniciaPagina(){
  init();
  parent.texto.document.location='textoHome.html';
  parent.fotosVSA.document.location='fotosHome.html';
}

function muestraImagen(imagen, ruta, orientacion){
	if(ventanaImagen && ventanaImagen!=""){
		if(ventanaImagen && !ventanaImagen.closed && ventanaImagen.name!=imagen){
			ventanaImagen.close();
		}
		else if(!ventanaImagen.closed){
			ventanaImagen.focus();
			return;
		}
	}
	if(orientacion=="vertical")
	ventanaImagen = window.open('',imagen,"width=271, height=400, scrollbars=no, menubar=no, location=no, resizable=no") ;
	else
	ventanaImagen = window.open('',imagen,"width=400, height=271, scrollbars=no, menubar=no, location=no, resizable=no") ;
	ventanaImagen.document.writeln("<html><body topmargin='0' leftmargin='0' marginWidth='0' marginHeight='0'><img src='" + ruta + "'></body><html>");

}
function abreMapa(mapa, ruta){
	if(ventanaMapa && ventanaMapa!=""){
		if(ventanaMapa && !ventanaMapa.closed && ventanaMapa.name!=mapa){
			ventanaMapa.close();
		}
		else if(!ventanaMapa.closed){
			ventanaMapa.focus();
			return;
		}
	}
	ventanaMapa = window.open('',mapa,"width=500, height=500, scrollbars=no, menubar=no, location=no, resizable=no") ;
	ventanaMapa.document.writeln("<html><body topmargin='0' leftmargin='0' marginWidth='0' marginHeight='0'><img src='" + ruta + "'></body><html>");
}
function cierraVentanas(){
	if(ventanaImagen && ventanaImagen!="")
		ventanaImagen.close();
	if(ventanaMapa && ventanaMapa!="")
		ventanaMapa.close();
}


function activaOpciones(activa, form){
	if (activa=="on") {
		total = form.elements.length;
		for(i=1; i<total; i++){
			form.elements[i].disabled=false;
			form.elements[i].checked=false;
		}
		for(i=1; i<total; i=i+5){
			form.elements[i].checked=true;
		}

	} else {
		total = form.elements.length;
		for(i=1; i<total; i++){
			form.elements[i].disabled=true;
			form.elements[i].checked=false;
		}
	}
}

function abreCroquis(croquis){
  ventanaCroquis = window.open('','Croquis',"width=400, height=218, scrollbars=no, menubar=no, location=no, resizable=no") ;
  ventanaCroquis.document.writeln("<html><body topmargin='0' leftmargin='0' marginWidth='0' marginHeight='0'><img src='" + croquis + "'></body><html>");
}

function abreReserva(){
  ventanaReserva = window.open('http://www.inetrural.com/Reservas/Reservas.php?CodCliente=38','reserva',"");
}

function abreOpine(){
  ventanaOpine = window.open('opine.html','opine',"width=550, height=530, scrollbars=no, menubar=no, location=no, resizable=no");
}

function abreDistintivo(){
  ventanaDistintivo = window.open('textoDistintivo.html','distintivo',"width=600, height=300, scrollbars=no, menubar=no, location=no, resizable=no");
}

function abreWelcome(){
  ventanaInfoWelcome = window.open('infoWelcome.html','infoWelcome',"width=800, height=600, scrollbars=yes, menubar=no, location=no, resizable=no");
}

function abreExterna(url){
  ventanaExterna = window.open(url);
}

function compruebaReserva(form){
  var fechaEntrada, fechaSalida;
  if(form.Entrada.value!=""){
  	fechaEntrada = form.Entrada.value.substring(6) + form.Entrada.value.substring(3,5) + form.Entrada.value.substring(0,2);
  	if(form.Salida.value!=""){
  		fechaSalida = form.Salida.value.substring(6) + form.Salida.value.substring(3,5) + form.Salida.value.substring(0,2);
  	}
  }
  if(form.Nombre.value==""){
  	alert("Por favor, introduzca su nombre.");
  	return false;
  } else if(form.Apellidos.value==""){
  	alert("Por favor, introduzca sus apellidos.");
  	return false;
  } else if(form.Entrada.value==""){
  	alert("Por favor, introduzca la fecha de entrada.");
  	return false;
  } else if(form.Salida.value==""){
  	alert("Por favor, introduzca la fecha de salida.");
  	return false;
  } else if(fechaEntrada>=fechaSalida){
  	alert("La fecha de salida debe ser posterior a la fecha de entrada");
  	return false;
  } else if(form.Telefono.value=="" && form.Fax.value=="" && form.eMail.value==""){
  	alert("Por favor, introduzca un medio de contacto: teléfono, fax o email.");
  	return false;
  } else {
  	form.submit();
	return true;
  }
}

var restaurante="on";
var hotel="on";
function cambiaRestaurante(){
	if(restaurante=="on")
		restaurante="off";
	else
		restaurante="on";
}
function cambiaHotel(){
	if(hotel=="on")
		hotel="off";
	else
		hotel="on";
}

function reinicia(){
  restaurante="on";
  hotel="on";
  document.opineRestaurante.reset();
  document.opineHotel.reset();
  document.Opine.reset();
}

function compruebaOpine(form){
  if(restaurante!="off" && hotel!="off"){
  	alert("Por favor, marque una opción.");
  	return false;
  } else if(form.FechaVisita.value==""){
  	alert("Por favor, introduzca la fecha de su visita.");
  	return false;
  } else {
  	if(restaurante=="off"){
 	  for (i=0;i<document.opineRestaurante.platos.length;i++){ 
       	    if (document.opineRestaurante.platos[i].checked) {
              form.platos.value = document.opineRestaurante.platos[i].value;
            }
            if (document.opineRestaurante.personalR[i].checked) {
              form.personalR.value = document.opineRestaurante.personalR[i].value;
            }
            if (document.opineRestaurante.limpiezaR[i].checked) {
              form.limpiezaR.value = document.opineRestaurante.limpiezaR[i].value;
            }
            if (document.opineRestaurante.calidadR[i].checked) {
              form.calidadR.value = document.opineRestaurante.calidadR[i].value;
            }
            if (document.opineRestaurante.generalR[i].checked) {
              form.generalR.value = document.opineRestaurante.generalR[i].value;
            }
    	  }
    	}
    	if(hotel=="off"){
 	  for (i=0;i<document.opineHotel.descanso.length;i++){ 
       	    if (document.opineHotel.descanso[i].checked) {
              form.descanso.value = document.opineHotel.descanso[i].value;
            }
            if (document.opineHotel.personalH[i].checked) {
              form.personalH.value = document.opineHotel.personalH[i].value;
            }
            if (document.opineHotel.limpiezaH[i].checked) {
              form.limpiezaH.value = document.opineHotel.limpiezaH[i].value;
            }
            if (document.opineHotel.calidadH[i].checked) {
              form.calidadH.value = document.opineHotel.calidadH[i].value;
            }
            if (document.opineHotel.generalH[i].checked) {
              form.generalH.value = document.opineHotel.generalH[i].value;
            }
    	  }
  	}
  	form.submit();
	return true;
  }
}

function mostrarVacaciones() {
	var ahora = new Date();
	var vNowDay = "" + ahora.getDate();
    	var vNowMonth = "" + (ahora.getMonth() + 1);
    	if(vNowDay.length == 1) {
    		vNowDay = "0" + vNowDay;
    	}
    	if(vNowMonth.length == 1) {
    		vNowMonth = "0" + vNowMonth;
    	}
    	var vNowYear = "" + ahora.getFullYear();
    	var fechaActual = vNowYear + vNowMonth + vNowDay;
    	var fechaInicio = 20040719;
    	var fechaFin = 20040816;
    	if((fechaActual>=fechaInicio) && (fechaActual<=fechaFin)){
    		ventanaVacaciones = window.open('','vacaciones04',"width=720, height=540, scrollbars=no, menubar=no, location=no, resizable=no") ;
    		ventanaVacaciones.document.writeln("<html><head>" + 
    						   "<title>Cerrado por vacaciones - Closed for holidays</title>" + 
    						   "</head><body topmargin='0' leftmargin='0' marginWidth='0' " + 
    						   "marginHeight='0'><img src='imagenes/vacaciones04.jpg'></body><html>");
    	}
}