var mst_initPostcodeText="Postcode/Suburb";var mst_initPostcodeError="Invalid Postcode/Suburb";var mst_errorMsg='<div class="errorMessage">** Error **</div>';var mst_AjaxLoadingMsg='<div class="ajaxLoading">Loading...</div>';$(document).ready(function(){$.ajax({type:"POST",url:"/lmk/handlers/CustomisedWeather.ashx",data:{pfunc:1},success:function(a){mst_processCustomSettings(0,a)},error:function(a,c,b){pcodeSearchInit(3000)}});$("#switch").hide();$("#switch").click(function(){$("#weather:visible").hide();$("#weather-list:hidden").effect("slide",{direction:"right"},500);$("#txt-pcode-list").val($("#txt-pcode").val())});$("#switch-back").click(function(){$("#weather-list:visible").hide();$("#weather:hidden").effect("slide",{direction:"left"},500);$("#txt-pcode").val($("#txt-pcode-list").val())});$("input.pcode-search").attr("value",mst_initPostcodeText).click(function(){if($(this).val()==mst_initPostcodeText||$(this).val()==mst_initPostcodeError){$(this).attr("value","")}}).blur(function(){if(jQuery.trim($(this).val()).length==0){$(this).attr("value",mst_initPostcodeText)}});$("#btn-pcode").click(function(){pcodeSearch("#txt-pcode")});$("#btn-pcode-list").click(function(){pcodeSearch("#txt-pcode-list")});$(".ui-state-default").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")});mst_showWeatherSearchPanel();$(".ui-icon-extlink").click(function(){loadInternalLinks("RelatedPageLink"+$(this).attr("id"),"RelatedPage"+$(this).attr("id"))});$(function(){$("#related-edit").tabs()});$("input.pcode-search").autocomplete("/lmk/handlers/weather-ac.ashx",{max:10,mustMatch:false,width:200,scroll:false,selectFirst:true}).result(function(d,c){var b=$(this).val();var a=b.split(",");$("input.pcode-search").val(jQuery.trim(a[2]))})});function mst_showError(b,c){if((b==undefined)||(b==null)){b="Unable to process your request at the moment.\nPlease check back later."}var a;if((c==undefined)||(c==null)){scroll(0,0);a=$("#mst_pnlError")}else{a=$("#"+c)}if(a.length==0){alert(b)}else{a.html(b.replace(/\n/g,"<br/>"));a.show()}}function mst_showInitFailed(){mst_showError("Sorry, your requested weather information is unavailable at the moment.\nEither refresh the page or return to this page later.")}function mst_showAjaxFailed(){mst_showError(null)}function mst_showMapError(a){mst_showError(a,"mst_pnlMapErr")}function mst_hideMapError(){$("#mst_pnlMapErr").hide()}function mst_ajaxCall(f,c,b,a,d){var e=$("#mst_pnlError");if(e.length>0){e.hide()}if(f!=null){$(f).html(mst_AjaxLoadingMsg)}$.ajax({type:"POST",url:c,data:b,success:(a==null)?function(g){if(f!=null){$(f).html(g)}}:a,error:(d==null)?function(g,i,h){if(g.responseText.indexOf("Invalid postcode")>0){$("input.pcode-search").attr("value","Invalid Postcode/Suburb").attr("color","red")}else{if(f!=null){$(f).html(mst_errorMsg)}mst_showAjaxFailed()}}:d})}function mst_showWeatherSearchPanel(){$("#minweather_SearchPanel").show();$("#minweatherlist_SearchPanel").show()}function mst_hideWeatherSearchPanel(){$("#minweather_SearchPanel").hide();$("#minweatherlist_SearchPanel").hide()}function mst_processCustomSettings(c,d){var e=d.split("|");if(e.length<5){mst_showInitFailed()}else{var a=e[2];var b=e[3];mst_UpdateWeather(c,b,0,a);mst_UpdateWeather(c,b,1,a);if(window.onUpdateWeatherControls){onUpdateWeatherControls(c,d)}}}function loadInternalLinks(a,i){var h=$("span#[id*='_"+a+"']").attr("id");var f=$("input#[id*='"+h+"_']").attr("id");var d=$("span#[id*='_"+i+"']").attr("id");var c=$("input#[id*='"+d+"_']").attr("id");var g=document.getElementById(f).value;var j=window.showModalDialog("/lmk/CMS/WebAuthor/Dialogs/InternalLinks/InternalLinks.aspx?NRMODE=Unpublished&wbc_caller=IEModal",g,IDS_IEWIN_INTLINKS_FEATURES);if(j!="Cancel"){var b=document.getElementById(f);var e=document.getElementById(c);if((e.value=="")||(b.value==e.value)){e.value=j}b.value=j}}function pcodeSearch(a){mst_ajaxCall(null,"/lmk/handlers/post-code-search.ashx",{pcode:$(a).val()},function(b){mst_processCustomSettings(1,b)},null)}function pcodeSearchInit(a){mst_ajaxCall(null,"/lmk/handlers/post-code-search.ashx",{pcode:a},function(b){mst_processCustomSettings(1,b)},null)}function mst_UpdateWeather(a,c,d,b){mst_ajaxCall((d==0)?"#weather div.ph":"#weather-list div.ph","/lmk/handlers/weather-min.ashx",{aploc:c,view:d},function(e){if(d==0){$("#weather div.ph").html(e);$("#switch").show()}else{$("#weather-list div.ph").html(e)}},null);if((b!=undefined)&&(b!=null)){if($("#weather").is(":visible")){$("#txt-pcode").val(jQuery.trim($("#txt-pcode").val()));if(($("#minweather_SearchPanel").is(":visible"))&&(($("#txt-pcode").val().length==0)||($("#txt-pcode").val()!=mst_initPostcodeText))){$("#txt-pcode").val(b)}}if($("#weather-list").is(":visible")){$("#txt-pcode-list").val(jQuery.trim($("#txt-pcode-list").val()));if(($("#minweatherlist_SearchPanel").is(":visible"))&&(($("#txt-pcode-list").val().length==0)||($("#txt-pcode-list").val()!=mst_initPostcodeText))){$("#txt-pcode-list").val(b)}}}};