
rootElement=("onorientationchange"in window)?$(document):$(window);position=1;position_page=1;var Lungarno={body:$('body,html'),main:$('#main'),header:$('#header'),content:$('#content'),sidebar:$('#sidebar'),sidebar_nav:$('#sidebar-nav'),panel:$('#panel'),footer:$('#footer'),background:null,isReady:false,isStarted:false,browser:null,gallery:null,tracker:_gaq,getBody:function(){return $('body');},getHeader:function(){return $('#header');},getContent:function(){return $('#content');},getPanel:function(){return $('#panel');},getScroller:function(){return $('#scroller');},getSidebar:function(){return $('#sidebar');},getSidebarNav:function(){return $('#sidebar-nav');},getFooter:function(){return $('#footer');},getLaunches:function(){return $('#launches');},getGallery:function(){return $('#gallery-container').parent();},getGalleryPhoto:function(){return $('#gal-photo').parent();},init:function(){if($.cookie('intro')==null)$.cookie('intro',0,{expires:null,path:'/',domain:'.lungarnocollection.com',secure:false});Lungarno.getPage();if(Lungarno.getGallery().length>0)Lungarno.setUpGallery();$(window).bind('resize',function(){Lungarno.resizeContent();});},getPage:function(){arrContexts=[];arrContexts['it']='web';arrContexts['en']='en';arrContexts['de']='de';arrContexts['fr']='fr';$.address.init().externalChange(function(event){context=event.pathNames[0];var pathNames=event.pathNames;var language_to_set='/en/';var browser_language=(navigator.browserLanguage)?navigator.browserLanguage:navigator.language;if(browser_language.indexOf('it')!=-1)language_to_set='/it/';if(browser_language.indexOf('de')!=-1)language_to_set='/de/';if(browser_language.indexOf('fr')!=-1)language_to_set='/fr/';if(window.location.pathname=='/'&&window.location.href.indexOf('#')==-1){_gaq.push(['_trackPageview']);window.location=language_to_set;}var language=pathNames.shift();var alias=pathNames.join('/');alias=(alias!=''&&alias.indexOf('.html')!='-1')?alias:alias+'/';$.ajax({url:'/ajax-backend/get-page-from-alias.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){Lungarno.setComponents(data,alias);if(Lungarno.isStarted){}}});});$('#logo a').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewCollectionPage(alias_to_send,arrContexts[language]);$(this).parent().addClass('active');$.address.value(alias);return false;});$('#corporate-nav a:not(a.gallery,a.booking)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewMainPage(alias_to_send,arrContexts[language]);$('#service-nav li, #corporate-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#service-nav ul a').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');if($('#logo a.back').length>0){Lungarno.viewMainPageFromHotel(alias_to_send,arrContexts[language]);}else{Lungarno.viewMainPage(alias_to_send,arrContexts[language]);}
$('#service-nav li, #corporate-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#sidebar-nav > ul.common > li > a:not(a.external), #sidebar-nav ul.hotel-suites a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewSidebarPage(alias_to_send,arrContexts[language]);$('#sidebar-nav ul ul li').removeClass('active');$('#sidebar-nav ul.common > li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#sidebar-nav > ul.common > li.active > ul > li a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewSidebarPage(alias_to_send,arrContexts[language]);$(this).parent().siblings().removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#sidebar-nav ul.hotel a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewHotelPage(alias_to_send,arrContexts[language]);$('#sidebar-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#sidebar-nav ul.corporate-offers a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewCorporateOffersPage(alias_to_send,arrContexts[language]);$('#sidebar-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#sidebar-nav ul.hotel-offers a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewPageFromLaunch(alias_to_send,arrContexts[language]);$('#service-nav li, #corporate-nav li').removeClass('active');$.address.value(alias);return false;});$('#footer ul a:not(a.external)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewFooterPage(alias_to_send,arrContexts[language]);$('#sidebar-nav li, #service-nav li, #corporate-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);return false;});$('#panel a:not(p a,a[href^="http"],a#switcher,a[href^="mailto"],a.press-view,a.press-view-img,a.artdesign-view-img, a#booking-offer, a.file-download)').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewPageInsidePanel(alias_to_send,arrContexts[language]);$.address.value(alias);return false;});$('#launches a, #launch-video, #ferragamo-creations').live('click',function(){var alias=$(this).attr('href');alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');Lungarno.viewPageFromLaunch(alias_to_send,arrContexts[language]);$('#service-nav li, #corporate-nav li').removeClass('active');$.address.value(alias);return false;});$('#panel a#switcher').live('click',function(){var $width=240;if($('#panel').is('.medium'))var $width=434;if($('#panel').is('.large'))var $width=750;var $button=$(this);var $img=$(this).find('img');if($button.parent().width()!=0){$button.parent().find('*').css('opacity',0);$button.parent().find('object').hide();$button.parent().animate({width:0},500,function(){$button.css('opacity',1);$img.css('opacity',1);$img.attr('src','/assets/i/panel-switcher-open.png');});}else{$button.css('opacity',0);$button.find('img').css('opacity',0);$(this).parent().animate({width:$width},500,function(){$button.parent().find('*').css('opacity',1);$button.css('opacity',1);$img.css('opacity',1);$button.parent().find('object').show();$img.attr('src','/assets/i/panel-switcher.png');});}
return false;});$(window).load(function(){var readytimer=setInterval(function(){if(Lungarno.isReady){clearInterval(readytimer);Lungarno.loadIntro(function(){$('#overlay').animate({opacity:0},1000,function(){$(this).remove();Lungarno.showIntro(function(){Lungarno.loadBackground(function(){Lungarno.header.delay(1000).animate({top:0},800,'easeOutQuad');Lungarno.sidebar.delay(1000).animate({left:0},800,'easeOutQuad');Lungarno.footer.delay(1000).animate({bottom:0},800,'easeOutQuad');Lungarno.showBackground(1000);Lungarno.getLaunches().delay(1000).animate({opacity:1},800,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});});});});}},10);});},loadIntro:function(callback){var counter=0;$.each(['/assets/i/intro-1.jpg'],function(index,img){var image=$('<img/>').css({position:"absolute",top:0,left:0,opacity:0}).bind('load',function(e){counter=counter+1;var self=$(this);imgRatio=$(e.target).width()/$(e.target).height();Lungarno._adjustBGIntro(function(){});if(counter==1){image.css({position:'relative',opacity:1});$('#backstretch img:first').remove();callback();return false;}}).appendTo($('#backstretch'));image.attr('src',img);});},loopIntro:function(callback) {var cb=callback;if($('#backstretch img').size()>1){var $last=$('#backstretch img:last');$last.prev().css('opacity',1);$last.animate({opacity:0},1000,function(){$(this).remove();$('#backstretch img:last').css('position','relative');});setTimeout(function(){Lungarno.loopIntro(cb);},1000);}else{clearTimeout(introtimeout);cb();}},showIntro:function(callback){var cb=callback;introtimeout=setTimeout(function(){Lungarno.loopIntro(cb);},2000);},viewMainPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();Lungarno.getPanel().find('object').remove();Lungarno.panel.stop(true,true).animate({opacity:0},500);Lungarno.panel.find('*').stop(true,true).animate({opacity:0},500);if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
Lungarno.sidebar_nav.animate({opacity:0},500,function(){$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-main-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);Lungarno.sidebar_nav.html(data.sidebar);Lungarno.panel.css('width',240).html(data.panel);if(data.map!='')$(data.map).appendTo(Lungarno.content);if(data.launches!='')Lungarno.setLaunches(data.launches);Lungarno.footer.html(data.footer);Lungarno.resizeContent();Lungarno.loadBackground(function(){if(data.sidebar!=''){Lungarno.content.removeClass('no-bg');Lungarno.sidebar_nav.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
if(!data.is_home){if(data.map!=''){if($('#collection-map').length>0){$('#collection-map').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}}else{Lungarno.panel.find('*').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}}
Lungarno.showBackground(0);Lungarno.getLaunches().animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});}});});},viewCorporateOffersPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();$.ajax({url:'/ajax-backend/get-corporate-offers-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.panel.html(data.panel);Lungarno.resizeContent();Lungarno.loadBackground(function(){Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.showBackground(0);});}});},viewSidebarPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();Lungarno.getPanel().find('object').remove();Lungarno.panel.find('*').animate({opacity:0},500);Lungarno.panel.stop(true,true).animate({opacity:0},500,function(){$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-sidebar-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.sidebar_nav.html(data.sidebar);Lungarno.panel.css('width',240).html(data.panel);Lungarno.resizeContent();Lungarno.loadBackground(function(){Lungarno.panel.find('*:not(object,embed,param)').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.showBackground(0);});}});});},viewFooterPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
$.ajax({url:'/ajax-backend/get-footer-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);$('#logo-sidebar').html('<img alt="Lungarno Collection" src="assets/i/logo-collection.png" id="corporate-logo" style="position: absolute; top: 0px; left: 0px;">');Lungarno.sidebar_nav.html('').css('opacity',0);Lungarno.panel.html(data.panel).css('width',240).css('opacity',1);Lungarno.footer.html(data.footer);Lungarno.resizeContent();Lungarno.loadBackground(function(){Lungarno.showBackground(0);});}});},viewPageInsidePanel:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();Lungarno.panel.find('*').animate({opacity:0},500);Lungarno.panel.stop(true,true).animate({opacity:0},500,function(){$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-inside-panel-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.sidebar_nav.html(data.sidebar);Lungarno.panel.html(data.panel);Lungarno.resizeContent();Lungarno.loadBackground(function(){Lungarno.panel.find('*').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.showBackground(0);});}});});},viewHotelPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-hotel-page.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);Lungarno.sidebar_nav.html('');Lungarno.panel.css('width',240).html('');if(data.launches!='')Lungarno.setLaunches(data.launches);Lungarno.footer.html(data.footer);if(Lungarno.getGallery().length>0)Lungarno.getGallery().parent().remove();Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.setHotelSidebar(data.hotel_name,data.logo);Lungarno.resizeContent();Lungarno.loadBackground(function(){Lungarno.slideHotelIn();Lungarno.showBackground(0);Lungarno.getLaunches().animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});}});},viewHotelPageFromFlash:function(alias){var alias=alias;alias=alias.replace(/http:\/\/www.lungarnocollection.com/i,'');alias_to_send=alias.replace(/\/(it|en|de|fr)\//i,'');$('#sidebar-nav li').removeClass('active');$(this).parent().addClass('active');$.address.value(alias);Lungarno.startPageLoading();Lungarno.removeLaunches();if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-hotel-page.php?alias='+alias_to_send+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias_to_send);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);Lungarno.sidebar_nav.html('');Lungarno.panel.css('width',240).html('');Lungarno.footer.html(data.footer);if(Lungarno.getGallery().length>0)Lungarno.getGallery().parent().remove();Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.setHotelSidebar(data.hotel_name,data.logo);Lungarno.loadBackground(function(){Lungarno.slideHotelIn();Lungarno.showBackground(0);});}});},viewCollectionPage:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();$.ajax({url:'/ajax-backend/get-collection-page-from-hotel.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);Lungarno.sidebar_nav.html('');$('#panel').removeClass('medium');Lungarno.panel.animate({opacity:0},1000,function(){Lungarno.panel.css('width',300).html('');if(data.map!=''){$(data.map).appendTo(Lungarno.content);if(Lungarno.browser.webkit||Lungarno.browser.msie){setTimeout(function(){var so=new SWFObject("/assets/i/collection-map-"+context+".swf","coll-map","2560","1440","7","");so.addParam("wmode","transparent");so.write("coll-map");$(window).trigger("resize");},900);}}});Lungarno.footer.html(data.footer);if(data.launches!='')Lungarno.setLaunches(data.launches);if(Lungarno.getGallery().length>0)Lungarno.getGallery().parent().remove();Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.setCorporateSidebar();Lungarno.loadBackground(function(){Lungarno.slideCorporateIn(data.sidebar);Lungarno.showBackground(0);$('#collection-map').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.getLaunches().animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});}});},viewMainPageFromHotel:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();Lungarno.getPanel().find('object').remove();$.ajax({url:'/ajax-backend/get-main-page-from-hotel.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);Lungarno.sidebar_nav.html(data.sidebar);$('#panel').removeClass('medium');Lungarno.panel.find('*').animate({opacity:0},1000);Lungarno.panel.animate({opacity:0},1000,function(){Lungarno.panel.css('width',240);Lungarno.getPanel().html(data.panel);Lungarno.resizeContent();});Lungarno.footer.html(data.footer);if(data.launches!='')Lungarno.setLaunches(data.launches);if(Lungarno.getGallery().length>0)Lungarno.getGallery().parent().remove();Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.setCorporateSidebar();Lungarno.loadBackground(function(){Lungarno.slideCorporateInService();if(data.sidebar!=''){Lungarno.content.removeClass('no-bg');Lungarno.sidebar_nav.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
Lungarno.panel.find('*:not(object, embed, param)').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.showBackground(0);Lungarno.getLaunches().animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});}});},viewPageFromLaunch:function(alias){Lungarno.startPageLoading();Lungarno.removeLaunches();Lungarno.getPanel().find('object').remove();if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
Lungarno.panel.find('*').animate({opacity:0},500);Lungarno.panel.stop(true,true).animate({opacity:0},500);Lungarno.sidebar_nav.stop(true,true).animate({opacity:0},500,function(){$('#panel').removeClass('medium');$.ajax({url:'/ajax-backend/get-page-from-launch.php?alias='+alias+'&context='+arrContexts[context],dataType:'json',success:function(data,textStatus,xhr){$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);$('#logo-sidebar img').attr('src',data.logo).attr('alt',data.hotel_name).attr('id','');Lungarno.sidebar_nav.html(data.sidebar);Lungarno.panel.css('width',240).html(data.panel);if(data.map!='')$(data.map).appendTo(Lungarno.content);Lungarno.footer.html(data.footer);if(data.launches!='')Lungarno.setLaunches(data.launches);if(Lungarno.getGallery().length>0)Lungarno.getGallery().remove();Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.resizeContent();Lungarno.loadBackground(function(){if(data.sidebar!=''){Lungarno.content.removeClass('no-bg');Lungarno.sidebar_nav.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
if(data.panel!=''){Lungarno.panel.find('*:not(object, embed, param)').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
if($('#collection-map').length>0){$('#collection-map').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
Lungarno.showBackground(0);Lungarno.getLaunches().animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});});}});});},startPageLoading:function(){if(typeof background_timer!='undefined')clearInterval(background_timer);$('<div id="overlay-loading" style="position:absolute;top:0;left:0;width:100%;height:100%;z-index:100000;" />').css('opacity',0).appendTo(Lungarno.getBody());$('<div id="loading-page" />').css({position:'absolute',top:(($(window).height()-120)/2)-20,left:($(window).width()/2)-20,width:40,height:40,backgroundImage:"url('/assets/i/loading-page.png')",zIndex:2}).appendTo(Lungarno.getBody());position_page=1;timer_page=setInterval('Lungarno.loadingPage()',150);},stopPageLoading:function(){$('#overlay-loading, #loading-page').remove();},startGalleryLoading:function(){if(typeof timer_gallery!='undefined')clearInterval(timer_gallery);$('<div id="loading-page" />').css({position:'absolute',top:((Lungarno.getGalleryPhoto().height())/2)-20,left:(Lungarno.getGalleryPhoto().width()/2)-20,width:40,height:40,backgroundImage:"url('/assets/i/loading-page.png')",zIndex:2}).appendTo(Lungarno.getGalleryPhoto());position_page=1;timer_gallery=setInterval('Lungarno.loadingPage()',150);},stopGalleryLoading:function(){clearInterval(timer_gallery);$('#loading-page').remove();},setHotelSidebar:function(hotel_name,logo){hotel_logo=$('<img id="hotel-logo" src="'+logo+'" alt="'+hotel_name+'">').css({position:'absolute',top:0,left:'-170px'}).appendTo(Lungarno.content);},slideHotelIn:function(){$('#logo-sidebar').animate({left:'-170px'},1000,'easeOutQuad');Lungarno.getSidebarNav().animate({left:'-170px'},1000,'easeOutQuad');$('#hotel-logo').animate({left:0},1000,'easeOutQuad',function(){$('#logo-sidebar').css('left',0).empty();hotel_logo.appendTo($('#logo-sidebar'));Lungarno.getSidebarNav().css({opacity:0,left:0},1000);});},setCorporateSidebar:function(){corporate_logo=$('<img id="corporate-logo" src="/assets/i/logo-collection.png" alt="Lungarno Collection">').css({position:'absolute',top:0,left:'-170px'}).appendTo(Lungarno.content);},slideCorporateIn:function(sidebar){$('#logo-sidebar').animate({left:'-170px'},1000,'easeOutQuad');Lungarno.getSidebarNav().animate({left:'-170px'},1000,'easeOutQuad');$('#corporate-logo').animate({left:0},1000,'easeOutQuad',function(){$('#logo-sidebar').css('left',0).empty();corporate_logo.appendTo($('#logo-sidebar'));corporate_logo.attr('id','');Lungarno.content.removeClass('no-bg');Lungarno.getSidebarNav().html(sidebar).css({opacity:1,left:0},1000);});},slideCorporateInService:function(){$('#logo-sidebar').animate({left:'-170px'},1000,'easeOutQuad');Lungarno.getSidebarNav().animate({left:'-170px'},1000,'easeOutQuad',function(){Lungarno.getSidebarNav().css('opacity',1);});$('#corporate-logo').animate({left:0},1000,'easeOutQuad',function(){$('#logo-sidebar').css('left',0).empty();corporate_logo.appendTo($('#logo-sidebar'));});Lungarno.getSidebarNav().animate({left:0},1000,'easeOutQuad');},setComponents:function(data,alias){Lungarno.removeGallery();Lungarno.removeLaunches();if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},500,function(){$(this).remove();});}
$.address.title(data.pagetitle);if(alias=='/'){Lungarno.trackPage('/'+context+'/');}else{Lungarno.trackPage('/'+context+'/'+alias);}
Lungarno.setBackground(data.backgrounds);Lungarno.header.html(data.header);$('#logo-sidebar img').attr('src',data.logo).attr('alt',data.hotel_name);Lungarno.sidebar_nav.html(data.sidebar).css('opacity',0);Lungarno.panel.html(data.panel).css('opacity',0);if(data.map!=''){$(data.map).appendTo(Lungarno.content);if(Lungarno.browser.webkit||Lungarno.browser.msie){setTimeout(function(){var so=new SWFObject("/assets/i/collection-map-"+context+".swf","coll-map","2560","1440","7","");so.addParam("wmode","transparent");so.write("coll-map");$(window).trigger("resize");},900);}}
if(data.launches!='')Lungarno.setLaunches(data.launches);if(Lungarno.isStarted)Lungarno.getLaunches().delay(1000).animate({opacity:1},800);Lungarno.gallery=data.gallery;Lungarno.setUpGallery();Lungarno.footer.html(data.footer);Lungarno.resizeContent();if(data.sidebar!=''){Lungarno.content.removeClass('no-bg');Lungarno.sidebar_nav.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
if(data.panel!=''){Lungarno.panel.animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
if($('#collection-map').length>0){$('#collection-map').animate({opacity:1},1000,function(){if(Lungarno.browser.msie){this.style.removeAttribute('filter');}});}
Lungarno.isReady=true;},updateGalleryCategory:function(){Lungarno.startGalleryLoading();$('#gal-prev, #gal-next').remove();$('#gal-photos-slider').css('left',0);if($('#gal-photos-slider img').size()>1){if($('#gal-pagination ul li').size()>0&&$('#gal-pagination ul li.active').length==0){$('#gal-pagination ul li:first').addClass('active');$('#gal-photo img:first').parent().addClass('active');$('#gal-photo-caption').text($('#gal-photo img:first').attr('alt'));}
if($('#gal-navigation ul li').size()>0&&$('#gal-navigation ul li.active').length==0){$('#gal-navigation ul:first li:first').addClass('active');}
$totalWidth=0;$loaded=0;$('#gal-photos-slider img').each(function(index,image){$('<img class="tmp_image">').css({visibility:'hidden',position:'absolute',top:'0',left:'0'}).load(function(){$totalWidth=$totalWidth+$(this).width();$loaded++;if($loaded==$('#gal-photos-slider img').size()){$first_width=$('.tmp_image:first').width();$('.tmp_image').remove();$('#gal-photos-slider').css('width',$totalWidth);$button_width=(980-$first_width)/2;$('#gal-photos-slider').css('left',$button_width);$btn_prev=$('<a id="gal-prev" title="Previous"><img src="/assets/i/gal-arrow-prev.png"></a>').appendTo('#gal-photo').css({width:$button_width,visibility:'visible'}).click(function(){Lungarno.showPrev();});$btn_next=$('<a id="gal-next" title="Next"><img src="/assets/i/gal-arrow-next.png"></a>').appendTo('#gal-photo').css({width:$button_width,visibility:'visible'}).click(function(){Lungarno.showNext();});$('#gal-pagination li a').click(function(){Lungarno.goTo($('#gal-pagination li a').index($(this)));return false;});Lungarno.stopGalleryLoading();$('#gal-photo-caption').fadeIn(500);$('#gal-pagination ul').fadeIn(500);$('#gal-photos-slider').fadeIn(500);$('#gal-next,#gal-prev').fadeIn(500);}}).attr('src',$(this).attr('src')).appendTo('body');});}},setUpGallery:function(){if($('#gal-navigation ul li').size()>0&&$('#gal-navigation ul li.active').length==0){$('#gal-navigation ul li:first').addClass('active');}
if($('#corporate-nav a.gallery').attr("href").indexOf('#')==-1)$('#corporate-nav a.gallery').attr("href","#gallery-container");$('#corporate-nav a.gallery').unbind('mouseenter').bind('mouseenter',function(){$(this).fancybox({'width':980,'height':630,'padding':0,'margin':0,'autoDimensions':false,'overlayOpacity':1,'overlayColor':'#000','scrolling':'no','showCloseButton':false,'hideOnOverlayClick':false,'titleShow':false,'onClosed':function(){Lungarno.getGallery().parent().remove();},'onStart':function(){$(Lungarno.gallery).appendTo(Lungarno.getBody());$('#gal-close').unbind('click').bind('click',function(){$.fancybox.close();return false;});$('#gal-navigation a').unbind('click').bind('click',function(){separator=$(this).attr('id').indexOf('-')+1;gal_id=$(this).attr('id').substring(separator);clicked=$(this);$.ajax({url:'/ajax-backend/get-gallery-new.php?id='+gal_id,dataType:'json',success:function(data,textStatus,xhr){$('#gal-photo-caption').fadeOut(500);$('#gal-next,#gal-prev').fadeOut(500);$('#gal-pagination ul').fadeOut(500);$('#gal-photos-slider').fadeOut(500,function(){$('#gal-photos-slider').html(data.photos);$('#gal-pagination ul').html(data.pagination);$('#gal-navigation ul li').removeClass('active');clicked.parent().addClass('active');Lungarno.updateGalleryCategory();});}});return false;});$('#gal-thumbs a').unbind('click').bind('click',function(evt){Lungarno.loadImage($(this));return false;});$('#gal-photo-caption').hide();$('#gal-next,#gal-prev').hide();$('#gal-pagination ul').hide();$('#gal-photos-slider').hide();Lungarno.updateGalleryCategory();}});return false;});},viewMainGallery:function(){if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},1000);}
Lungarno.getGallery().animate({bottom:20},1000,'easeInOutQuad');Lungarno.getHeader().animate({top:-(Lungarno.getHeader().outerHeight())},1000,'easeInOutQuad');Lungarno.getSidebar().animate({left:-170},1000,'easeInOutQuad');Lungarno.getPanel().fadeOut(1000);Lungarno.getLaunches().fadeOut(1000);Lungarno.getFooter().animate({bottom:-(Lungarno.getFooter().outerHeight())},1000,'easeInOutQuad');},viewHotelGallery:function(){if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:0},1000);}
Lungarno.getGallery().animate({bottom:20},1000,'easeInOutQuad');Lungarno.getHeader().animate({top:-(Lungarno.getHeader().outerHeight())},1000,'easeInOutQuad');Lungarno.getSidebar().animate({left:-170},1000,'easeInOutQuad');Lungarno.getPanel().fadeOut(1000);Lungarno.getLaunches().fadeOut(1000);Lungarno.getFooter().animate({bottom:-(Lungarno.getFooter().outerHeight())},1000,'easeInOutQuad');},closeGallery:function(){if($('#collection-map').length>0){$('#collection-map').stop(true,true).animate({opacity:1},1000);}
Lungarno.getGallery().animate({bottom:-125},1000,'easeInOutQuad');Lungarno.getHeader().animate({top:0},1000,'easeInOutQuad');Lungarno.getSidebar().animate({left:0},1000,'easeInOutQuad');Lungarno.getPanel().fadeIn(1000);Lungarno.getLaunches().fadeIn(1000);Lungarno.getFooter().animate({bottom:0},1000,'easeInOutQuad');},goTo:function(index){var $active=$('#gal-photos-slider .active');var $toshow=$($('#gal-photos-slider div')[index]);var $toshow_width=parseInt($toshow.find('img').width());var $button_width=parseInt((980-$toshow_width)/2);$btn_next.animate({width:$button_width},300);$btn_prev.animate({width:$button_width},300);$('#gal-photos-slider').animate({left:-($toshow.position().left-$button_width)},300,function(){$active.removeClass('active');$toshow.addClass('active');$('#gal-photo-caption').text($toshow.find('img').attr('alt'));var index=$('#gal-photos-slider img').index($toshow.find('img'));$('#gal-pagination li').removeClass('active');$($('#gal-pagination li')[index]).addClass('active');});},showPrev:function(){var $active=$('#gal-photos-slider .active');if($active.prev().length==0)return;var $prev=$active.prev();var $prev_width=parseInt($prev.find('img').width());var $prev_button_width=$button_width;var $button_width=parseInt((980-$prev_width)/2);$btn_next.animate({width:$button_width},300);$btn_prev.animate({width:$button_width},300);$('#gal-photos-slider').animate({left:-($prev.position().left-$button_width)},300,function(){$active.removeClass('active');$prev.addClass('active');$('#gal-photo-caption').text($prev.find('img').attr('alt'));var index=$('#gal-photos-slider img').index($prev.find('img'));$('#gal-pagination li').removeClass('active');$($('#gal-pagination li')[index]).addClass('active');});},showNext:function(){var $active=$('#gal-photos-slider .active');if($active.next().length==0)return;var $next=$active.next();var $next_width=parseInt($next.find('img').width());var $prev_button_width=$button_width;var $button_width=parseInt((980-$next_width)/2);$btn_next.animate({width:$button_width},300);$btn_prev.animate({width:$button_width},300);$('#gal-photos-slider').animate({left:-($next.position().left-$button_width)},300,function(){$active.removeClass('active');$next.addClass('active');$('#gal-photo-caption').text($next.find('img').attr('alt'));var index=$('#gal-photos-slider img').index($next.find('img'));$('#gal-pagination li').removeClass('active');$($('#gal-pagination li')[index]).addClass('active');});},loading:function(){if(position==6){$('#loading').css('background-position','0 0');position=1;}else{$('#loading').css('background-position','0 '+-position*40+'px');position++;}},loadingPage:function(){if(position_page==6){$('#loading-page').css('background-position','0 0');position_page=1;}else{$('#loading-page').css('background-position','0 '+-position_page*40+'px');position_page++;}},loadImage:function(obj){if(typeof timer!='undefined')clearInterval(timer);$('#loading').remove();$to_remove=$('#backstretch img');$('<div id="loading" />').css({position:'absolute',top:(($(window).height()-120)/2)-20,left:($(window).width()/2)-20,width:40,height:40,backgroundImage:"url('/assets/i/loading-page.png')",zIndex:2}).appendTo('#backstretch');position=1;timer=setInterval('Lungarno.loading()',100);img=$('<img class="gal-current" />').css({position:"absolute",top:0,left:0,opacity:0}).bind("load",function(e){$('#loading').css('z-index','0').remove();clearTimeout(timer);var self=$(this);imgRatio=$(e.target).width()/$(e.target).height();obj.parent().siblings().find('a').removeClass('active');obj.addClass('active');Lungarno._adjustBGGallery(function(){self.animate({opacity:1},500,function(){self.css('position','relative');self.removeClass('gal-current');$to_remove.remove();if(typeof callback=="function")callback();});});}).appendTo($('#backstretch'));img.attr("src",obj.attr('href'));$(window).resize(Lungarno._adjustBGGallery);},_adjustBGIntro:function(fn){try{bgCSS={left:0,top:0}
bgWidth=rootElement.width();bgHeight=bgWidth/imgRatio;if(bgHeight>=rootElement.height()){bgOffset=(bgHeight-rootElement.height())/2;bgCSS={top:"-"+bgOffset+"px"};}else{bgHeight=rootElement.height();bgWidth=bgHeight*imgRatio;bgOffset=(bgWidth-rootElement.width())/2;bgCSS={left:"-"+bgOffset+"px"};}
if($("#backstretch img").length){$("#backstretch img").width(bgWidth).height(bgHeight).css(bgCSS);}else{$("#backstretch img").width(bgWidth).height(bgHeight).css(bgCSS);}}catch(err){}
if(typeof fn=="function")fn();},_adjustBGGallery:function(fn){try{bgCSS={left:0,top:0}
bgWidth=rootElement.width();bgHeight=bgWidth/imgRatio;if(bgHeight>=rootElement.height()){bgOffset=(bgHeight-rootElement.height())/2;}else{bgHeight=rootElement.height();bgWidth=bgHeight*imgRatio;bgOffset=(bgWidth-rootElement.width())/2;bgCSS={left:"-"+bgOffset+"px"};}
if($("#backstretch img.gal-current").length){$("#backstretch img.gal-current").width(bgWidth).height(bgHeight).css(bgCSS);}else{$("#backstretch img").width(bgWidth).height(bgHeight).css(bgCSS);}}catch(err){}
if(typeof fn=="function")fn();},resizeContent:function(){var content_height=Lungarno.body.height()-(Lungarno.header.outerHeight()+Lungarno.footer.outerHeight());Lungarno.content.css('height',content_height);$.each([Lungarno.sidebar,Lungarno.panel],function(index,el){$(el).css('height',content_height-(parseInt($(el).css('padding-top'))+parseInt($(el).css('padding-bottom'))));});if($('#launches').length>0)$('#launches').css('bottom',Lungarno.footer.outerHeight()-.5);if($('#collection-map').length>0)$('#collection-map').css('height',content_height-(parseInt($('#collection-map').css('padding-top'))+parseInt($('#collection-map').css('padding-bottom'))));Lungarno.sidebar_nav.css('height',Lungarno.sidebar.height()-170);Lungarno.getScroller().css('height',Lungarno.panel.height());Lungarno.resizeScroller();},setBackground:function(images){var tmp_images=eval(images);var images=[];if(tmp_images.length==1){var images=tmp_images;}else{$.each(tmp_images,function(index,value){if(value.active!=undefined&&value.active=='1'){images.push(value);}});}
Lungarno.background=images;},showBackground:function(delay){var modulus=($(".bg-mask img").height()%2);var offset=(modulus!=0)?0:1;mask.delay(delay).animate({height:'100%'},1000,'easeInOutQuad',function(){mask.css({top:0,left:0,bottom:'auto',width:'auto',height:'auto',zIndex:'-9999'});$(".bg-mask img").css({position:'relative',top:($.browser.webkit||($.browser.msie&&parseInt($.browser.version)<9))?-Math.round(bgOffset):-(bgOffset),bottom:'auto'});$('#backstretch').remove();mask.attr('id','backstretch').removeClass('bg-mask');Lungarno.stopPageLoading();if(Lungarno.background.length>1)Lungarno.rotateBackgrounds();});},rotateBackgrounds:function(){background_timer=setInterval(function(){Lungarno.fadeBackground();},6000);},fadeBackground:function(){var $current_index=null;for(var i=0;i<Lungarno.background.length;i++){if(Lungarno.background[i].file==$('#backstretch img').attr('src')){$current_index=i;break;}}
var $to_remove=$('#backstretch img');$to_remove=$('#backstretch img').removeClass('current');var $to_show=(Lungarno.background[$current_index+1]==null)?Lungarno.background[0].file:Lungarno.background[$current_index+1].file;img=$('<img class="current" />').css({position:"absolute",top:0,left:0,opacity:0}).bind("load",function(e){var self=$(this);imgRatio=$(e.target).width()/$(e.target).height();Lungarno._adjustRotationBG(function(){self.animate({opacity:1},2000,function(){self.css('position','relative');$to_remove.remove();if(typeof callback=="function")callback();});});}).appendTo('#backstretch');img.attr("src",$to_show);$(window).resize(Lungarno._adjustRotationBG);},loadBackground:function(callback){var bg=Lungarno.background[0].file;$to_remove=$('#backstretch > img');mask=$('<div class="bg-mask" />').css({width:'100%',height:0,overflow:'hidden',position:'fixed',bottom:0}).prependTo(Lungarno.getBody());var img=$('<img />').css({position:'absolute',bottom:0,left:0,display:'block'}).bind("load",function(e){$('#loading-page').css('z-index','0').remove();if(typeof timer_page!='undefined')clearTimeout(timer_page);var self=$(this);imgRatio=$(e.target).width()/$(e.target).height();Lungarno._adjustBG(function(){callback();});}).appendTo(mask);img.attr("src",bg);$(window).resize(Lungarno._adjustBG);},_adjustBG:function(fn){try{bgCSS={left:0,top:0}
bgCSSMask={left:0,top:0}
bgWidth=rootElement.width();bgHeight=bgWidth/imgRatio;if(bgHeight>=rootElement.height()){bgOffset=(bgHeight-rootElement.height())/2;bgCSS={top:"-"+bgOffset+"px"};bgCSSMask={bottom:"-"+bgOffset+"px"};}else{bgHeight=rootElement.height();bgWidth=bgHeight*imgRatio;bgOffset=(bgWidth-rootElement.width())/2;bgCSS={left:"-"+bgOffset+"px"};bgCSSMask={left:"-"+bgOffset+"px"};}
if($(".bg-mask").length==0)$("#backstretch img").width(bgWidth).height(bgHeight).css(bgCSS);if($(".bg-mask").length>0)$(".bg-mask img").width(bgWidth).height(bgHeight).css(bgCSSMask);}catch(err){}
if(typeof fn=="function")fn();},_adjustRotationBG:function(fn){try{bgCSS={left:0,top:0}
bgCSSMask={left:0,top:0}
bgWidth=rootElement.width();bgHeight=bgWidth/imgRatio;if(bgHeight>=rootElement.height()){bgOffset=(bgHeight-rootElement.height())/2;bgCSS={top:"-"+bgOffset+"px"};bgCSSMask={bottom:"-"+bgOffset+"px"};}else{bgHeight=rootElement.height();bgWidth=bgHeight*imgRatio;bgOffset=(bgWidth-rootElement.width())/2;bgCSS={left:"-"+bgOffset+"px"};bgCSSMask={left:"-"+bgOffset+"px"};}
$("#backstretch img.current").width(bgWidth).height(bgHeight).css(bgCSS);}catch(err){}
if(typeof fn=="function")fn();},resizeScroller:function(){if(Lungarno.getScroller().length==0)return;Lungarno.getScroller().jScrollPane({verticalGutter:12,animateScroll:true,autoReinitialise:true,enableKeyboardNavigation:false});var api=Lungarno.getScroller().data('jsp');},removeGallery:function(){if(Lungarno.getGallery().length>0){Lungarno.getGallery().remove();}},removeLaunches:function(){if(Lungarno.getLaunches().length>0){Lungarno.getLaunches().animate({opacity:0},500,function(){Lungarno.getLaunches().remove();});}},setLaunches:function(launches){$(launches).css('opacity',0).appendTo(Lungarno.getBody());},trackPage:function(alias){setTimeout(function(){_gaq.push(['_trackPageview',alias])},500);},readcookie:function(name){var re=new RegExp("(?:^| )"+name+"=([^;]*)","i");var matches=document.cookie.match(re);return matches&&matches.length==2?matches[1]:null;},savecookie:function(name,value,days){var date=new Date;date.setTime(date.getTime()+(typeof days!="undefined"?days:3)*24*60*60*1000);var expires="; expires="+date.toGMTString();document.cookie=name+("="+value+expires+"; path=/; domain="+document.domain);}}
$(document).ready(function(){Lungarno.browser=$.browser;Lungarno.init();});
