var LAST_CONTENT = false ; var PANEL_H = new Array() ; var TIMER_ROOMS = null ; var TIMER_WELCOME = null ; $(document).ready(function(){ // Startup slider first $('#slider').nivoSlider({ directionNav:false, animSpeed:1000, // Slide transition speed pauseTime:4000 // How long each slide will show }); // Startup attractions slider initSlider(); // Bind colorbox effects var lang = $("a.attractions_panel").attr("lang") ; $("a.attractions_panel").colorbox({ iframe:true, href:"attrazioni_info.html?lang="+lang, width:920, height:545 }) ; /*$("a[rel='gallery1']").colorbox();*/ window.setTimeout( function(){initPage()} , 1000 ) }); /*Gal igniter*/ function initGal() { $("#gallery a[rel='gallery1']").colorbox({ }) ; } /*bind effects*/ function initPage() { // TRACK AND RESET HEIGHTS !!! PANEL_H["content_welcome"] = $("#content_welcome").height() ; if( PANEL_H["content_welcome"]<279 ) { PANEL_H["content_welcome"] = 279 ; } PANEL_H["content_rooms"] = $("#content_rooms").height() ; if( PANEL_H["content_rooms"]<279 ) { PANEL_H["content_rooms"] = 279 ; } PANEL_H["content_location"] = $("#content_location").height() ; if( PANEL_H["content_location"]<279 ) { PANEL_H["content_location"] = 279 ; } PANEL_H["content_reservations"] = $("#content_reservations").height() ; if( PANEL_H["content_reservations"]<279 ) { PANEL_H["content_reservations"] = 279 ; } PANEL_H["content_gallery"] = $("#content_gallery").height() ; if( PANEL_H["content_gallery"]<279 ) { PANEL_H["content_gallery"] = 279 ; } PANEL_H["content_offers"] = $("#content_offers").height() ; if( PANEL_H["content_offers"]<279 ) { PANEL_H["content_offers"] = 279 ; } $(".menu_item").click(function(){ var elem = this ; var newSuffix = $(elem).attr("id").split("_") ; newSuffix = newSuffix[1] ; if(newSuffix=="reservations") { avail('villaadele',$(elem).attr("lang")) ; } else { var oldSuffix = false ; if( LAST_CONTENT ) { oldSuffix = $(LAST_CONTENT).attr("id").split("_") ; oldSuffix = oldSuffix[1] ; } LAST_CONTENT = elem ; if( newSuffix==oldSuffix ) { return ; } var menuItem = ("#menu_"+newSuffix) ; var contentItem = ("#content_"+newSuffix) ; $(menuItem).animate( //{opacity:0}, {backgroundPosition:"0px -58px"}, 400 , function(){ //$(menuItem).css( {backgroundPosition:"0px -58px"}); $(menuItem).css( {backgroundPosition:"0px -174px"} ) if( oldSuffix ) { $("#menu_"+oldSuffix).animate( {backgroundPosition:"0px 0px"} , 400 ); /*$("#menu_"+oldSuffix).animate( {opacity:0} , 400 ,function(){ $("#menu_"+oldSuffix).css( {backgroundPosition:"0px 0px"} ); $("#menu_"+oldSuffix).animate({opacity:1},400); } );*/ } //$(menuItem).css({backgroundPosition:"0px -116px"}); $(menuItem).animate( //{opacity:1} , {backgroundPosition:"0px -116px"} , 400, function(){ togglePanels( contentItem , oldSuffix? "#content_"+oldSuffix :false ) ; } ); } ); }// Fine if newSuffix=="prenotazioni" }); // TRIGGER THE WELCOME PANEL $("#menu_welcome").click(); }; function togglePanels(p1,p2) { if( $("#page_loader").css("display")=="block" ) { $("#page_loader").slideUp(); } var h = 0 ; var pc = $("#page_content") ; if(!p2) { h = PANEL_H[ p1.replace(/#/g,"") ]+50; pc.stop().animate( {height:h}, 500, function(){ $(p1).css({opacity:0,display:"block"}); $(p1).animate( { opacity:1 }, 400 , function(){ /*if(p1=="#content_camere" ) { TIMER_ROOMS = window.setTimeout( function(){ animate_inner_images(p1) } , 4000 ) ; } else if( p1=="#content_welcome" ) { TIMER_WELCOME = window.setTimeout( function(){ animate_inner_images(p1) } , 5000 ) ; }*/ } ); } ); } else { h = PANEL_H[ p2.replace(/#/g,"") ]; $(p2).stop().animate( {opacity:0}, 400, function(){ pc.css({height:h}); h = PANEL_H[ p1.replace(/#/g,"") ]+50; pc.animate( {height:h}, 400, function(){ // CLEAR TIMEOUTS //trace("CLEAR TIMEOUTS"); //clearTimeout(TIMER_ROOMS); //clearTimeout(TIMER_WELCOME); $(p2).css({display:"none"}) ; $(p1).css({opacity:0,display:"block"}); $(p1).animate( { opacity:1 }, 400, function(){ /*if(p1=="#content_camere" ) { TIMER_ROOMS = window.setTimeout( function(){ animate_inner_images(p1) } , 4000 ) ; } else if( p1=="#content_welcome" ) { TIMER_WELCOME = window.setTimeout( function(){ animate_inner_images(p1) } , 5000 ) ; }*/ } ); } ); } ); } } function animate_inner_images(p1) { //trace("Animating "+p1) /*if( p1=="#content_camere" ) { var elem = $("#rooms_images") ; elem.stop().animate( {opacity:0}, 1000, function(){ var imgSrc = "./images/rooms_01.jpg" ; if( $(this).attr("src")==imgSrc ) { imgSrc = "./images/rooms_02.jpg" ; } $(this).attr("src" , imgSrc ) ; $(this).animate({opacity:1},1000); } ) TIMER_ROOMS = window.setTimeout( function(){ animate_inner_images(p1) } , 10000 ) ; } if( p1=="#content_welcome" ) { var elem = $("#welcome_images") ; elem.stop().animate( {opacity:0}, 1000, function(){ var imgSrc = "./images/welcome_01.jpg" ; if( $(this).attr("src")==imgSrc ) { imgSrc = "./images/welcome_02.jpg" ; } $(this).attr("src" , imgSrc ) ; $(this).animate({opacity:1},1000); } ) TIMER_WELCOME = window.setTimeout( function(){ animate_inner_images(p1) } , 10000 ) ; } */ } function trace(m) { if( window.console ) { window.console.log(m); } }