(function(a){jQuery.fn.haccordion=function(b){var b=jQuery.extend({closedWidth:30,marginLeft:5},b);return this.each(function(c){if(jQuery.browser.msie&&jQuery.browser.version<8){var d=this;jQuery(document).ready(function(){a.haccordion(jQuery(d).attr("id"),b)})}else{a.haccordion(this,b)}})};a.haccordion=function(c,d){if(typeof c=="string"){var c=jQuery("#"+c)}if(!jQuery(".accordion.active",c).length){jQuery(".accordion",c).eq(0).addClass("active")}var b=jQuery(".accordion",c).length*(d.closedWidth+d.marginLeft)-d.closedWidth;d.width=jQuery(c).innerWidth()-b;jQuery(".accordion",c).each(function(){jQuery(this).css({width:d.width-jQuery(this).outerWidth()+jQuery(this).width()+d.marginLeft})});var e=0;var f=1000;jQuery(".accordion",c).each(function(){jQuery(this).css({left:e+"px",zIndex:f++});if(jQuery(this).is(".active")){e+=d.width+d.marginLeft;return}e+=d.closedWidth+d.marginLeft});jQuery(".accordion .handle",c).bind("click",function(g){a.haccordionSetActive(jQuery(this).parents(".accordion").eq(0),c,d);return false})};a.haccordionSetActive=function(f,e,j){var b=jQuery(".accordion",e);var h=b.index(f);var d=b.index(jQuery(".accordion.active",e));jQuery(".accordion",e).removeClass("active");jQuery(b[h]).addClass("active").addClass("loading");if(h==d){return false}else{if(h>d){for(var c=d+1;c<=h;c++){jQuery(b[c]).animate({left:c*(j.closedWidth+j.marginLeft)+"px"},400)}}else{for(var c=h+1;c<=d;c++){jQuery(b[c]).animate({left:j.width+(c-1)*(j.closedWidth+j.marginLeft)+j.marginLeft+"px"},400)}}}var g=function(i){jQuery(i).removeClass("loading")};window.setTimeout(g,410,b[h])}})(jQuery);(function(a){jQuery.fn.slide=function(b){var b=jQuery.extend({randomActive:false,leftHandle:"#handle-l",rightHandle:"#handle-r"},b);return this.each(function(c){if(jQuery.browser.msie&&jQuery.browser.version<8){var d=this;jQuery(document).ready(function(){a.slide(d,b)})}else{a.slide(this,b)}})};a.slide=function(e,h){var d=jQuery(h.leftHandle);var g=jQuery(h.rightHandle);var c=jQuery.browser.msie&&jQuery.browser.version<8?jQuery(".slide"):jQuery(".slide",e);var b=jQuery(c[0]).innerWidth();jQuery(c).each(function(j){jQuery(this).css({zIndex:100+j,left:b+"px"})});var f=0;var i=0;if(h.randomActive){f=Math.floor(Math.random()*c.length)}jQuery(c[f]).css({zIndex:200,left:0});g.bind("click",function(j){j.preventDefault();if(c[f-1]){i=f-1}else{i=c.length-1}jQuery(c[i]).css({left:b+"px"}).animate({left:0});jQuery(c[f]).animate({left:-b+"px"});f=i});d.bind("click",function(j){j.preventDefault();if(c[f+1]){i=f+1}else{i=0}jQuery(c[i]).css({left:-b+"px"}).animate({left:0});jQuery(c[f]).animate({left:b+"px"});f=i})}}(jQuery));(function(a){jQuery.fn.fade=function(b){var b=jQuery.extend({randomActive:false,leftHandle:"#handle-l",rightHandle:"#handle-r"},b);return this.each(function(c){if(jQuery.browser.msie&&jQuery.browser.version<8){var d=this;jQuery(document).ready(function(){a.fade(d,b)})}else{a.fade(this,b)}})};a.fade=function(e,h){var d=jQuery(h.leftHandle);var g=jQuery(h.rightHandle);var c=jQuery.browser.msie&&jQuery.browser.version<8?jQuery(".slide"):jQuery(".slide",e);var b=jQuery(c[0]).innerWidth();jQuery(c).css({zIndex:100});var f=0;var i=0;if(h.randomActive){f=Math.floor(Math.random()*c.length)}jQuery(c[f]).css({zIndex:200});g.bind("click",function(j){j.preventDefault();if(c[f-1]){i=f-1}else{i=c.length-1}jQuery(c).css({zIndex:100});jQuery(c[f]).css({zIndex:101});jQuery(c[i]).css({zIndex:225,opacity:0});jQuery(c[i]).animate({opacity:1},300);f=i});d.bind("click",function(j){j.preventDefault();if(c[f+1]){i=f+1}else{i=0}jQuery(c).css({zIndex:100});jQuery(c[f]).css({zIndex:101});jQuery(c[i]).css({zIndex:225,opacity:0});jQuery(c[i]).animate({opacity:1},300);f=i})}}(jQuery));puu.app("tt",function(){window.domain_static=/toidutakso\.localhost/.test(document.domain)?"http://static.toidutakso.localhost/":"http://toidutakso.static.puu.ee/";puu.locale.register("en_US",{"Tehniline viga, palun proovi uuesti.":"Technical problem, please try again.","Toode on lisatud ostukorvi.":"The product has been added to the cart.","Mõned tooted ei ole valitud ajal saadaval. Palun eemalda need või muuda kättetoimetamise aega.":"Some products are not available at the choosen time. Please remove them or change the delivery time.","Palun täida ka ülejäänud väljad.":"Please fill in other fields, too.","Palun sisesta tänav.":"Please enter your street name.","Palun sisesta maja.":"Please enter your house number.","Palun sisesta oma e-posti aadress.":"Please enter your e-mail address.","Paroolid ei kattu.":"Passwords do not match.","Parool peab olema vähemalt 7 tähemärki pikk.":"Password has to be at least 7 characters long.","Palun sisesta parool.":"Please enter a password.","Palun sisesta kasutajanimi.":"Please enter an username.","Palun sisesta telefon.":"Please enter your phone number.","Palun sisesta kood.":"Please enter the code."});puu.locale.register("ru_RU",{});jQuery(document).ready(this.ready)},{km:0,updatePrices:null,pageTracker:null,pageTrackerInit:function(){try{tt.pageTracker=_gat._getTracker("UA-12057524-2");tt.pageTracker._setDomainName(".toidutakso.ee");tt.pageTracker._setAllowHash(false);tt.pageTracker._trackPageview()}catch(a){}},trackPageview:function(b){try{tt.pageTracker._trackPageview(b)}catch(a){}},setUpdatePrices:function(a){this.updatePrices=a},error:function(a,c,b){jQuery("#"+a+" .error").remove();jQuery("#"+a).prepend('<p class="error">'+(c?c:_("Tehniline viga, palun proovi uuesti."))+"</p>");if(!b){jQuery("#"+a).modal().updatePosition()}},loadProduct:function(a){puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#product",type:"content",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=product&id="+a,beforeSend:function(){jQuery("#product").modal({loading:true,maxWidth:600}).show()},success:function(b){jQuery("#product").modal().setContent(b);if(jQuery("#product img").length&&!jQuery("#product img")[0].complete){jQuery("#product img").addClass("hidden");jQuery("#product img").bind("load",function(){jQuery(this).removeClass("hidden");jQuery("#product").modal().updatePosition()})}tt.trackPageview("/Toode/"+a+"/")}})},buyProduct:function(b,a){if((jQuery("#product-"+b).is(".liviko")||jQuery("#product-"+b).is(".tubakas"))&&!puu.readCookie("a18")){jQuery("#a18").modal().show();jQuery("#a18 #o18, #a18 #eo18").unbind("click");if(jQuery("#product-"+b).is(".tubakas")){jQuery("#a-liviko").addClass("hidden")}else{jQuery("#a-liviko").removeClass("hidden")}jQuery("#a18 #o18").unbind("click").bind("click",function(c){c.preventDefault();puu.createCookie("a18","1");tt.submitProduct(b,1,a);jQuery("#a18").modal().hide()});jQuery("#a18 #eo18").unbind("click").bind("click",function(c){c.preventDefault();jQuery("#a18").modal().hide()});return}else{if(!jQuery("#cart-left").is(".hidden")&&((jQuery("#product-"+b).is(".liviko")&&!this.hasAlcohol())||(!jQuery("#product-"+b).is(".liviko")&&this.hasAlcohol()))){jQuery("#alcohol").modal().show();jQuery("#alcohol-y").unbind("click").bind("click",function(c){c.preventDefault();jQuery("#alcohol").modal().hide();if(jQuery("#product-"+b).is(".liviko")){tt.submitProduct(b,1,a)}});jQuery("#alcohol-n").unbind("click").bind("click",function(c){c.preventDefault();jQuery("#alcohol").modal().hide();if(!jQuery("#product-"+b).is(".liviko")){tt.submitProduct(b,1,a)}});return}}tt.submitProduct(b,1,a)},submitProduct:function(c,a,b){jQuery("#product-"+c+" .image span").remove();jQuery.ajax({timeout:10000,type:"GET",url:"/ajax.php?p=cart&id="+c+(a?"&amount="+a:""),success:function(d){if(d=="OK"||!d||/([0-9]+)/.test(d)){if(!b){jQuery("#product-"+c+" .image").append("<span>"+_("Toode on lisatud ostukorvi.")+'<br /><a href="/Ostukorv/" class="viewcart">Vaata ostukorvi</a></span>');jQuery("#product-"+c+" .image").bind("click",function(f){f.preventDefault();tt.loadCart()})}else{if(jQuery("#content .product-c").length){jQuery("#content .product-c h2 + div.clear.normal").remove();jQuery("#content .product-c h2").after('<div class="clear normal"><p class="ok">'+_("Toode on lisatud ostukorvi.")+"</p></div>")}else{jQuery("#product h2 + div.clear.normal").remove();jQuery("#product h2").after('<div class="clear normal"><p class="ok">'+_("Toode on lisatud ostukorvi.")+"</p></div>");jQuery("#product").modal().updatePosition()}}tt.cartModified();tt.trackPageview("/Ostukorv/Lisa/"+c+"/");return}if(!b){jQuery("#product-"+c+" .image").append("<span>"+d+"</span>")}else{jQuery("#product h2").after('<div class="clear normal"><p class="important">'+d+"</p></div>");jQuery("#product").modal().updatePosition()}},error:function(){if(!b){jQuery("#product-"+c+" .image").append("<span>"+_("Tehniline viga, palun proovi uuesti.")+"</span>")}else{jQuery("#product h2").after('<div class="clear normal"><p class="error">'+_("Tehniline viga, palun proovi uuesti.")+"</p></div>");jQuery("#product").modal().updatePosition()}}})},loadContentConn:null,loadContent:function(g,f,e,d){if(!jQuery(d?"#recipes":"#products").length){jQuery("#content").children(":not(#left)").remove();jQuery("#content").addClass(d?"recipes":"products");jQuery("#content").append('<div id="'+(d?"recipes":"products")+'"></div>')}if((document.documentElement.scrollTop||document.body.scrollTop)>110&&!e&&!(jQuery.browser.msie&&jQuery.browser.version==6)){jQuery.scrollTo(d?"#recipes":"#products",150,{offset:{top:(jQuery.browser.msie&&jQuery.browser.version==7?-200:-15)}})}if(jQuery.browser.msie){var b=g.split("/");for(var c=0;c<b.length;c++){b[c]=encodeURIComponent(b[c])}g=b.join("/")}tt.getContent("path="+g,d)},getContent:function(b,a){if(tt.loadContentConn){tt.loadContentConn.abort()}tt.loadContentConn=puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#content",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?"+b,success:function(c){jQuery("#content .error, #content #tutvustus-cont").remove();jQuery(a?"#recipes":"#products").html(c);if(a){jQuery(".recipe a").bind("click",function(d){jQuery.address.value(jQuery(this).attr("href").replace(/http(s)?\:\/\/(.*?)\//,""));
return false})}else{jQuery(".product .image a").bind("click",function(d){tt.loadProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false});jQuery(".product .buy").bind("click",function(d){tt.buyProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false})}jQuery("#pageselect a").address(function(d){return jQuery(this).attr("href").replace(/http(s)?\:\/\/(.*?)\//,"")});jQuery("#tags a").bind("click",function(){jQuery.address.value(jQuery(this).attr("href").replace(/http(s)?\:\/\/(.*?)\//,""));return false})}})},calculateTotal:function(c,a){var b=0;jQuery(a?".poe-tooted td.kokku":"#cart td.kokku").each(function(){if(!c||!jQuery(this).parents("tr").eq(0).is(".tubakas")){b+=parseFloat(jQuery(this).text())}});if(b<0){return 0}return b.toFixed(2)},updateTotal:function(a){var b=tt.calculateTotal();var c=tt.calculateTotal(null,true);if(a){jQuery("#cart #allahindlus-vip td.kogus").text("1");jQuery("#cart #allahindlus-vip td.hind, #cart #allahindlus-vip td.kokku").text("-"+(parseFloat(b)*0.05).toFixed(2)+" EUR");b=tt.calculateTotal();c=tt.calculateTotal(null,true)}jQuery("#cart tr.total td.total").text(Math.round(b/(100+this.km))*100+" EUR");jQuery("#cart tr.total-km td.total").text(Math.round(b*this.km)/100+" EUR");jQuery("#cart tr.total-wkm td.total").text(Math.round(b*100)/100+" EUR ("+(Math.round((b*15.6466)*100)/100)+" EEK)");jQuery(".poe-tooted td.total").text(Math.round(c/(100+this.km))*100+" EUR");jQuery(".restorani-tooted td.total").text(Math.round((c>b?0:b-c)/(100+this.km))*100+" EUR");return b},updateAmountTimeout:null,updateAmountDelay:function(c,b,a){if(tt.updateAmountTimeout){window.clearTimeout(tt.updateAmountTimeout)}if(jQuery.browser.msie){tt.updateAmountTimeout=window.setTimeout("tt.updateAmount("+c+", '"+b+"', "+(a?true:false)+");",700)}else{tt.updateAmountTimeout=window.setTimeout(tt.updateAmount,700,c,b,a)}},updateAmount:function(c,b,a){puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&id="+c+"&amount="+b+"&update=1",success:function(e){if(e=="OK"||!e){var d=jQuery("#cart-"+c);d.children("td.kokku").text(Math.round((a?b/1000:b)*parseFloat(d.children("td.hind").text())*100)/100+" EUR");jQuery("#cart").modal().updatePosition();tt.updateTotal();tt.updatePrices();tt.cartModified();jQuery("#cart").modal().updatePosition();return}tt.error("cart",e)}})},loadCart:function(){puu.ajax({timeoutCallback:tt.timeoutCallback,validateCache:function(b,a){return b>tt.cartUpdated},url:"/ajax.php?p=cart",errorHandler:{where:"#cart",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,beforeSend:function(){jQuery("#cart").modal().clearContent(true).show()},success:function(a){jQuery("#cart").modal().setContent(a);jQuery("#cart .tootja a").bind("click",function(b){jQuery.address.value(jQuery(this).attr("href").replace(/^http\:\/\/(.*?)\//,""));jQuery("#cart").modal().hide();b.preventDefault()});jQuery("#cart td.kogus input").bind("keyup change",function(b){var d=jQuery(this).parents("td.kogus").eq(0).is(".kg");var f=jQuery(this).parents("tr").eq(0).attr("id").split("-")[1];if(!parseInt(this.value)&&parseInt(this.value)!==0&&this.value){if(d){this.value="100"}else{this.value="1"}}var c=parseInt(this.value)?parseInt(this.value):0;if(this.value){this.value=parseInt(this.value)}tt.updateAmountDelay(f,c,d)});jQuery("#cart .delete").bind("click",function(c){var b=this;var d=jQuery(this).parents("tr").eq(0).attr("id").split("-").reverse()[0];puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&delete="+d,success:function(e){if(e=="OK"||!e){jQuery(b).parents("tr").eq(0).remove();tt.updateTotal();tt.updatePrices();tt.cartModified();jQuery("#cart").modal().updatePosition();tt.trackPageview("/Ostukorv/Kustuta/"+d+"/");return}tt.error("cart",e)}});return false});jQuery("#cart-time-link").bind("click",function(c){jQuery("#cart-time #aeg2-f").val("").addClass("hidden");jQuery("#cart").modal().hide();jQuery("#cart-time .error").remove();jQuery("#cart-time .pood").removeClass("hidden");jQuery("#cart-time").modal().show();if(jQuery("#cart-time-custom").length){jQuery("#cart-time #aeg-f").val(jQuery("#cart-time-custom").text().substr(0,10));jQuery("#cart-time #aeg2-f").val(jQuery("#cart-time-custom").text().substr(-5,5));jQuery("#cart-time #aeg3-f option").attr("selected","")}else{if(jQuery("#cart-time-normal").length){jQuery("#cart-time #aeg-f").val(jQuery("#cart-time-normal").text().substr(0,10));jQuery("#cart-time #aeg2-f").val("");jQuery("#cart-time #aeg3-f option").attr("selected","");jQuery("#cart-time #aeg3-f option:nth-child("+(parseInt(jQuery("#cart-time-normal").attr("class").split("-")[1])+1)+")").attr("selected","selected")}else{var b=new Date();b.setMinutes(b.getMinutes()+120);jQuery("#cart-time #aeg-f").val(b.getFullYear()+"-"+(b.getMonth()<9?"0"+(b.getMonth()+1):b.getMonth()+1)+"-"+(b.getDate()<10?"0"+b.getDate():b.getDate()))}}tt.trackPageview("/Ostukorv/Aeg/");return false});jQuery("#cart-time-link-r").bind("click",function(c){jQuery("#cart-time #aeg2-f").val("").removeClass("hidden");jQuery("#cart").modal().hide();jQuery("#cart-time .error").remove();jQuery("#cart-time .pood").addClass("hidden");jQuery("#cart-time").modal().show();if(jQuery("#cart-time-link-r span").length){jQuery("#cart-time #aeg-f").val(jQuery("#cart-time-link-r span").text().substr(0,10));jQuery("#cart-time #aeg2-f").val(jQuery("#cart-time-link-r span").text().substr(-5,5));jQuery("#cart-time #aeg3-f option").attr("selected","")}else{var b=new Date();b.setMinutes(b.getMinutes()+30);jQuery("#cart-time #aeg-f").val(b.getFullYear()+"-"+(b.getMonth()<9?"0"+(b.getMonth()+1):b.getMonth()+1)+"-"+(b.getDate()<10?"0"+b.getDate():b.getDate()));jQuery("#cart-time #aeg2-f").val((b.getHours()<10?"0"+b.getHours():b.getHours())+":"+(b.getMinutes()<10?"0"+b.getMinutes():b.getMinutes()))}tt.trackPageview("/Ostukorv/Restoraniaeg/");return false});jQuery("#cart form").bind("submit",function(b){return false});jQuery("#tourist-button, #location-button, #commit-button, #kupong-button").bind("click",function(c){var b=jQuery(this).attr("name");if(b=="location"){tt.showLocationSelect();return false}else{if(b=="tourist"){tt.showLocationSelect(true);return false}else{if(b=="kupong"){tt.kupong();return false}}}if(jQuery("#cart tr.unavailable").length){tt.error("cart",_("Mõned tooted ei ole valitud ajal saadaval. Palun eemalda need või muuda kättetoimetamise aega."));return false}window.location.href="/Ostukorv/Kinnita/";return false});jQuery("#cart-addr #addr-f").val(jQuery("#cart #location-button").attr("title"));jQuery("#asendus-f").bind("change",function(c){var b=jQuery("#asendus-f").is(":checked")?1:0;jQuery.ajax({timeout:10000,type:"GET",url:"/ajax.php?p=cart&asendus="+b,success:function(e){jQuery("#asendus-f").attr("checked",b?"checked":"")},error:function(e){jQuery("#asendus-f").attr("checked",b?"":"checked")}})});tt.trackPageview("/Ostukorv/")}})},showLocationSelect:function(a){jQuery("#cart").modal().hide();jQuery("#cart-addr"+(a?"-tourist":"")).modal().show();tt.trackPageview("/Ostukorv/Aadress/");return false},kupong:function(){jQuery("#cart").modal().hide();jQuery("#cart-kupong").modal().show();tt.trackPageview("/Ostukorv/Kupong/");return false},notLoggedIn:function(a){if(a){return}jQuery("#login-link").bind("click",function(b){jQuery("#login-modal").modal().show();jQuery("#login-modal").modal().updatePosition();tt.trackPageview("/Logi sisse/");return false});jQuery("#login-modal form").bind("submit",function(b){return false});jQuery("#login-button, #register-button").bind("click",function(f){var g=false;if(f.target.id=="register-button"){g=true}var c=!!jQuery(this).parents("#login-modal").length;if(g&&jQuery("#login-modal-register").is(".hidden")){jQuery("#login-modal-register").removeClass("hidden");jQuery("#login").prepend('<p class="info">'+_("Palun täida ka ülejäänud väljad.")+"</p>");if(c){jQuery("#login-modal").modal().updatePosition()}return false}var b=function(e){jQuery("#login .error, #login .info").remove();jQuery("#login").prepend('<p class="error">'+e+"</p>");if(c){jQuery("#login-modal").modal().updatePosition()}};var d="";if(!jQuery("#kasutajanimi-f").val()){d=_("Palun sisesta kasutajanimi.")}else{if(!jQuery("#parool-f").val()){d=_("Palun sisesta parool.")}else{if(g&&jQuery("#parool-f").val().length<7){d=_("Parool peab olema vähemalt 7 tähemärki pikk.")}else{if(g&&jQuery("#parool2-f").val()!=jQuery("#parool-f").val()){d=_("Paroolid ei kattu.")}else{if(g&&!jQuery("#epost-f").val()){d=_("Palun sisesta oma e-posti aadress.")}else{if(g&&!jQuery("#telefon-f").val()){d=_("Palun sisesta telefon.")}}}}}}if(d){b(d);return false}puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#login-modal",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p="+(g?"register":"login")+"&username="+encodeURIComponent(jQuery("#kasutajanimi-f").val())+"&password="+encodeURIComponent(jQuery("#parool-f").val())+(g?"&password2="+encodeURIComponent(jQuery("#parool2-f").val())+"&epost="+encodeURIComponent(jQuery("#epost-f").val())+"&telefon="+encodeURIComponent(jQuery("#telefon-f").val()):""),success:function(e){if(e=="OK"||!e){window.location.reload();return}b(e)}})})},loggedIn:function(){jQuery("#prefs-link").bind("click",function(a){tt.trackPageview("/Seaded/");jQuery("#prefs-modal").modal().show();return false});jQuery("#prefs-modal form").bind("submit",function(c){var a=function(d){jQuery("#prefs-modal .error, #prefs-modal .info").remove();jQuery("#prefs-modal").prepend('<p class="error">'+d+"</p>");jQuery("#prefs-modal").modal().updatePosition()};var b="";if(jQuery("#parool-f").val()&&jQuery("#parool-f").val().length<7){b=_("Parool peab olema vähemalt 7 tähemärki pikk.")}else{if(jQuery("#parool-f").val()&&jQuery("#parool2-f").val()!=jQuery("#parool-f").val()){b=_("Paroolid ei kattu.")
}else{if(!jQuery("#epost-f").val()){b=_("Palun sisesta oma e-posti aadress.")}}}if(b){a(b);return false}puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#prefs-modal",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=prefs&username="+encodeURIComponent(jQuery("#kasutajanimi-f").val())+"&password="+encodeURIComponent(jQuery("#parool-f").val())+"&password2="+encodeURIComponent(jQuery("#parool2-f").val())+"&epost="+encodeURIComponent(jQuery("#epost-f").val()),success:function(d){if(d=="OK"||!d){window.location.reload();return}a(d)}});return false})},cart:function(){jQuery(".cart-link").bind("click",function(a){tt.loadCart();a.preventDefault()});jQuery("#cart-time form").bind("submit",function(a){puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart-time",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&time="+encodeURIComponent(jQuery("#aeg-f").val()+" "+(jQuery("#aeg2-f").val()!=""?jQuery("#aeg2-f").val():jQuery("#aeg3-f").val().split("-")[0]))+"&normal="+(jQuery("#aeg2-f").val()!=""?1:0)+"&restaurant="+(jQuery("#cart-time .pood").is(".hidden")?1:0),success:function(b){if(b=="OK"||!b){jQuery("#cart-time").modal().hide();tt.cartModified();tt.loadCart();return}jQuery("#cart-time .error").remove();jQuery("#cart-time h2").after('<p class="error">'+(b?b:_("Tehniline viga, palun proovi uuesti."))+"</p>");jQuery("#cart-time").modal().updatePosition()}});return false});jQuery("#cart-addr-tourist form, #cart-addr form").bind("submit",function(b){var a=jQuery(this).parents("div.modal").eq(0).attr("id").split("-")[2]=="tourist";if(!a){if(!jQuery("#tanav-f").val()){tt.error("cart-addr",_("Palun sisesta tänav."));return false}else{if(!jQuery("#maja-f").val()){tt.error("cart-addr",_("Palun sisesta maja."));return false}}}puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart-addr"+(a?"-tourist":""),handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&"+(a?"asukoht="+jQuery("#asukoht-f").val():"tanav="+encodeURIComponent(jQuery("#tanav-f").val())+"&maja="+encodeURIComponent(jQuery("#maja-f").val())+"&korter="+encodeURIComponent(jQuery("#korter-f").val())+"&linn="+encodeURIComponent(jQuery("#linn-f").val())+"&maakond="+encodeURIComponent(jQuery("#maakond-f").val())),success:function(c){if(c=="OK"||!c){jQuery("#cart-addr"+(a?"-tourist":"")).modal().hide();if(jQuery("#cart tr.unavailable").length){jQuery("#cart").modal().show();tt.error("cart",_("Mõned tooted ei ole valitud ajal saadaval. Palun eemalda need või muuda kättetoimetamise aega."))}else{if(!a&&jQuery("#linn-f").val().toLowerCase()!="tallinn"&&jQuery("#linn-f").val().toLowerCase()!="keila"){window.location.href="/Kaart/"}else{window.location.href="/Ostukorv/Kinnita/"}}tt.cartModified();return}tt.error("cart-addr"+(a?"-tourist":""),c)}});return false});jQuery("#cart-kupong form").bind("submit",function(a){if(!jQuery("#kood-f").val()){tt.error("cart-kupong",_("Palun sisesta kood."));return false}puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart-kupong",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&kupong="+jQuery("#kood-f").val(),success:function(b){if(b=="OK"||!b){jQuery("#cart-kupong").modal().hide();tt.cartModified();tt.loadCart();return}tt.error("cart-kupong",b)}});return false})},loadRecipe:function(b){jQuery("#content").children(":not(#left)").remove();jQuery("#content").removeClass("recipes");var a=b;b=b.split("/").reverse();puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#content",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=recipe&id="+(b[0]?b[0]:b[1]),success:function(c){jQuery("#content").append(c);jQuery(".product .image a").bind("click",function(d){tt.loadProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false});jQuery(".product .buy").bind("click",function(d){tt.buyProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false})}});tt.trackPageview("/Retsept/"+a)},updateMargin:function(){if(jQuery(window).width()<=1024){jQuery("#content").addClass("small");return}jQuery("#content").removeClass("small");if(!jQuery("#tutvustus-container").length){return}var k=0;var g=0;var j=576;var b=jQuery("#tutvustus-container").offset();var c=jQuery("#products").offset();var d=jQuery("#products").innerWidth();var l=178;if(jQuery("#content").is(".small")){l=172}var h=jQuery("#products > .product");for(var f=0;f<9;f++){var e=h.eq(f).offset();if(!e.top){continue}if(!g&&e.top>b.top+10){break}else{if(!g){g=e.left}else{if(e.left<=g){break}}}k++}if(k==0){jQuery("#tutvustus-container").addClass("firstRow")}else{var a=jQuery("#products").innerWidth()-d+g-c.left-11;if(a+12>0){jQuery("#tutvustus-container").css({left:-a+"px"})}}},updateIntroMargin:function(){tt.updateMargin();jQuery(window).bind("resize",function(){tt.updateMargin()})},updateLeft:function(){if(jQuery.address.pathNames().length&&jQuery.address.pathNames()[0].toLowerCase()=="leviala"){jQuery("#search, .categories").addClass("hidden");jQuery("#content").removeClass("products").addClass("nocats");return}jQuery("#content").addClass("products").removeClass("nocats");if(jQuery.address.pathNames().length&&jQuery.address.pathNames()[0].toLowerCase()=="otsing"){jQuery(".categories").addClass("hidden");jQuery("#search").removeClass("hidden")}else{jQuery("#search").addClass("hidden");jQuery(".categories").removeClass("hidden")}},doSearch:function(c,b,a){if(!jQuery("#products").length){jQuery("#content").children(":not(#left)").remove();jQuery("#content").addClass("products");jQuery("#content").append('<div id="products"></div>')}if((jQuery("html")[0].scrollTop>110||document.body.scrollTop>110)&&!a&&!(jQuery.browser.msie&&jQuery.browser.version==6)){jQuery.scrollTo("#products",150,{offset:{top:(jQuery.browser.msie&&jQuery.browser.version==7?-200:-15)}})}tt.getContent("path="+c)},addressFirst:true,address:function(){var a=function(c){if(!c.pathNames[0]&&tt.addressFirst){tt.addressFirst=false;return}if(jQuery.browser.msie&&jQuery.browser.version==6){self.location.href=c.path;return}var b=c.pathNames[0]?decodeURIComponent(c.pathNames[0].toLowerCase()):"";if(b=="retsept"){tt.loadRecipe(c.path)}else{if((b=="retseptid")){tt.loadContent(c.path,0,c.type=="externalChange",true)}else{if(b=="otsing"||(/\/Otsing\//).test(document.location.href)||!c.pathNames[0]||b=="pood"||b=="restoranid"||b=="menüü"||b=="liviko+alcostore"){tt.loadContent(c.path,0,c.type=="externalChange")}else{if(b=="leviala"){tt.initMap()}else{puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#cart",handleTimcontent:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?path=/"+c.pathNames[0]+"/",success:function(e){jQuery("#content > *:not(#left)").remove();jQuery("#content").append(e);if(c.type!="externalChange"&&(document.documentElement.scrollTop||document.body.scrollTop)>110&&!(jQuery.browser.msie&&jQuery.browser.version==6)){jQuery.scrollTo(0,150)}}})}}}}tt.setTitle(c.pathNames);tt.updateLeft();tt.trackPageview(c.path)};jQuery.address.internalChange(a);jQuery.address.externalChange(a);jQuery.address.crawlable(true)},mapConfig:{version:"v4.0.1",googleAPIkey:"ABQIAAAAcsmN9Gqg6CqxcZ_EccxOdBS3PeUgquD0CTIueQ9UFWvOjqpiRRTadzKEWYaKRiih9oRjPlorkVcvWA",lon:24.7467041,lat:59.4520556,zoom:3,gmlLayerEnabled:true,gmlLayer:{name:"",loc:"/ajax.php?p=map",visibility:false},enableInfo:true},mapHandlers:function(b,d,c){var a={gmlStyleMap:function(){var e={getStrokeColor:function(f){return f.fid==1?"#e96e06":"#66cccc"},getStrokeWidth:function(f){return f.fid==1?"2":"3"}};return new OpenLayers.StyleMap({"default":new OpenLayers.Style({fillColor:"#66cccc",fillOpacity:0.15,strokeColor:"${getStrokeColor}",strokeOpacity:1,strokeWidth:"${getStrokeWidth}"},{context:e})})},infoInit:function(){var e="";if(b){e+="<p>Asukoha märkimiseks kliki kaardil. Parema tulemuse saamiseks väljaspool Tallinna kasuta satelliidikaarti.</p>";e+='<p>Kui asukoht on määratud, <strong><a href="/Ostukorv/Kinnita/">kinnita tellimus</a></strong>.</p>'}e+="<p>Väljaspool leviala lisandub kilomeetrihind 0.6€, mida arvestatakse <em>linnulennult</em>.</p>";jQuery("#map-info").append(e)}};if(b){a=jQuery.extend({},a,{clickEventHandler:function(h,g,i){if(i){var f=(h/20037508.34)*180;var e=(g/20037508.34)*180;e=180/Math.PI*(2*Math.atan(Math.exp(e*Math.PI/180))-Math.PI/2)}puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{where:"#map-info h2",type:"after",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=cart&location="+(f?f+","+e:h+","+g),success:function(j){jQuery("#map-info .error, #map-info .important").remove();if(!j){jQuery("#map-info h2").after('<p class="error">Tehniline viga, palun proovi uuesti.</p>');return}if(!jQuery("#map-info .dist").length){jQuery("#map-info h2").after('<p class="dist important"></p>')}jQuery("#map-info .dist").html(j)}});this.addMarker(h,g)},addMarker:function(h,f){if(!this.markersLayer){this.markersLayer=new OpenLayers.Layer.Markers("Punktid",{calculateInRange:function(){return true},displayInLayerSwitcher:false});this.markersLayer.inRange=true;puuMap.data.map.addLayer(this.markersLayer)}if(this.marker){this.markersLayer.clearMarkers();this.marker.destroy()}var e=new OpenLayers.Size(20,34);var g=new OpenLayers.Pixel(-(e.w/2),-e.h);this.marker=new OpenLayers.Icon(puuMap.config.imgLoc+"default_.png",e,g);this.markersLayer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(h,f),this.marker))},init:function(){if(d&&c){var e=puuMap.forwardMercator(d,c);puuMap.handlers.addMarker(e.lon,e.lat);puuMap.data.map.setCenter(new OpenLayers.LonLat(e.lon,e.lat),5)}}})}return a},initMap:function(a,c,b){jQuery("#content").children(":not(#left)").remove();window.mapConfig=tt.mapConfig;window.mapHandlers=tt.mapHandlers(a,c,b);
jQuery("#content").append('<div id="map"></div>');if(document.domain.indexOf("localhost")==-1){jQuery("#content").append('<script type="text/javascript" src="http://kaart.puu.ee/kaart/'+tt.mapConfig.version+'/init.js"><\/script>')}else{jQuery("#content").append('<script type="text/javascript" src="http://kaart.puu.localhost/kaart/dev/init.js"><\/script>')}},origFullTitle:"Toidutakso ~ ...mugavuse uus tase",origTitle:"Toidutakso",setTitle:function(b){if(!b.length){document.title=tt.origFullTitle;return}if(typeof b=="object"){if(parseInt(b[b.length-1])==b[b.length-1]){b.pop()}var c=[];for(var a=0;a<b.length;a++){c[a]=decodeURIComponent(b[a]).replace(/\+/g," ")}document.title=c.reverse().join(" / ")+" :: "+(c.length==1?tt.origFullTitle:tt.origTitle);return}document.title=b+" :: "+tt.origTitle},bindUrls:function(a){jQuery("a",jQuery(a)).bind("click",function(c){var b=jQuery(this).attr("href");if(/^http:\/\/(www\.)?toidutakso\.(ee|localhost)\//.test(b)){jQuery.address.value(b.replace(/^http:\/\/(www\.)?toidutakso\.(ee|localhost)\//,""));c.preventDefault()}})},updateLeftInfoQuery:null,updateLeftInfo:function(){if(!jQuery("#cart").is(".hidden")){var c=jQuery(".poe-tooted:first tr").length;var a=jQuery(".restorani-tooted:first tr").length;var b=(c>0?c-2:0)+(a>0?a-2:0);jQuery("#cart-left strong").eq(1).text(tt.calculateTotal()+" EUR");jQuery("#cart-left strong").eq(0).text(b);if(b>0&&jQuery("#cart-left").is(".hidden")){jQuery("#cart-left").removeClass("hidden")}else{if(b==0){jQuery("#cart-left").addClass("hidden")}}}else{if(tt.updateLeftInfoQuery){tt.updateLeftInfoQuery.abort()}tt.updateLeftInfoQuery=puu.ajax({timeoutCallback:tt.timeoutCallback,errorHandler:{handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=stats",success:function(e){var e=e.split("|");jQuery("#cart-left strong").eq(1).text(e[0]);jQuery("#cart-left strong").eq(0).text(e[1]);tt.hasAlcohol(e[2]);if(e[1]>0&&jQuery("#cart-left").is(".hidden")){jQuery("#cart-left").removeClass("hidden")}else{if(e[1]==0){jQuery("#cart-left").addClass("hidden")}}}})}},_hasAlcohol:false,hasAlcohol:function(a){if(a==undefined||a==null){return this._hasAlcohol}this._hasAlcohol=!!parseInt(a)},cartUpdated:puu.getTime(),cartModified:function(){this.updateLeftInfo();this.cartUpdated=puu.getTime()},timeoutCallback:function(a,b){puu.ajax({timeout:60000,global:false,type:"GET",url:"/ajax.php?p=timeout&timeouts="+a+"&url="+encodeURIComponent(b.url)})},introInit:function(){if(puu.readCookie("u")){jQuery(".accordion").eq(3).addClass("active")}else{puu.setCookie("u",1,24*60*60*60)}var a=function(){jQuery("#tutvustus").haccordion({marginLeft:7});jQuery("#tutvustus2").fade({randomActive:true,leftHandle:"#tutvustus-h-l",rightHandle:"#tutvustus-h-r"});jQuery("#tutvustus .overlay").bind("click",function(b){jQuery.address.value("/Leviala/");b.preventDefault()})};if(jQuery.browser.msie&&jQuery.browser.version<8){jQuery(document).ready(a)}else{a()}},contentHeight:function(a){jQuery("#content").css({minHeight:Math.max(jQuery("#search").outerHeight(),jQuery("#left").outerHeight())+"px"})},ready:function(){if(jQuery.browser.msie&&jQuery.browser.version==6){jQuery("body").addClass("ready");return}jQuery("#menu form").bind("submit",function(a){if(jQuery("#top-search-f").val()!=_("Otsi toodetest...")){jQuery.address.value("/Otsing/"+jQuery("#top-search-f").val()+"/");jQuery("#otsi-f").val(jQuery("#top-search-f").val())}a.preventDefault()});jQuery("#search form").bind("submit",function(a){jQuery.address.value("/Otsing/"+jQuery("#otsi-f").val()+"/"+(jQuery("#tag-f").val()?"Märksõna-"+jQuery("#tag-f").val()+"/":"")+(jQuery("#hind-f").val()?"Hind-"+jQuery("#hind-f").val()+"/":""));a.preventDefault()});jQuery("#coupon-link").bind("click",function(a){tt.kupong(true);a.preventDefault()});tt.bindUrls("#footer");jQuery("#map-link, #intro-link, #card-link").bind("click",function(a){jQuery.address.value(jQuery(this).attr("href").replace(/^http:\/\/(www\.)?toidutakso\.(ee|localhost)\//,""));a.preventDefault()});jQuery("#orders-link").bind("click",function(a){puu.ajax({errorHandler:{where:"#orders",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?p=orders",beforeSend:function(){jQuery("#orders").addClass("loading").html("");jQuery("#orders").modal().show();jQuery("#orders").removeClass("hidden")},success:function(b){jQuery("#orders").removeClass("loading").html(b).modal().updatePosition();jQuery("#orders h3").bind("click",function(d){d.preventDefault();var c=jQuery("table."+jQuery(this).attr("class"));if(c.is(".hidden")){c.removeClass("hidden");jQuery("#orders").modal().updatePosition();return}c.addClass("hidden");jQuery("#orders").modal().updatePosition()});jQuery("#orders .redo").bind("click",function(d){d.preventDefault();var c=jQuery(this).attr("href").replace(/http(s)?:\/\/(.*?)\//,"");puu.ajax({errorHandler:{where:"#orders",handleTimeout:true},timeout:10000,maxTimeouts:3,timeoutMultiplier:1.5,type:"GET",url:"/ajax.php?path="+c,success:function(e){if(e=="OK"||!e){jQuery("#orders").modal().hide();tt.loadCart();tt.trackPageview(c);return}jQuery("#orders").html('<p class="error">'+_("Tehniline viga, palun proovi uuesti.")+"</p>").modal().updatePosition()},error:function(){jQuery("#orders").html('<p class="error">'+_("Tehniline viga, palun proovi uuesti.")+"</p>").modal().updatePosition()}})})},error:function(){jQuery("#orders").html('<p class="error">'+_("Tehniline viga, palun proovi uuesti.")+"</p>").modal().updatePosition()}});return false});jQuery(".product .image a").bind("click",function(a){tt.loadProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false});jQuery(".product .buy").bind("click",function(a){tt.buyProduct(jQuery(this).parents(".product").eq(0).attr("id").split("-")[1]);return false});jQuery(".recipe a").bind("click",function(a){jQuery.address.value(jQuery(this).attr("href").replace(/http(s)?:\/\/(.*?)\//,""));return false});jQuery("#tags a").bind("click",function(a){jQuery.address.value(jQuery(this).attr("href").replace(/http(s)?:\/\/(.*?)\//,""));return false});jQuery("#pageselect a").address(function(a){return jQuery(this).attr("href").replace(/http(s)?:\/\/(.*?)\//,"")})}});
