function setHoverAction(){$("#locationlist .scrollable div").on("mousemove",function(n){n.pageX+n.pageY!=mouseEvent&&(mouseEvent=n.pageX+n.pageY,showMap(this))});$("#locationlist .scrollable div").on("click",function(){doNavigate()})}function showMap(n){var t=parseFloat($(n).find(".lat").text()),r=parseFloat($(n).find(".lon").text()),u=$(n).find(".postcode").length>0,i;if(isNaN(t)||t==0){$("#map").hide("fast");return}$("#locationlist .scrollable > div").removeClass("active");$(n).addClass("active");recordIndex=$("#locationlist .scrollable .active").index()+1;i=mapurl.replace(/{lat}/g,t.toString()).replace(/{lon}/g,r.toString());u&&(i=detailmapurl.replace(/{lat}/g,t.toString()).replace(/{lon}/g,r.toString()));$("#map img").attr("src",i);$("#map").show("fast")}function doNavigate(){var n;if(selectedCountry=$("#countrycodes").val(),n=$("#locationlist .scrollable .active"),n.length!=0){var t=n.find(".locationid").text(),i=n.find(".name").text().replace(/[^a-z0-9]/gi,"-").toLowerCase(),r=targetUrl.replace(/{locationid}/g,t).replace(/{name}/,i);window.document.location.href=r}}function processKeyInput(n){switch(n.which){case 40:$("#locationlist .scrollable > div").removeClass("active");recordIndex++;recordIndex>$("#locationlist .scrollable > div").length&&(recordIndex=$("#locationlist .scrollable > div").length);$("#locationlist .scrollable > div:nth-child("+recordIndex+")").addClass("active");break;case 38:$("#locationlist .scrollable > div").removeClass("active");recordIndex--;recordIndex<1&&(recordIndex=1);$("#locationlist .scrollable > div:nth-child("+recordIndex+")").addClass("active");break;case 13:doNavigate()}try{$("#locationlist .scrollable .active").position().top<25&&$("#locationlist .scrollable").scrollTop((recordIndex-10)*20)}catch(n){}recordIndex<0&&(recordIndex=0);recordIndex<11&&$("#locationlist .scrollable").scrollTop(1);recordIndex%10==0&&$("#locationlist .scrollable").scrollTop((recordIndex-1)*20);showMap($("#locationlist .scrollable .active"))}function findLocations(n){(n={name:n.term,format:"jsonp"},typeof activeRequest=="undefined"||activeRequest!=n.term)&&(activeRequest=n.term,$("#locationlist").html(""),$("#resultset").show(),$.ajax({url:"https://api.themeteocompany.com/forecast/GetLocationsByName",type:"GET",cache:!0,data:n,jsonp:"callback",crossDomain:!0,dataType:"jsonp",success:function(n){var t="",i;if(n&&n.length!=0)if(recordIndex=0,typeof n[0].Postcode=="string"){t="<div class='head'><span class='postcode'>Postalcode<\/span><span class='straat'>Street<\/span><span class='plaats'>Location<\/span><\/div>";var u="",f="",e="",r="";for(t+="<div class='scrollable'>",i=0;i<n.length;i++)u!=n[i].Plaats&&(u=n[i].Plaats,f=u),e!=n[i].Straatnaam&&(e=n[i].Straatnaam,r=e),r!=""&&(t+="<div class='record'>",t+="<span class='postcode'><a href='#'>"+n[i].Postcode+"<\/a><\/span>",t+="<span class='straat'>"+r+"<\/span>",t+="<span class='plaats'>"+f+"<\/span>",t+="<span class='hidden gps lat'>"+Math.round(n[i].Latitude*100)/100+"<\/span>",t+="<span class='hidden gps lon'>"+Math.round(n[i].Longitude*100)/100+"<\/span>",t+="<\/div>"),r="",f="";t+="<\/div>"}else{for(t="<div class='head'><span class='name'>Location<\/span><span class='country'>Country<\/span><span class='gps'>Lat<\/span><span class='gps'>Lon<\/span><span class='gps'>Alt (m)<\/span><\/div>",t+="<div class='scrollable'>",i=0;i<n.length;i++)t+="<div class='record'>",t+="<span class='name'><a href='#'>"+n[i].Name+"<\/a><\/span>",t+="<span class='country'>"+n[i].Country+"<\/span>",t+="<span class='gps lat'>"+Math.round(n[i].Latitude*100)/100+"<\/span>",t+="<span class='gps lon'>"+Math.round(n[i].Longitude*100)/100+"<\/span>",t+="<span class='hidden locationid'>"+n[i].Id+"<\/span>",n[i].ElevationModel>0&&(t+="<span class='gps alt'>"+Math.round(n[i].ElevationModel)+"<\/span>"),t+="<\/div>";t+="<\/div>"}else t="<div class='nolocations'>No locations found.<\/div>";$("#locationlist").html(t);$("#locationlist .scrollable > div:nth-child(1)").addClass("active");showMap($("#locationlist .scrollable > div:nth-child(1)"));setHoverAction()}}))}function addLocationToFavorite(){}var language,culture,recordIndex=0,mapurl="https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/{lat},{lon}/11?ms=200,236&od=1&c="+culture+"&key=AijbFhynMi9YlUoC5sbBKfrfbnkcMJ34sYBEORQwbsviodnw8nTkkgh5se5COtMs&ur="+language,detailmapurl="https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/{lat},{lon}/14?ms=200,236&od=1&c="+culture+"&key=AijbFhynMi9YlUoC5sbBKfrfbnkcMJ34sYBEORQwbsviodnw8nTkkgh5se5COtMs&ur="+language,targetUrl="/"+language+"/forecast/h/{locationid}/{name}",selectedCountry,mouseEvent,activeRequest;$("#location").autocomplete({source:function(n,t){findLocations(n,t)},minLength:3});mouseEvent=null;$("#countrycodes").on("change",function(){var n={term:$("#location").val(),country:$("#countrycodes").val()};findLocations(n,null)});$("#location").on("input",function(){$("#location").val().length==0&&$("#resultset").hide()});$("#clear").on("click",function(){$("#location").val("");$("#resultset").hide()});$(".zoekplaats input").on("keydown",function(n){try{processKeyInput(n)}catch(n){}});activeRequest="";$.ajax({url:"/"+language+"/api/countrylist",type:"GET",cache:!0,dataType:"json",success:function(n){var i,r,t,u;if(n&&n.length!=0){for(i="",r=!1,i+="<select id='countrycodes'>",t=0;t<n.length;t++)n[t].DisplayOrder!=99||r||(i+="<option class='split'>===============================<\/option>",r=!0),u="",selectedCountry==n[t].CountryCode&&(u=" selected='selected' "),i+="<option "+u+" value='"+n[t].CountryCode+"' class=''>"+n[t].Name+"<\/option>";i+="<\/select>";$("#countrylist").html(i)}}})