function setcookie(d,b,c){var a="";c&&(a=new Date,a.setTime(a.getTime()+864E5*c),a="; expires="+a.toUTCString());document.cookie=d+"="+b+a+"; path=/"}function deletecookie(d){document.cookie=d+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"}function getcookie(d){d+="=";for(var b=document.cookie.split(";"),c=0;c<b.length;c++){for(var a=b[c];" "==a.charAt(0);)a=a.substring(1);if(-1!=a.indexOf(d))return a.substring(d.length,a.length)}return""}
function liftcurtain(){$(document).unbind("keydown");$(".d-popupCurtain, .p-popup").remove();$("body").removeClass("j-noScroll")}function dropcurtain(d){liftcurtain();$(document).on("keydown",function(b){27==b.keyCode&&liftcurtain()});$(document.body).prepend('<div class="d-popupCurtain"></div><div class="loadingWrap p-popup d-popupWrap '+d+'"><img src="/images/loading.gif" alt="loading"></div>')}
function loadpopup(d,b,c,a){c=void 0===c?null:c;a=void 0===a?null:a;dropcurtain(d);"undefined"==typeof a&&(a="");$.get(b,c,function(a){$(".p-popup").html(a).removeClass("loadingWrap");$(document).scrollTop();$(".p-popup").css("top","0px")}).done(a)}
$(function(){var d=null;$(document).on("click",".j-changelocation",function(b){b={};b.l=$(this).data("id");$.getJSON("/update-location",b,function(b){if(b.status)location.reload();else return alert("Something went wrong with the location update!"),!1})});$(document).on("keyup",".j-typeahead",function(b){var c={a:"typeahead"};c.q=$(this).val();clearTimeout(d);d=setTimeout(function(){$.getJSON("/search",c,function(a){$(".searchResult").removeClass("j-hidden");$(".searchResult").html(a.content)})},500)});
$(document).on("click",".j-signupsubmit",function(b){b.preventDefault();var c=$(this).closest("form");b=c.serializeArray();console.log(b);$.getJSON("/general-process?a=signup",b,function(a){var b=c.find(".d-inError[data-for=e]"),d=c.find(".d-success[data-for=e]");b.addClass("j-hidden");d.addClass("j-hidden");0==a.status?b.removeClass("j-hidden").html(a.data):d.removeClass("j-hidden").html(a.data)})});""===getcookie("firstvisit")&&"/city-update-confirmation"!=window.location.pathname&&(setcookie("firstvisit",
1,2592E6),setTimeout(function(){loadpopup("welcome","/welcome-popup")},5E3));$(document).on("click",".d-popupClose, .d-popupCurtain, .d-popupClose",function(b){b.preventDefault();liftcurtain()})});