var headerImageDir="/images/header/";var pages=new Array(new Array("","header_start.jpg","naviStartseite",true),new Array("speisekarte","header_speisekarte.jpg","naviSpeisekarte",false),new Array("ueber","header_hh.jpg","naviUeber",false),new Array("raum","header_raum.jpg","naviRaum",false),new Array("kontakt","header_kontakt.jpg","naviKontakt",false));var initCall=true;var page=-1;var fadingDelay=100;var alle_ausgeblendet=false;var html_geladen=false;var new_html="";var load_header=false;var animating=false;var animating_header=false;var animating_content=false;var animating_abendkarte=false;var bildelements="";var bildelementsCount=0;var bildcounter=0;var textelements="";var textelementsCount=0;var textcounter=0;var abendkarteOpen=false;var newsOpen=false;$(document).ready(function(){if(window.location.hash!=""){switch(window.location.hash){case"#/startseite":openPage(0);break;case"#/speisekarte":openPage(1);break;case"#/ueber":openPage(2);break;case"#/restaurant":openPage(3);break;case"#/kontakt":openPage(4);break;default:openPage(0);}}else{switch(window.location.pathname){case"/homepage":openPage(0);break;case"/speisekarte":openPage(1);break;case"/ueber":openPage(2);break;case"/restaurant":openPage(3);break;case"/kontakt":openPage(4);break;default:openPage(0);}}});function headerImageLoaded(){if(load_header){load_header=false;var images=$(".backgroundImage");if(initCall){$(images[0]).fadeIn(2000);$("#logo").fadeIn(1200,function(){if($("#abendkarte").size()>0){$("#abendkarte").fadeIn(1000,function(){$("#languages").css("display","block");$("#navigation").fadeIn(2000);if(page==0){openNews();}else{animating_header=false;}if(html_geladen){if(initCall&&page==0){animateItIn();}else{$("#content").html(new_html);animateItIn();}}});}else{$("#languages").css("display","block");$("#navigation").fadeIn(2000);if(page==0){openNews();}else{animating_header=false;}if(html_geladen){if(initCall&&page==0){animateItIn();}else{$("#content").html(new_html);animateItIn();}}}});}else{if(images.length==2){$(images[1]).fadeIn(3000);$(images[0]).fadeOut(3000,function(){$(images[0]).remove();if(page==0){openNews();}else{animating_header=false;if(!animating_content&&!animating_header){animating=false;}}});}}}}function openPage(pageParam){if(!animating&&(pageParam>=0)&&(pageParam<pages.length)){if(pageParam!=page){animating=true;page=pageParam;var info=pages[page];alle_ausgeblendet=false;html_geladen=false;new_html="";if(!initCall){animating_content=true;animateItOut();}else{alle_ausgeblendet=true;}$(".navi").removeClass("active");$("#"+info[2]).addClass("active");if(newsOpen){hideNews();unloadNews();}if(abendkarteOpen){closeAbendkarte();}animating_header=true;load_header=true;$("#backgroundImageWrapper").append('<img src="'+url_root+headerImageDir+info[1]+'" class="backgroundImage" style="display:none;" onload="headerImageLoaded(); return false;"/>');$.ajax({type:"GET",url:url_root+info[0],success:function(html){new_html=html;html_geladen=true;if(!initCall&&alle_ausgeblendet){$("#content").html(new_html);animateItIn();}}});}}}function openNews(){newsOpen=true;$("#news").css("opacity","0");$("#news").css("display","block");$("#news").animate({opacity:"1"},1000,function(){animating_header=false;if(!animating_content&&!animating_header){animating=false;}$("#news").bind({mouseover:function(){$("#newsBG").css("background-color","#B2002E");$("#newsBG").css("opacity",".90");$("#newsopenicon").css("background-position","0 -25px");$("#newscloseicon").css("background-position","0 -25px");},mouseout:function(){$("#newsBG").css("background-color","#000000");$("#newsBG").css("opacity",".55");$("#newsopenicon").css("background-position","0 0");$("#newscloseicon").css("background-position","0 0");}});});}function hideNews(){$("#news").animate({opacity:"0"},1000,function(){$("#news").css("display","none");newsOpen=false;});}function openAbendkarte(){if($("#abendkarte").size()>0&&!animating_abendkarte){animating_abendkarte=true;abendkarteOpen=true;var hoehe=$("#abendkarteContent").height()+110-612;$("#bubble").animate({top:[hoehe+"px","easeOutCubic"]},1000,function(){$("#abendkarteContent").css("display","block");$("#openAbendkarte").css("display","none");$("#closeAbendkarte").css("display","block");animating_abendkarte=false;});}}function closeAbendkarte(){if($("#abendkarte").size()>0&&!animating_abendkarte){animating_abendkarte=true;$("#abendkarteContent").css("display","none");$("#bubble").animate({top:["-518px","easeInCubic"]},1000,function(){$("#closeAbendkarte").css("display","none");$("#openAbendkarte").css("display","block");abendkarteOpen=false;animating_abendkarte=false;});}}function animateItOut(){var list=$(".animationBox");if(list.length>0){var i=list.length;var sortedlist=list.tsort("",{attr:"tabindex"});var interval=setInterval(function(){if(i==0){sortedlist.eq(i).fadeOut("slow",function(){alle_ausgeblendet=true;if(html_geladen){if(initCall&&page==0){animateItIn();}else{$("#content").html(new_html);animateItIn();}}});sortedlist.eq(i).remove();alle_ausgeblendet=true;}else{sortedlist.eq(i).fadeOut("slow");sortedlist.eq(i).remove();}i--;if(i<0){clearInterval(interval);}},fadingDelay);}else{alle_ausgeblendet=true;if(html_geladen){if(initCall&&page==0){animateItIn();}else{$("#content").html(new_html);animateItIn();}}}}function calculateHeight(sortedlist){var j=0;var hoehe=0;while(j<sortedlist.length){var topvalue=$(sortedlist[j]).css("top");topvalue=topvalue.substring(0,topvalue.length-2);var heightvalue=$(sortedlist[j]).css("height");heightvalue=heightvalue.substring(0,heightvalue.length-2);var paddingtop=$(sortedlist[j]).css("padding-top");paddingtop=paddingtop.substring(0,paddingtop.length-2);var paddingbottom=$(sortedlist[j]).css("padding-bottom");paddingbottom=paddingbottom.substring(0,paddingbottom.length-2);var v=parseInt(topvalue)+parseInt(heightvalue)+parseInt(paddingtop)+parseInt(paddingbottom);if(v>hoehe){hoehe=v;}j++;}return hoehe;}function animateItIn(){var list=$(".animationBox");if(list.length>0){var i=0;var sortedlist=list.tsort("",{attr:"tabindex"});var hoehe=calculateHeight(list);$("#content").css("height",hoehe+"px");var interval=setInterval(function(){sortedlist.eq(i).animate({opacity:"1"});i++;if(i>=list.length){clearInterval(interval);animating_content=false;if(!animating_content&&!animating_header){animating=false;}if(initCall&&page==0){openAbendkarte();}if(initCall){initCall=false;}}},fadingDelay);}else{animating_content=false;if(!animating_content&&!animating_header){animating=false;}if(initCall&&page==0){openAbendkarte();}if(initCall){initCall=false;}}}function loadNews(token){$.ajax({type:"GET",url:url_root+"news",data:"token="+token,success:function(html){$("#newscontent").html(html);$("#newsinnerContent").css("display","none");$("#newsinnerClose").css("display","block");$("#newscontent").slideDown("slow",function(){});}});}function unloadNews(){$("#newsinnerContent").css("display","block");$("#newsinnerClose").css("display","none");$("#newscontent").slideUp("slow",function(){$("#newscontent").html("");});}
