google.load("jquery","1.3.2");google.load("jqueryui","1.7.2");google.setOnLoadCallback(function(){var config={mouseDownOnSelect:false};var searchBox=$(".searchbox");var searchbutton=$(".searchbutton");var searchResultHolder=$("#suggestions");searchBox.attr("autocomplete","off");searchBox.click(function(){if(searchBox.val()=="Search..."){this.value=""}});searchbutton.click(function(){if(searchBox.val()=="Search..."||searchBox.val()==""){searchBox.focus();searchBox.val("");return false}});var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};searchBox.blur(function(){if(!config.mouseDownOnSelect){$("#searchresults").fadeOut(400)}});searchResultHolder.mousedown(function(){config.mouseDownOnSelect=true}).mouseup(function(){config.mouseDownOnSelect=false});var selectedIndex=-1;searchBox.bind("keydown",function(e){if(e.keyCode==KEY.RETURN||e.keyCode==KEY.TAB){return false}});searchBox.bind("keyup",function(event){if(!config.mouseDownOnSelect&&event.keyCode==KEY.RETURN){eval($(".searchbutton").attr("href"))}else{config.mouseDownOnSelect=false;var searchResultItems=$("#searchresults li a");switch(event.keyCode){case KEY.UP:if(selectedIndex>0){selectedIndex--;$(searchResultItems[selectedIndex+1]).toggleClass("selected");$(searchResultItems[selectedIndex]).toggleClass("selected")}config.mouseDownOnSelect=true;break;case KEY.DOWN:case KEY.TAB:config.mouseDownOnSelect=true;if(selectedIndex<searchResultItems.length-1){selectedIndex++;if(selectedIndex>0){$(searchResultItems[selectedIndex-1]).toggleClass("selected")}$(searchResultItems[selectedIndex]).toggleClass("selected")}config.mouseDownOnSelect=true;break;case KEY.RETURN:config.mouseDownOnSelect=false;var item=$(searchResultItems[selectedIndex]);if(item.hasClass("suggestionText")){selectedIndex=-1;item.trigger("click")}else{window.location=item.attr("href")}break;default:selectedIndex=-1;jQuery.fn.performAjaxSearch($(this).val(),false,event);break}return true}});jQuery.fn.performAjaxSearch=function(searchText,resetSearchText,event){if(resetSearchText){searchBox.val(searchText)}if(searchText.length==0){$("#searchresults").fadeOut(400)}else{if(searchText.length>2){$.ajax({contentType:"text/html; charset=utf-8",data:"queryString="+searchText,url:"http://www.redbridge.gov.uk/search.aspx",dataType:"html",success:function(data){searchResultHolder.html(data);var searchresults=$("#searchresults");$("#searchresults li a").mouseover(function(){selectedIndex=jQuery.inArray(this,$("#searchresults li a"))});if(searchText.length==3){searchresults.fadeIn(400)}else{searchresults.show()}}})}}};jQuery.fn.focusRadioIEFix=function(){if($.browser.msie){this.each(function(index){if(this.hasChildNodes&&this.childNodes.item(0).tagName=="IMG"){this.childNodes.item(0).forid=this.htmlFor;this.childNodes.item(0).onclick=function(){var e=$("#"+this.forid)[0];if(e.type=="radio"){e.checked|=1}}}})}};jQuery.fn.focusOnFirstItem=function(){$(this)[0].onfocusout=function(){$("input:text:first").focus()}};jQuery.fn.ShowUploadProgress=function(btn,validate,uploadDivId){if(validate){Page_ClientValidate();if(typeof(Page_IsValid)!="undefined"&&Page_IsValid){btn.style.display="none";$("#"+uploadDivId)[0].style.display="block";return true}return false}else{btn.style.display="none";$("#"+uploadDivId)[0].style.display="block";return true}};jQuery.fn.FindPos=function(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent);return[curleft,curtop]}};jQuery.fn.RatingSetup=function(RatingHolderId,rating,contentId,callback){jQuery.fn.WhenReady(RatingHolderId,function(){$("#RatingPopup").dialog({autoOpen:false,modal:true,width:300,height:100,resizable:false});$("#rateMsg").html("");var starList=$(".star-rating");PageMethods.LoggedIn(function(isLoggedIn){var rateable=true;if(isLoggedIn){starList.each(function(index){if(rating>0&&index<=rating-1){$(this).addClass("star-rating-on")}$(this).unbind("mouseover").mouseover(function(){if(rateable==true){starList.removeClass("star-rating-on").removeClass("star-rating-hover");highlightStars($(this).attr("id"),"star-rating-hover")}});$(this).unbind("click").click(function(){if(rateable==true){var starId=$(this).attr("id");highlightStars(starId,"star-rating-on");starList.addClass("star-rating-readonly");rateable=false;var rateVal=starId.replace("Star","");callback(rateVal,contentId);$("#rateMsg").html(" <strong>rating saved</strong>")}})})}else{starList.each(function(index){if(rating>0&&index<=rating-1){$(this).addClass("star-rating-on")}$(this).addClass("star-rating-readonly");$(this).click(function(){var secureRoot=$("#secureRootUrl > input").val();var popup=$("#RatingPopup");popup.html("You need to be logged in to rate a map location. Would you like to log in now");popup.dialog("open");popup.dialog("option","buttons",{No:function(){popup.dialog("close")},Yes:function(){window.location=secureRoot+"/Secure/LoginOrRegister.aspx?ReturnUrl=%2fMap%2fDefault.aspx%3faction%3dview%26guid%3d"+contentId;popup.dialog("close")}});popup.dialog("option","draggable",false)})})}})})};function highlightStars(starId,cssClass){var selectedStar=starId.replace("Star","");for(var i=1;i<=selectedStar;i++){$("#Star"+i).addClass(cssClass)}}jQuery.fn.WhenReady=function(id,callback){var interval=setInterval(function(){var element=document.getElementById(id);if(element){clearInterval(interval);callback(element)}},10)};jQuery.fn.ShowStreetView=function(lat,lng,svYaw,svPitch,svZoom){var streetview;$("#StreetViewHolder").show();if($("#MapCategories").length){$("#MapCategories").hide()}var point=new GLatLng(lat,lng);if(typeof(svYaw)!="undefined"){myPov={yaw:svYaw,pitch:svPitch,zoom:svZoom};svOpts={latlng:point,pov:myPov};streetview=new GStreetviewPanorama($("#StreetView")[0],svOpts)}else{svOpts={latlng:point};streetview=new GStreetviewPanorama($("#StreetView")[0],svOpts)}GEvent.addListener(streetview,"error",handleNoFlash)};var yawchangedListener;var pitchchangedListener;var zoomchangedListener;var streetViewMoveListener;var errorListener;jQuery.fn.EditStreetView=function(performGeocode){var streetview;$("#StreetViewHolder").show();if(typeof(marker)=="undefined"){alert("Error: the variable marker needs to be set on the calling page before you use EditStreetView")}else{var point=marker.getLatLng();var svYaw=parseFloat($(".StreetViewYawValue").val());var svPitch=parseFloat($(".StreetViewPitchValue").val());var svZoom=parseFloat($(".StreetViewZoomValue").val());if(svYaw!=0){myPov={yaw:svYaw,pitch:svPitch,zoom:svZoom};svOpts={latlng:point,pov:myPov};streetview=new GStreetviewPanorama($("#StreetView")[0],svOpts)}else{svOpts={latlng:point};streetview=new GStreetviewPanorama($("#StreetView")[0],svOpts)}yawchangedListener=GEvent.addListener(streetview,"yawchanged",function(y){$(".StreetViewYawValue").val(y)});pitchchangedListener=GEvent.addListener(streetview,"pitchchanged",function(p){$(".StreetViewPitchValue").val(p)});zoomchangedListener=GEvent.addListener(streetview,"zoomchanged",function(z){$(".StreetViewZoomValue").val(z)});streetViewMoveListener=GEvent.addListener(streetview,"initialized",function(a){marker.setLatLng(a.latlng);$(".LatitudeValue").val(a.latlng.lat());$(".LongitudeValue").val(a.latlng.lng());if(performGeocode){geocode(marker.getLatLng(),marker)}});errorListener=GEvent.addListener(streetview,"error",handleNoFlash)}};jQuery.fn.CloseStreetView=function(){$("#StreetViewHolder").hide();if(typeof(yawchangedListener)!="undefined"){GEvent.removeListener(yawchangedListener)}if(typeof(pitchchangedListener)!="undefined"){GEvent.removeListener(pitchchangedListener)}if(typeof(zoomchangedListener)!="undefined"){GEvent.removeListener(zoomchangedListener)}if(typeof(streetViewMoveListener)!="undefined"){GEvent.removeListener(streetViewMoveListener)}if(typeof(errorListener)!="undefined"){GEvent.removeListener(errorListener)}};function handleNoFlash(errorCode){if(errorCode==603){$("#StreetViewHolder").hide();if(confirm("To use street view, you need Adobe Flash Player version 9 or newer, Would you like to Get the latest Flash Player?")){window.location="http://get.adobe.com/flashplayer/"}return}}jQuery.fn.AddPolygon=function(encodedPoints,encodedLevels,color,zoom,type){var shape=null;if(type=="POLYGON"){polygon=new GPolygon.fromEncoded({polylines:[{points:encodedPoints,levels:encodedLevels,color:color,weight:2,numLevels:4,zoomFactor:zoom}],fill:true,color:color,outline:true});map.addOverlay(polygon);return polygon}else{line=GPolyline.fromEncoded({color:color,weight:6,points:encodedPoints,zoomFactor:2,levels:encodedLevels,numLevels:4});map.addOverlay(line);return line}};jQuery.fn.ShowHidePostcodeEdit=function(show){if(show){$("#ViewHome").fadeOut(200,function(){$("#EditHome").fadeIn(200)})}else{$("#EditHome").fadeOut(200,function(){$("#ViewHome").fadeIn(200)})}return false}});