// JavaScript Document
Cufon.replace('#menu2 li');
Cufon.replace('#explore a');
Cufon.replace('#separatore span');
Cufon.replace('#fastbooking p');

function validateFastbooking(idForm){
	var adulti= $("#adulteresa").val();
	var bambini=$("#enfantresa").val();
	var totalePersone=parseInt(adulti)+parseInt(bambini);
	//alert(totalePersone);
	if(totalePersone>5) { alert("WE SHOULD HAVE AVAILABILITY FOR YOU, BUT FOR THIS NUMBER OF GUESTS, PLEASE BE SO KIND TO CONTACT J.K. BOOKING OFFICE AT info@jkplace.com or call +39 055 2645181"); 
	}
	else
	{
	hhotelDispoprice(idForm);
	}
	}


$(document).ready(function () {
$(document).pngFix();

$("a.zoomFoto").fancybox({'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true, 'imageScale': false, 'centerOnScroll': false}); 
$("a.mm").fancybox({'frameWidth':960, 'frameHeight':480}); 
$("a.companyInfo").fancybox({'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true, 'frameWidth':460, 'frameHeight':200}); 

// supersize //
$.fn.supersized.options = {  
startwidth: 1550,  
startheight: 841,
vertical_center: 1,
slideshow: 0,
navigation: 0,
transition: 1, //0-None, 1-Fade
pause_hover: 0,
slide_counter: 1,
slide_captions: 1,
slide_interval: 3000  
};

$('#supersize').supersized(); 
		
///////////////////////////////////////////////////////////////////////
/////////// Calcolo dimensioni per DIV Rooms e Photogallery ///////////
///////////////////////////////////////////////////////////////////////
	
// dimensioni finestra	
var browserwidth = $(window).width();
var browserheight = $(window).height();

// spazio disponibile per la galleria
var galleriawidth = $("#galleria").width();
var galleriaheight = $("#galleria").height();

// spazio disponibile per le rooms		
var roomswidth = $("#rooms").width();
var roomsheight = $("#rooms").height();
	
//220 è la barra di sx, 66 è la somma della barra alta + barra bassa
var larghezzaDisponibile=browserwidth-220;
var altezzaDisponibile=browserheight-66;

var larghezzaDisponibile2=roomswidth-220;
var altezzaDisponibile2=roomsheight-66;

// definisco dimensioni fotine gallery e tastoni camere
var larg=parseInt(larghezzaDisponibile/7);
var larg2=parseInt(larghezzaDisponibile2/7);
var alt=parseInt(altezzaDisponibile/5);
var alt2=parseInt(altezzaDisponibile2/5);
	
//$("#header").html(larghezzaDisponibile2+"x"+altezzaDisponibile2+"//"+larg3+"x"+alt3);
		
//gallery
$(".image-holder").css("width",larg);
$(".image-holder").css("height",alt);
$(".image-holder img").attr("width",larg);
$(".image-holder img").attr("height",alt);

//rooms
$(".image-holder2").css("width",larg2);
$(".image-holder2").css("height",alt2);
$(".image-holder2 img").attr("width",larg2);
$(".image-holder2 img").attr("height",alt2);
		
//eeepc
if(browserheight<420) { 
	$("#footer").css({
	"margin-left":"220px",
	"width":browserwidth-220
	})
}

//////////////////////////////////////////////////////////////////////////////
/////////// Calcolo ridimensionamento per DIV Rooms e Photogallery ///////////
//////////////////////////////////////////////////////////////////////////////
	
// ad ogni ridimensionamento della finestra richiamo la funzione
$(window).bind("resize", function(){

var browserwidth = $(window).width();
var browserheight = $(window).height();

var roomswidth = $("#rooms").width();
var roomsheight = $("#rooms").height();
		
var larghezzaDisponibile=browserwidth-220;
var altezzaDisponibile=browserheight-66;

var larghezzaDisponibile2=roomswidth-220;
var altezzaDisponibile2=roomsheight-66;

var larg=parseInt(larghezzaDisponibile/7);
var larg2=parseInt(larghezzaDisponibile2/7);

var alt=parseInt(altezzaDisponibile/5);
var alt2=parseInt(altezzaDisponibile2/5);

/*$("#header").html(larghezzaDisponibile3+"x"+altezzaDisponibile3+"//"+larg3+"x"+alt3);*/
			
$(".image-holder").css("width",larg);
$(".image-holder").css("height",alt);
$(".image-holder img").attr("width",larg);
$(".image-holder img").attr("height",alt);

//rooms
$(".image-holder2").css("width",larg2);
$(".image-holder2").css("height",alt2);
$(".image-holder2 img").attr("width",larg2);
$(".image-holder2 img").attr("height",alt2);
		
//eeepc
if(browserheight<420) { 
$("#footer").css({
	"margin-left":"220px",
	"width":browserwidth-220
			 })
}
else{
$("#footer").css({
	"margin-left":"0px",
	"width":browserwidth
			 })
}


	
	// gestisco la finestra explore e il suo ridimensionamento del browser	
	var allargoAltezza=$("#explore").height();
	var allargoLarghezza=$("#explore").width();

	allargoAltezza=parseInt(allargoAltezza)-66;
	allargoLarghezza=parseInt(allargoLarghezza)-220;
	
	var dimAltezza=parseInt(allargoAltezza/8);
	
	$("#explore-rates, #explore-rates table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-lounge, #explore-lounge table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-press, #explore-press table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-location, #explore-location table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-download, #explore-download table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-contact, #explore-contact table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-friends, #explore-friends table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	$("#explore-suggestions, #explore-suggestions table").css({"width":allargoLarghezza,"height":dimAltezza}); 
	/*$("#header").html(dimAltezza);*/




}); // fine funzione che gestisce il ridimensionamento della finestra
		
		
		
		
		
		
		
}); // fine document ready


// funzione che attiva la galleria
function galleria(){
	$("#supersize a").replaceWith("<a href=''></a>");
	$("#galleria").fadeIn(800);
	$("#rooms").hide(); 
	$("#closer").hide();
	$("#dettaglioCamera").hide();
	$("#navigatoreFoto").hide();
	}
	
// funzione che attiva div Rooms
function rooms(){
	$("#supersize a").replaceWith("<a href=''></a>");
	$("#galleria").hide();
	$("#closer").hide();
	$("#dettaglioCamera").hide();
	$("#rooms").fadeIn(1000);
	}
	
// funzione che attiva div explore
/*
function explore(){
	$("#galleria").hide();
	$("#rooms").hide();
	$("#closer").hide();
	$("#dettaglioCamera").hide();
	$("#explore").animate({opacity:1},1000,"linear");
	}
*/

// funzione che attiva div explore2 (7 fasce con i tasti)
function explore2(){
	
	var allargo=$("#explore").width();
	allargo=parseInt(allargo)-221;
	
	var allargoAltezza=$(window).height();
	allargoAltezza=parseInt(allargoAltezza)-66;
	var dimAltezza=parseInt(allargoAltezza/8);
	//alert(allargoAltezza);
	
	$("#galleria").hide();
	$("#rooms").hide();
	$("#closer").hide();
	$("#dettaglioCamera").hide();
	
	$("#explore").show();
	$("#explore table").css({"height": dimAltezza});
	
	$("#explore-rates").css({"height": dimAltezza});
	$("#explore-lounge").css({"height": dimAltezza});
	$("#explore-press").css({"height": dimAltezza});
	$("#explore-location").css({"height": dimAltezza});
	$("#explore-download").css({"height": dimAltezza});
	$("#explore-contact").css({"height": dimAltezza});
	$("#explore-friends").css({"height": dimAltezza});
	$("#explore-suggestions").css({"height": dimAltezza});
	
	$("#explore a").animate({opacity:1},2000,"linear");
	$("#explore a").css({"width":allargo-30, "height":dimAltezza});
	
	$("#explore-rates").animate({width:allargo},700,"easeOutQuad");
	$("#explore-lounge").animate({width:allargo},900,"easeOutQuad");
	$("#explore-press").animate({width:allargo},1100,"easeOutQuad");
	$("#explore-location").animate({width:allargo},1300,"easeOutQuad");
	$("#explore-download").animate({width:allargo},1500,"easeOutQuad");
	$("#explore-contact").animate({width:allargo},1700,"easeOutQuad");
	$("#explore-friends").animate({width:allargo},2000,"easeOutQuad");
	$("#explore-suggestions").animate({width:allargo},2000,"easeOutQuad");
	}	
	
	
	var precedente=successiva=0;
	var nFoto=0;
	
// funzione che fa lo zoom sulla foto usata per la fotogallery
function mostraFoto(foto,numFoto){
	
	if(numFoto==1) { precedente=32; successivo=numFoto+1; }
	else if(numFoto==32) { precedente=numFoto-1; successivo=1; }
	else { precedente=numFoto-1; successivo=numFoto+1; }
	
	$("#closer").fadeIn(200);
	$("#galleria").hide();
	$("#rooms").hide();
	
	var contenuto=$("#supersize a").html();
	$("#supersize a").replaceWith("<a href='javascript:galleria();void(0);'><img src='" + foto + "'></a>");
	contenuto="";
	
	//29-06-2010
	$("#navigatoreFoto").fadeIn(200);
	
	nFoto=numFoto;
	settaFrecce(nFoto);
	}
	

function settaFrecce(nFoto){
	precedente=nFoto-1;
	successivo=nFoto+1;
	if(nFoto==1){
		precedente=32;
		}
	if(nFoto==32){
		successivo=1;
		}
	//alert(precedente+"/"+nFoto+"/"+successivo);
	}	
	
function avanti(){
	var nomeBig=fotoBig[successivo];
	$("#supersize a").replaceWith("<a href='javascript:galleria();void(0);'><img src='" + nomeBig + "'></a>");
	settaFrecce(successivo);
	}
	
function indietro(){
	var nomeBig=fotoBig[precedente];
	$("#supersize a").replaceWith("<a href='javascript:galleria();void(0);'><img src='" + nomeBig + "'></a>");
	settaFrecce(precedente);
	}	
	
	
	

// funzione che fa lo zoom sulla foto usata per la pagina delle camere
function mostraFotoRoom(tipo,foto){
	$("#closer").fadeIn(600);
	var contenuto=$("#supersize a").html();
	$("#supersize a").replaceWith("<a href='javascript:rooms();void(0);'><img src='" + foto + "'></a>");
	contenuto="";
	$("#galleria").hide();
	$("#rooms").hide();
	$("#dettaglioCamera").fadeIn(600).load("room-"+tipo+".php",function(){
	});
	}
	
// funzione che fa lo zoom sulla cartina
function mostraCartina(){
	$("#closer").fadeIn(600);
	var contenuto=$("#supersize a").html();
	$("#supersize a").replaceWith("<a href='location.html'><img src='grafica/cartinaBig.jpg'></a>");
	contenuto="";
	$("#galleria").hide();
	$("#rooms").hide();
	$("#contenutoInterno").hide();
	}	
	

function caricaLounge(){
	$("#closer").fadeIn(600);
	$("#galleria").hide();
	$("#rooms").hide();
	$("#explore").show();
	$("#dettaglioCamera").fadeIn(600).load("jklounge-interno.html",function(){
	});
	}

function mostraFotoLounge(foto){
	$("#closer").fadeIn(600);
	var contenuto=$("#supersize a").html();
	$("#supersize a").replaceWith("<a href='jklounge.html'><img src='" + foto + "'></a>");
	contenuto="";
	$("#galleria").hide();
	$("#rooms").hide();
	$("#explore").show();
	$("#dettaglioCamera").fadeIn(600).load("jklounge-interno.html",function(){
	});
	}

function caricaContenuto(pagina){
	$("#galleria").hide();
	$("#rooms").hide();
	$("#explore").show();
	$("#contenutoInterno").fadeIn(600).load(pagina+".php",function(){
	});
	}

// mostra le immagini quando sono caricate
/*
$(function () {
		$('#galleria1 img').hide();//hide all the images on the page
		});
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)",300);//500 is the fade in speed in milliseconds
		});

		function doThis() {
			var imgs = $('#galleria1 img').length;//count the number of images on the page
			
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
				//clearInterval(i);//When it reaches the last image the loop ends
			}
			$('#galleria1 img:hidden').eq(0).fadeIn(300);//fades in the hidden images one by one
			i++;//add 1 to the count
		}
*/		
		
// mostra le immagini della PRESS quando sono caricate
/*
$(function () {
		$('#press').hide();	
		$('#pressInterno img').hide();//hide all the images on the page
		});
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			$('#press').show();	
			var int = setInterval("doThis(i)",200);//500 is the fade in speed in milliseconds
		});

		function doThis() {
			var imgs = $('#pressInterno img').length;//count the number of images on the page
			
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
				//clearInterval(i);//When it reaches the last image the loop ends
			}
			$('#pressInterno img:hidden').eq(0).fadeIn(200);//fades in the hidden images one by one
			i++;//add 1 to the count
		}
*/



