﻿var loaded=false;
var contenido_plano = new Array;
 
function delay(time){
   for(var d=new Date();new Date()-d < time;);
}

//***********************************************
//********* MÉTODOS DE CAPA *********************
//***********************************************
function pinta(id)
{
    //plano.activate();
    var sTitulo = "";
    var sCapas = "";
    var plano;
    var entero = 0;
   
    entero = parseInt(id);
    
    if (id == "0")//Junior suite
    {
        sTitulo = "Plano Junior Suite";
    }
    if (id == "1")
    {
        sTitulo = "Plano Golf Suite";
    }
    if (id == "2")
    {
        sTitulo = "Plano Golf Suite Royal";
    }
    if (id == "3")
    {
        sTitulo = "Plano Residence Suite";
    }
    if (id == "4")
    {
        sTitulo = "Plano Golf Suite con piscina";
    }
    if (id == "5")
    {
        sTitulo = "Plano Residence Suite con piscina";
    }
    
   sCapas = "<div id='galeria_base'><iframe src='' class='iframeTarifasPlanos' id='theframe' ></iframe>" +
            "<div id='galeria_container'>" +
		    "<div id='galeria_linea_migas'>" +
		    "<img src='http://" + get_servidor(2) + "/comun/imagenes/iconos/imprimir.gif'/>&nbsp;" +
			"<a href='javascript:printPopup();' class='linkDestGrg11Gris'>Imprimir</a>&nbsp;&nbsp;"+
			"<img src='http://" + get_servidor(2) + "/comun/imagenes/iconos/aspaGaleria.gif'/>&nbsp;" +
		    "<a href='javascript:cerrar_plano();' class='linkDestGrg11Gris'>Cerrar</a></div>" +
		    "<div class='divTitulo' id='galeria_titulo'>" + sTitulo + "</div>" +
            "<div id='galeria_contenido'>"+ contenido_plano[entero] +"</div>" +
	        "</div>" +
            "</div>";
    document.getElementById("div_popup").innerHTML = sCapas;
    
   
	initial();
    
    
}
function cerrar_plano(){   
    if (impreso == 1)
	{	history.go(0); }
	document.getElementById("div_popup").innerHTML = "";
}

    
//************************************************
//*********  MÉTODOS DE PLANO  ********************
//*************************************************

function addroom(room){
	this.rooms[this.totalrooms] = room;
	this.rooms[this.totalrooms].id = this.totalrooms;
	this.totalrooms++;
	return room
}

function plano_over(n){
var room;
	if (this.selected != n) {
		room = this.rooms[n];
		room.over(this);
	}
};

function plano_hideAll(){
var room;
	room = this.rooms[this.selected];
	room.out(this);
};

function plano_out(n){
var room;
	if (this.selected != n) {
		room = this.rooms[n];
		room.out(this);
	}
};
function plano_next(){
var sel = this.selected
	sel = sel + 1
	if (sel > this.totalrooms-1)
	sel = 0;
	this.activate(sel);
}

function plano_previous(){
var sel = this.selected
	sel = sel - 1
	if (sel < 0 )
		sel = this.totalrooms-1;
	this.activate(sel);
}

function activate(n){
var room;
var selected;
	//document.all('atras').style.cursor = 'wait';
	selected=this.selected;
	if (n!=null) 
		this.selected = n;
	this.rooms[selected].out(this);
	room = this.rooms[this.selected];

    if (document.images[room.imageName].filters) 
       document.images[room.imageName].filters[0].apply();
	
	document.images[room.imageName].src = room.photo.src;

    if (document.images[room.imageName].filters) 
       document.images[room.imageName].filters[0].play();

	room.on();
	//document.all('atras').style.cursor = 'auto';
	return false;
}

function plano_off() {};

//*************************************************
//*************  MÉTODOS DE ROOMS  ****************
//*************************************************

function addImage(image){
	this.images[this.counter] = image;
	this.counter++;
	return image;
}

function room_out(objPlano){
var img = new Array;
img = this.images;
for (i=0; i< this.counter;i++) {
	// comprobar si la imagen que se va a sustituir pertenece a la que está activa
	var bValido=true;
	for (var j=0;j<objPlano.rooms[objPlano.selected].counter;j++) {
		if(objPlano.rooms[objPlano.selected].images[j].name == img[i].name) {
			bValido=false;
		}
	}
	if(bValido)	document.images[img[i].name].src = img[i].imageOut.src;
}
}

function preload(src) {
var img = new Image();
img.src = src;
return img
}

function room_on(){
var img = new Array;
img = this.images;
//this.preloadImages();
for (i=0; i< this.counter;i++) {
	  document.images[img[i].name].src = img[i].imageOn.src;
}
}

function room_over(objPlano){
var img = new Array;
img = this.images;
for (var i=0; i< this.counter;i++) {
	// comprobar si la imagen que se va a sustituir pertenece a la que está activa
	var bValido=true;
	for (var j=0;j<objPlano.rooms[objPlano.selected].counter;j++) {
		if(objPlano.rooms[objPlano.selected].images[j].name == img[i].name) {
			bValido=false;
		}
	}
	if (bValido) document.images[img[i].name].src = img[i].imageOver.src;
}
}

//*************************************************
//*************  MÉTODOS DE ROOMS  ****************
//*************************************************

function objPlano() {
this.addroom = addroom;
this.rooms = new Array;
this.totalrooms = 0
this.mouseover = plano_over;
this.mouseout = plano_out;
this.selected = 0;
this.activate = activate;
this.next = plano_next;
this.previous = plano_previous;
this.hideAll = plano_hideAll;
return this;
}

function objRoom(name,photo){
this.id;
this.name = name;
this.images = new Array;
this.imageName = 'carrusel';
this.photo = new Image;
this.photo.src = photo;
this.addImage = addImage;
this.over = room_over;
this.on = room_on;
this.out = room_out;
this.counter = 0;
return this;
}
function objImage(name, over, out, on){
this.name = name;
this.imageOn = new Image();
this.imageOn.src = on;
this.imageOver= new Image();
this.imageOver.src= over;
this.imageOut = new Image();
this.imageOut.src= out;
return this;
}


function nextImage(){
	if (totalImages > currentImage){
		currentImage++	
		carrusel.src = arCarrusel[currentImage]	
	}
}
function previousImage(){
	if (0 < currentImage){
		currentImage--	
		carrusel.src = arCarrusel[currentImage]	
	}

}

