function initialize(n){var t=!0,i;n=="mapCanvas_pop"&&(t=!1);bounds=new google.maps.LatLngBounds;i=arrLatLng.length>0?{zoom:11,scrollwheel:!0,disableDefaultUI:t,zoomControl:!0,mapTypeId:google.maps.MapTypeId.ROADMAP}:{zoom:11,scrollwheel:!0,disableDefaultUI:t,zoomControl:!0,mapTypeId:google.maps.MapTypeId.ROADMAP};(n==null||n=="undefined")&&(n="mapCanvas");mapDiv=n;(map===undefined||map=="undefined")&&(map=new google.maps.Map(document.getElementById(n),i))}function setCenter(n,t){try{if((t==null||t=="undefined")&&(t="mapCanvas"),initialize(t),n!=null&&displayMarkerWithLatLng(),n!=null&&(n=="detail"||n=="nearby")&&setPoint($("#address").val(),0,"/img/map/map-red.png"),n=="detail"?($('a[id="mapLocation"]').attr("class","mapTab selector active"),$('a[id="mapNearby"]').attr("class","mapTab selector")):n=="nearby"&&($('a[id="mapLocation"]').attr("class","mapTab selector"),$('a[id="mapNearby"]').attr("class","mapTab selector active")),arrLatLng.length>=0){var i=google.maps.event.addListener(map,"idle",function(){map.fitBounds(bounds);google.maps.event.removeListener(i)});google.maps.event.addListener(map,"zoom_changed",function(){var n=google.maps.event.addListener(map,"bounds_changed",function(){this.getZoom()>13&&this.setZoom(13);google.maps.event.removeListener(n)})})}map.fitBounds(bounds)}catch(r){}}function displayMarkerWithLatLng(){var n,t,i;try{for(n=0;n<arrLatLng.length;n++)t=new google.maps.LatLng(arrLatLng[n][0],arrLatLng[n][1]),bounds.extend(t),i=new google.maps.Marker({position:t,map:map,icon:"/img/map/map-"+arrMarker[n]+".png",shadow:getMakerShadow()}),addListnerForDetail(i,arrCarID[n])}catch(r){}}function addListnerForDetail(n,t){var i=google.maps.event.addListener(n,"click",function(){CreateDetailPop(n,t)})}function setPoint(n,t,i){try{var r;arrDetail[0][0]=="undefined"||arrDetail[0][0]=="NaN"||arrDetail[0][0]==null||(r=new google.maps.LatLng(arrDetail[0][0],arrDetail[0][1]),bounds.extend(r),addMarker(r,t,i))}catch(u){}}function addMarker(n,t,i){try{var r=new google.maps.Marker({position:n,map:map,icon:i!=null&&i!="undefined"?i:"/img/map/bluePin"+String.fromCharCode(idx+65)+".png",shadow:getMakerShadow()})}catch(u){}}function getMakerShadow(){try{return new google.maps.MarkerImage("http://www.drivemycarrentals.com.au/img/map/Marker_Shadow.png",new google.maps.Size(31,26),new google.maps.Point(0,0),new google.maps.Point(10,26))}catch(t){}}function enlarge(){$(".mapBlock").hasClass("enlarged")?($(".mapBlock").removeClass("enlarged"),$("#mapEnlarge").html("Enlarge Map View"),$("#car-list").css("margin-top","0"),$("#mapNotes").css("margin-top","0px"),$("#mapHolder").css("left",""),$("#mapHolder").css("width","")):($(".mapBlock").addClass("enlarged"),$("#mapEnlarge").html("Reduce Map View"),$("#car-list").css("margin-top","450px"),$("#mapNotes").css("margin-top","110px"),$("#mapHolder").css("left","-645px"),$("#mapHolder").css("width","945px"));var n=map.getCenter();google.maps.event.trigger(map,"resize");map.setCenter(n)}function CreateCarDetailWin(n){try{var t,i;n.icon=="/img/map/bluePinD.png"&&(t=arrCarID[0]);$.ajax({url:"/Home/CarDetailForMap/",dataType:"json",type:"POST",data:{id:t},success:function(t){if(t!=null)var i=new SmartInfoWindow({position:n.getPosition(),map:map,content:CarMapDetail(t)})},error:function(t){if(t.status!=0&&t.statusText!="")var i=new SmartInfoWindow({position:n.getPosition(),map:map,content:"Fail to load car details."})},complete:function(){return i}})}catch(r){}}function CreateDetailPop(n,t){try{var i;$.ajax({url:"/Search/CarDetailForMap/",dataType:"json",type:"POST",data:{id:t},success:function(t){if(t!=null)var i=new SmartInfoWindow({position:n.getPosition(),map:map,content:CarMapDetail(t)})},error:function(t){if(t.status!=0&&t.statusText!="")var i=new SmartInfoWindow({position:n.getPosition(),map:map,content:"Fail to load car details."})},complete:function(){return i}})}catch(r){}}function CarMapDetail(n){var t;try{return t=n.rtnTitle,t.length>25&&(t=t.substring(0,24)+"..."),"<div id=mappop class=CarInfoPop><table border=0 width=100% cellpadding=3 cellspacing=0><tr><td colspan=2 align=center><a href='"+n.rtnUrl+"'>"+t+"<\/a><tr><td width=80><img src='/UserImages/"+n.rtnImage+"' width=90 height=60 alt='"+t+"' /><\/td><td width=100% align=right>"+n.rtnAddr+"<br/><b>"+n.rtnRate+"<\/b> / day<\/td><\/tr><\/table><\/div>"}catch(i){}}function SmartInfoWindow(n){google.maps.OverlayView.call(this);this.latlng_=n.position;this.content_=n.content;this.map_=n.map;this.height_=101;this.width_=190;this.size_=new google.maps.Size(this.height_,this.width_);this.offsetVertical_=-this.height_;this.offsetHorizontal_=0;this.panned_=!1;this.setMap(this.map_);var t=this;google.maps.event.addListener(this.map_,"bounds_changed",function(){t.draw()})}function closeInfoWin(n,t){t!="undefined"&&t!=null&&n.removeChild(t)}var map,infoWindow,geocoder=new google.maps.Geocoder,bounds=new google.maps.LatLngBounds;SmartInfoWindow.prototype=new google.maps.OverlayView;SmartInfoWindow.prototype.onRemove=function(){this.div_&&(this.div_.parentNode.removeChild(this.div_),this.div_=null)};SmartInfoWindow.prototype.onAdd=function(){this.createElement()};SmartInfoWindow.prototype.draw=function(){try{if(!this.getProjection())return;var n=this.getProjection().fromLatLngToDivPixel(this.latlng_),i=this.getProjection().fromLatLngToDivPixel(this.map_.getCenter()),r=new google.maps.Point(this.map_.getDiv().offsetWidth/2,this.map_.getDiv().offsetHeight/2),e=-i.x+r.x-10,o=-i.y+r.y-15;if(!n)return;var s=this.getBestAlignment(),u=0,f=0,t=0;switch(s){case SmartInfoWindow.Align.ABOVE:this.width_=190;this.height_=101;image="infobox_above.gif";this.offsetX_=-(this.width_/2-10);this.offsetY_=-(this.height_+15);break;case SmartInfoWindow.Align.BELOW:this.width_=190;this.height_=90;image="infobox_below.gif";this.offsetX_=-(this.width_/2-17);this.offsetY_=-15;u=20;break;case SmartInfoWindow.Align.LEFT:this.width_=307;this.height_=326;image="infobox_left.gif";this.offsetX_=-this.width_+10;this.offsetY_=-(this.height_/2+33);t=20;break;case SmartInfoWindow.Align.RIGHT:image="infobox_right.gif";this.width_=307;this.height_=326;this.offsetX_=6;this.offsetY_=-(this.height_/2+33);f=20;t=20}this.div_.style.width=this.width_+"px";this.div_.style.left=n.x+this.offsetX_+e+"px";this.div_.style.height=this.height_+"px";this.div_.style.top=n.y+this.offsetY_+o+"px";this.div_.style.display="block";this.wrapperDiv_.style.width=this.width_-t+"px";this.wrapperDiv_.style.height=this.height_+"px";this.wrapperDiv_.style.marginTop=u+"px";this.wrapperDiv_.style.marginLeft=f+"px";this.wrapperDiv_.style.overflow="hidden";this.panned_||(this.panned_=!0,this.maybePanMap())}catch(h){}};SmartInfoWindow.prototype.createElement=function(){var o=this.getPanes(),n=this.div_,s=document.getElementById(mapDiv),h=document.getElementById("detailPop"),e,i,t,r,u,f;if(n)n.parentNode!=o.floatPane&&(n.parentNode.removeChild(n),o.floatPane.appendChild(n));else{closeInfoWin(s,h);n=this.div_=document.createElement("div");n.id="detailPop";n.style.border="0px none";n.style.position="absolute";n.style.overflow="hidden";e=this.wrapperDiv_=document.createElement("div");i=document.createElement("div");typeof this.content_=="string"?i.innerHTML=this.content_:i.appendChild(this.content_);i.style.backgroundColor="#FFFFFF";i.style.height="90px";i.style.border="1px solid #3F5765";i.style.padding="5px";t=document.createElement("div");t.style.textAlign="right";t.style.width="0px";t.style.height="0px";t.style.position="relative";t.style.padding="0 0 0 0";t.style.left="176px";t.style.top="2px";r=document.createElement("img");r.src="/img/map/closeInfoWin.png";r.style.width="12px";r.style.height="12px";r.style.verticalAlign="top";r.style.cursor="pointer";t.appendChild(r);function c(n){return function(){n.setMap(null)}}google.maps.event.addDomListener(r,"click",c(this));u=document.createElement("div");u.style.textAlign="center";u.style.margin="0";u.style.padding="0";u.style.height="6px";f=document.createElement("img");f.src="/img/map/blue_beak.png";f.style.width="8px";f.style.height="6px";f.style.verticalAlign="top";u.appendChild(f);e.appendChild(t);e.appendChild(i);e.appendChild(u);n.appendChild(e);n.style.display="none";s.appendChild(n)}};SmartInfoWindow.mouseFilter=function(n){n.returnValue="true";n.handled=!0};SmartInfoWindow.prototype.close=function(){this.setMap(null)};SmartInfoWindow.prototype.maybePanMap=function(){var n=this.map_,i=this.getProjection(),o=n.getBounds();if(o){var s=this.width_,h=this.height_,r=this.offsetX_,u=this.offsetY_-30,t=i.fromLatLngToDivPixel(this.latlng_),c=new google.maps.Point(t.x+r+20,t.y+u+h),l=new google.maps.Point(t.x+r+s,t.y+u),f=i.fromDivPixelToLatLng(c),e=i.fromDivPixelToLatLng(l);n.getBounds().contains(e)&&n.getBounds().contains(f)||n.panToBounds(new google.maps.LatLngBounds(f,e))}};SmartInfoWindow.Align={ABOVE:0,LEFT:1,RIGHT:2,BELOW:3};SmartInfoWindow.prototype.getBestAlignment=function(){var n=SmartInfoWindow.Align.ABOVE;return n};SmartInfoWindow.prototype.getPanValue=function(n){var r=new google.maps.Size(this.map_.getDiv().offsetWidth,this.map_.getDiv().offsetHeight),i=this.map_.getBounds(),t;switch(n){case SmartInfoWindow.Align.ABOVE:t=new google.maps.LatLng(i.getNorthEast().lat(),this.latlng_.lng());break;case SmartInfoWindow.Align.BELOW:t=new google.maps.LatLng(i.getSouthWest().lat(),this.latlng_.lng());break;case SmartInfoWindow.Align.RIGHT:t=new google.maps.LatLng(this.latlng_.lat(),i.getNorthEast().lng());break;case SmartInfoWindow.Align.LEFT:t=new google.maps.LatLng(this.latlng_.lat(),i.getSouthWest().lng())}return SmartInfoWindow.distHaversine(this.latlng_.lat(),this.latlng_.lng(),t.lat(),t.lng())};SmartInfoWindow.toRad=function(n){return n*Math.PI/180};SmartInfoWindow.distHaversine=function(n,t,i,r){var u=SmartInfoWindow.toRad(i-n),f=SmartInfoWindow.toRad(r-t);n=SmartInfoWindow.toRad(n);i=SmartInfoWindow.toRad(i);var e=Math.sin(u/2)*Math.sin(u/2)+Math.cos(n)*Math.cos(i)*Math.sin(f/2)*Math.sin(f/2),o=2*Math.atan2(Math.sqrt(e),Math.sqrt(1-e));return 6371*o}