window.dhtmlHistory.create({toJSON:JSON.encode,fromJSON:JSON.decode});window.addEvent("load",function(){dhtmlHistory.initialize();dhtmlHistory.addListener(dhtmlListener)});window.addEvent("resize",function(){var a=((window.getHeight()-739)/2).toInt();if(a<0){a=0}$("wrapper").setStyle("padding-top",a)});function addDOMLoadEvent(f){if(!window.__ADLE){var n=function(){if(arguments.callee.d){return}arguments.callee.d=true;if(window.__ADLET){clearInterval(window.__ADLET);window.__ADLET=null}for(var i=0;i<window.__ADLE.length;i++){window.__ADLE[i]()}window.__ADLE=null};if(document.addEventListener){document.addEventListener("DOMContentLoaded",n,false);
/*@cc_on @*/
/*@if (@_win32)document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");var s=document.getElementById("__ie_onload");s.onreadystatechange=function(){if(this.readyState=="complete")n()};/*@end @*/
}if(/WebKit/i.test(navigator.userAgent)){window.__ADLET=setInterval(function(){if(/loaded|complete/.test(document.readyState)){n()}},10)}window.onload=n;window.__ADLE=[]}window.__ADLE.push(f)}function externalLinks(a){if(a){str="#"+a+" a[rel=external]"}else{str="a[rel=external]"}$$(str).setProperty("target","_blank");if(pageTracker){$$("#"+a+" a").addEvent("click",function(b){pageTracker._trackPageview(this.getProperty("href").replace("/#/","/"))})}}var menu,pages,pagesByName,loadedPages,underline,pagesHolder,pagesLoaded,currentPage,first;var fxMove,fxUnderline,fxRunning;var fxClouds,clouds;var galleryName=null;var currentLocation="";var Page=new Class({initialize:function(b,d,a,c){this.name=b;this.obj=d;this.index=a;this.next=this.prev=null;this.menuItem=c;this.req=new Request({method:"get",url:URL+"xmlhttp/"+lang+"/"+this.name,onRequest:function(){d.addClass("loading")},onSuccess:function(e){loadedPages[b]=true;d.removeClass("loading");d.set("html",e);externalLinks(b);switch(b){case"home":homeLocations();break;case"galerie":galleryName?loadGallery(galleryName):loadGallery("hostel");galleryName=null;break;case"rezervari":booking();ajaxGalleryLinks();break;case"contact":contact();break;case"restaurant":ajaxGalleryLinks();break;case"pensiune":ajaxGalleryLinks();break;case"localizare":maps();break}}})},request:function(){this.req.send()}});function navigation(){var a=((window.getHeight()-739)/2).toInt();if(a>0){$("wrapper").setStyle("padding-top",a)}menu=$$("#menu ul li a");pagesHolder=$("pages");pages=$$("#pages .page");underline=$("underline");fxMove=new Fx.Morph(pagesHolder,{duration:"long",transition:Fx.Transitions.Quad.easeOut});fxUnderline=new Fx.Morph(underline,{duration:"long",transition:Fx.Transitions.Quad.easeOut});fxRunning=false;loadedPages=new Array();pagesByName=new Array();underline.setStyles({left:$("selected-menu").getPosition($$("#menu ul")[0]).x,width:$("selected-menu").getSize().x});pages.each(function(e,d){name=e.getProperty("id");pages[d]=new Page(name,e,d,menu[d]);pagesByName[name]=pages[d];loadedPages[name]=false;if(name==page){currentPage=pages[d];loadedPages[name]=true}});pages.each(function(e,d){pages[d].prev=pages[d-1];pages[d].next=pages[d+1]});pages[0].prev=pages[pages.length-1];pages[pages.length-1].next=pages[0];var c=currentPage;for(j=0;j<pages.length;j++){if(j==5){first=c}if(j>=5){c.obj.setStyle("left",-2700+(j-5)*900)}else{c.obj.setStyle("left",j*900)}c=c.next}menu.each(function(e,d){e.setProperty("href",e.getProperty("href").replace(lang+"/",lang+"/#/"))});var b=$$("#logo a")[0];b.setProperty("href",lang+"/#/pensiune");b.addEvent("click",function(d){if(fxRunning==true){return false}newLocation="/pensiune";dhtmlHistory.add(newLocation);changePage(pagesByName.pensiune);d.preventDefault()});menu.each(function(e,d){e.addEvent("click",function(f){if(fxRunning==true){return false}newLocation="/"+pages[d].name;dhtmlHistory.add(newLocation);changePage(pages[d]);f.preventDefault()})});if(pageTracker){$$("#menu a, #footer a, #header a").addEvent("click",function(d){pageTracker._trackPageview(this.getProperty("href").replace("/#/","/"))})}currentURL=currentURL.split("/");if(currentURL[3]&&currentURL[3]!=""&&(currentURL[2]=="galerie"||currentURL[2]=="gallery")){galleryName=currentURL[3]}if(!currentURL[2]){currentURL="home"}else{currentURL=currentURL[2]}changePage(pagesByName[currentURL])}var dhtmlListener=function(a,b){if(a==""){a="/home"}a=a.split("/");if(a[2]&&a[2]!=""&&(a[1]=="galerie"||a[1]=="gallery")){galleryName=a[2]}changePage(pagesByName[a[1]])};function changePage(a){if(fxRunning==true||currentPage.name==a.name){return}fxRunning=true;if(map=$("map-large")){map.dispose()}currentLeft=currentPage.obj.getStyle("left").toInt();newLeft=a.obj.getStyle("left").toInt();left=pagesHolder.getStyle("left").toInt()+(currentLeft-newLeft);steps=Math.abs(currentLeft-newLeft)/900;for(j=0;j<steps;j++){if(currentLeft-newLeft<0){if(steps>=3&&(j==2||j==3)){(function(){first.obj.setStyle("left",first.prev.obj.getStyle("left").toInt()+900);first=first.next}).delay(1000)}else{first.obj.setStyle("left",first.prev.obj.getStyle("left").toInt()+900);first=first.next}}else{first.prev.obj.setStyle("left",first.obj.getStyle("left").toInt()-900);first=first.prev}}$("selected-menu").removeProperty("id");a.menuItem.setProperty("id","selected-menu");$("ro").setProperty("href","ro/"+a.name);$("en").setProperty("href","en/"+a.name);$("de").setProperty("href","de/"+a.name);currentPage.obj.getFirst().fade("out");if(loadedPages[a.name]){a.obj.getFirst().fade("show");if(a.name=="galerie"){if(galleryName){loadGallery(galleryName)}clearGallery()}}else{a.request()}fxMove.start({left:left}).chain(function(){fxRunning=false});width=a.menuItem.getStyle("width");left=a.menuItem.getPosition($$("#menu ul")[0]).x;fxUnderline.start({width:width,left:left});currentPage=a}function homeLocations(){btnClose=$("gallery-close");content=$("content-home");details=$("location-details");icons=$$("#locations li a");selectedLocation="";fxClouds=new Fx.Morph($("clouds"),{duration:15000,link:"ignore",transition:Fx.Transitions.Sine.easeOut});fxClouds.start({left:[153,0]});btnClose.addEvent("click",function(a){a.stop();content.addClass("closed");$("selected-icon").removeProperty("id")});icons.addEvent("click",function(a){a.stop();if(this==$("selected-icon")){this.removeProperty("id");content.addClass("closed");return}if($("selected-icon")){$("selected-icon").removeProperty("id")}this.setProperty("id","selected-icon");selectedLocation=this.getProperty("rel");new Request.HTML({method:"get",url:URL+"xmlhttp/"+lang+"/home/"+selectedLocation,update:details,onRequest:function(){content.fade("hide");details.set("html","")},onSuccess:function(){content.fade("hide").removeClass("closed").fade("in")}}).send()})}function clearGallery(){$$("#gallery-thumbs a")[0].setProperty("id","selected-thumb").getFirst().setOpacity(0.5);$("gallery-left").fade("show");$("gallery-right").fade("show");$("gallery-menu").fade("show");$("gallery-nav").fade("show");if($("room-menu")){$("room-menu").fade("show")}(function(){$("gallery-left").fade("out");$("gallery-right").fade("out");$("gallery-menu").fade("out");$("gallery-nav").fade("out");if($("room-menu")){$("room-menu").fade("out")}}).delay(1000)}function loadGallery(a){galleryName=null;url=URL+"xmlhttp/"+lang+"/galerie/"+a;new Request({method:"get",url:url,onSuccess:function(b){$("gallery-wrapper").set("html",b);gallery()}}).send()}function gallery(){var m=$("gallery");var l=m.getElements("li");var a=$("gallery-dragger");var k=$("gallery-thumbs").getFirst();var f=k.getElements("a");var b=92*f.length+14;var g=(b-748)/700;var e=m.getFirst();var c=$$("#gallery-menu a");var h=$$("#room-menu a");var d=$("gallery-left");var i=$("gallery-right");f[0].setProperty("id","selected-thumb").getFirst().setOpacity(0.5);$("content-galerie").addEvents({mouseover:function(){d.fade("in");i.fade("in");$("gallery-menu").fade("in");$("gallery-nav").fade("in");if($("room-menu")){$("room-menu").fade("in")}},mouseout:function(){d.fade("out");i.fade("out");$("gallery-menu").fade("out");$("gallery-nav").fade("out");if($("room-menu")){$("room-menu").fade("out")}}});i.addEvent("click",function(n){n.stop();if(next=$("selected-thumb").getParent().getNext()){next=next.getFirst();$("selected-thumb").removeProperty("id").getFirst().setOpacity(1);next.setProperty("id","selected-thumb").getFirst().setOpacity(0.5);path=next.getFirst().src.replace(/th\//,"");e.fade("out");new Asset.image(path,{onload:function(){e.src=path;e.fade("in")}})}});d.addEvent("click",function(n){n.stop();if(previous=$("selected-thumb").getParent().getPrevious()){previous=previous.getFirst();$("selected-thumb").removeProperty("id").getFirst().setOpacity(1);previous.setProperty("id","selected-thumb").getFirst().setOpacity(0.5);path=previous.getFirst().src.replace(/th\//,"");e.fade("out");new Asset.image(path,{onload:function(){e.src=path;e.fade("in")}})}});c.addEvent("click",function(n){n.stop();name=this.getProperty("rel");loadGallery(name)});if(h.length){h.addEvent("click",function(n){n.stop();name=this.getProperty("rel");loadGallery(name)})}k.setStyle("width",b);f.addEvent("click",function(n){n.stop();$("selected-thumb").removeProperty("id").getFirst().setOpacity(1);this.setProperty("id","selected-thumb").getFirst().setOpacity(0.5);path=this.getFirst().src.replace(/th\//,"");e.fade("out");new Asset.image(path,{onload:function(){e.src=path;e.fade("in")}})});if(f.length>8){new Drag("gallery-dragger",{modifiers:{y:"top",x:"left"},limit:{x:[0,700],y:[0,0]},onDrag:function(){k.setStyle("left",-1*a.getStyle("left").toInt()*g)}})}}function maps(){$("area-map").addEvent("click",function(a){a.stop();div=new Element("div",{id:"map-large"});img=new Element("img",{alt:""});img.injectInside(div);img.fade("hide");path="images/area-map-large.jpg";new Asset.image(path,{onload:function(){img.src=path;img.fade("in")}});div.injectInside($("wrapper")).addEvent("click",function(){this.dispose()})});$("directions-map").addEvent("click",function(a){a.stop();div=new Element("div",{id:"map-large"});img=new Element("img",{alt:""});img.injectInside(div);img.fade("hide");path="images/directions-map-large.jpg";new Asset.image(path,{onload:function(){img.src=path;img.fade("in")}});div.injectInside($("wrapper")).addEvent("click",function(){this.dispose()})})}function booking(){var e=$("booking");var g=new Array(55,60,70,45,50,15);var b=0;var h=$("startDate");var a=$("endDate");var k=$("finalPrice");var i=$$("#booking-form input.persons");var c=$("booking-form-btn");var l=new Fx.Morph(e,{link:"cancel",transition:Fx.Transitions.Quad.easeOut});var d=false;var f;if(c.hasClass("down")){d=true}c.addEvent("click",function(m){m.stop();if(d){l.start({top:-420}).chain(function(){d=false;c.removeClass("down")})}else{l.start({top:0}).chain(function(){d=true;c.addClass("down")})}});$("booking-form").set("send",{url:"xmlhttp/"+lang+"/"+currentPage.name,onSuccess:function(m){currentPage.obj.set("html",m);booking()}});$("booking-form").addEvent("submit",function(m){m.preventDefault();this.send()});f=function(){if(!calendar.calendars[0].val||!calendar.calendars[1].val){return false}b=0;i.each(function(n,m){b+=(n.getProperty("value")*g[m]).toInt()});days=calendar.calendars[0].val.diff(calendar.calendars[1].val);k.setProperty("value",b*days)};calendar=new Calendar({startDate:"d/m/Y",endDate:"d/m/Y"},{days:["Duminica","Luni","Marti","Miercuri","Joi","Vineri","Sambata"],months:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"],draggable:false,direction:0.5,offset:1,onHideComplete:f});i.addEvent("keyup",f)}function contact(){$("contact-form").set("send",{url:"xmlhttp/"+lang+"/"+currentPage.name,onSuccess:function(a){currentPage.obj.set("html",a);contact()}});$("contact-form").addEvent("submit",function(a){a.preventDefault();this.send()})}function ajaxGalleryLinks(){$$(".to-gallery").addEvent("click",function(a){this.setProperty("href",this.getProperty("href").replace(lang+"/",lang+"/#/"));galleryName=this.getProperty("rel");newLocation="/galerie/"+galleryName;dhtmlHistory.add(newLocation);changePage(pagesByName.galerie);a.preventDefault()})}addDOMLoadEvent(externalLinks);addDOMLoadEvent(navigation);if(page=="home"){window.addEvent("load",homeLocations)};

