ErmJS.Controls.GoogleMap=new Class({initialize:function(A){this.loadFunctions=[];this.preLoadFunctions=[];this.mapTarget=A.mapTarget;this.centrePoint=A.centrePoint;this.zoom=A.zoom;this.maximumZoom=A.maxZoom;this.minimumZoom=A.minZoom;window.addEvent("domready",this.makeMap.bind(this));window.addEvent("unload",function(){GUnload()});this.BluePin=this.makePin("blue","newpin");this.tinyBluePin=this.makeTinyPin("blue","newpin");this.RedPin=this.makePin("red","newpin");this.BlueHouse=this.makePin("blue","house");this.RedHouse=this.makePin("red","house")},addEvent:function(A,B){if(A=="load"){this.loadFunctions.push(B)}else{this.preLoadFunctions.push(B)}},makeMap:function(){this.preLoadFunctions.each(function(C){C.run()});var B=G_DEFAULT_MAP_TYPES;for(var A=0;A<B.length;A++){B[A].getMaximumResolution=function(C){return this.maximumZoom}.bind(this);B[A].getMinimumResolution=function(C){return this.minimumZoom}.bind(this)}this.map=new GMap2(this.mapTarget,{"mapTypes":B});GEvent.addListener(this.map,"load",function(){this.loadFunctions.each(function(C){C.run()})}.bind(this));this.CenterMap(this.zoom)},CenterMap:function(A){this.map.setCenter(new GLatLng(this.centrePoint.Latitude,this.centrePoint.Longitude),A)},CopyrightCheck:function(){var C=this.map.getCurrentMapType().getCopyrights(this.map.getBounds(),this.map.getZoom());if(C.length>0){$clear(this.CopyrightCheckInstance);var D=C[0].copyrightTexts[0];if(D.split(" ").length>1){D=D.split(" ")[0]}var B=this.map.getContainer().getLast();if(B!=null&&B.getChildren().length>0){B=B.getChildren()[1];var A=this.map.getContainer().getSize();var E=B.getParent().getSize();if(E.x>A.x-70){B.set("html",B.get("html").replace(D,"<br/>"+D))}}}},makePin:function(C,B){var A=new GIcon(G_DEFAULT_ICON);A.image="http://www.easyroommate.com/images/buttons/maps/"+C+B+".png";A.shadow="http://www.easyroommate.com/images/buttons/maps/"+B+"_back.png";if(B=="pin"){A.iconSize=new GSize(23,42);A.shadowSize=new GSize(41,42);A.iconAnchor=new GPoint(4,40);A.imageMap=[0,0,23,0,23,42,0,42];A.infoWindowAnchor=new GPoint(9,2)}else{if(B=="house"){A.iconSize=new GSize(32,34);A.shadowSize=new GSize(47,32);A.iconAnchor=new GPoint(17,33);A.imageMap=[0,0,34,0,34,32,0,34];A.infoWindowAnchor=new GPoint(9,2)}else{A.iconSize=new GSize(23,31);A.shadowSize=new GSize(39,31);A.iconAnchor=new GPoint(12,30);A.imageMap=[0,0,23,0,23,31,0,31];A.infoWindowAnchor=new GPoint(9,2)}}return new GIcon(A)},makeTinyPin:function(B){var A=new GIcon(G_DEFAULT_ICON);A.image="http://www.easyroommate.com/images/buttons/maps/"+B+"newpin_small.png";A.shadow="http://www.easyroommate.com/images/buttons/maps/newpin_small_back.png";A.iconSize=new GSize(16,22);A.imageMap=[0,0,22,0,22,16,0,16];A.shadowSize=new GSize(28,22);A.iconAnchor=new GPoint(9,22);A.infoWindowAnchor=new GPoint(9,2);return new GIcon(A)},getBearingBetweenPoints:function(E,G){var H=E.lat()*Math.PI/180;var D=G.lat()*Math.PI/180;var B=(G.lng()-E.lng())*Math.PI/180;var A=Math.sin(B)*Math.cos(D);var C=Math.cos(H)*Math.sin(D)-Math.sin(H)*Math.cos(D)*Math.cos(B);var F=(Math.atan2(A,C)*180/Math.PI)%360;return F}});ErmJS.Controls.LightMarkers=function(){this.layer=null;this.node=null};ErmJS.Controls.LightMarkers.prototype=new GOverlay();ErmJS.Controls.LightMarkers.prototype.initialize=function(A){this.map=A;this.node=new Element("div");this.map.getPane(G_MAP_MARKER_PANE).adopt(this.node);this.shadowZIndex=this.map.getPane(G_MAP_MARKER_PANE).getStyle("z-index").toInt()+1;this.pinZIndex=this.shadowZIndex+1;this.markers=[];this.redraw(true);this.Visible=true};ErmJS.Controls.LightMarkers.prototype.addMarkers=function(A){this.markers.extend(A);this.markers.sort(function(B,C){return B.point.Latitude-C.point.Latitude})};ErmJS.Controls.LightMarkers.prototype.removeMarker=function(A){this.markers.erase(A)};ErmJS.Controls.LightMarkers.prototype.clearMarkers=function(){this.markers.empty()};ErmJS.Controls.LightMarkers.prototype.setVisible=function(A){if(!A){this.node.setStyle("display","none")}else{this.node.setStyle("display","block")}this.Visible=A};ErmJS.Controls.LightMarkers.prototype.redraw=function(G,I){if(this.Visible==true&&(G==true||I!=null)){var E=this.map.getSize();var D={NorthEast:this.map.fromContainerPixelToLatLng(new GPoint(E.width*2,0-E.height)),SouthWest:this.map.fromContainerPixelToLatLng(new GPoint(0-E.width,E.height*2))};var B;if(G==true){B=this.markers.filter(function(J){if(J.point.Latitude<=D.NorthEast.lat()&&J.point.Latitude>=D.SouthWest.lat()&&J.point.Longitude>=D.SouthWest.lng()&&J.point.Longitude<=D.NorthEast.lng()){return true}else{return false}})}else{B=I;B.sort(function(J,K){return J.point.Latitude-K.point.Latitude})}var A=B.length;var H=[];var F=[];while(A--){if(B[A].animateFirstDrop){F.push(B[A])}var C=this.map.fromLatLngToDivPixel(new GLatLng(B[A].point.Latitude,B[A].point.Longitude));H.push("<div id='"+B[A].id+"' class='lightpin"+B[A].color+"' style='left:"+C.x+"px;top: "+C.y+"px; z-index:"+this.pinZIndex+";"+(B[A].animatefirstdrop?"opacity:0":"")+"'></div>");if($(document.body).hasClass("ie6")==false){H.push("<div class='lightpinshadow' style='left:"+C.x+"px;top: "+C.y+"px; z-index:"+this.shadowZIndex+"'></div>")}}if(G==true){this.node.innerHTML=H.join("")}else{this.node.innerHTML+=H.join("")}A=F.length;while(A--){$(F[A].id).setStyle("top",$(F[A].id).getStyle("top").toInt()-50);$(F[A].id).set("morph",{duration:"long",transition:"bounce:out"});$(F[A].id).morph({opacity:1,top:$(F[A].id).getStyle("top").toInt()+50});F[A].animateFirstDrop=false}}};ErmJS.Controls.LightMarkers.prototype.getNode=function(){return this.node};ErmJS.Controls.TextMarkers=function(){this.layer=null;this.node=null};ErmJS.Controls.TextMarkers.prototype=new GOverlay();ErmJS.Controls.TextMarkers.prototype.initialize=function(A){this.map=A;this.node=new Element("div");this.map.getPane(G_MAP_MARKER_PANE).adopt(this.node);this.shadowZIndex=this.map.getPane(G_MAP_MARKER_PANE).getStyle("z-index").toInt()+1;this.pinZIndex=this.shadowZIndex+1;this.markers=[];this.redraw(true);this.Visible=true};ErmJS.Controls.TextMarkers.prototype.addMarkers=function(A){this.markers.extend(A)};ErmJS.Controls.TextMarkers.prototype.clearMarkers=function(){this.markers.empty()};ErmJS.Controls.TextMarkers.prototype.setVisible=function(A){if(!A){this.node.setStyle("display","none")}else{this.node.setStyle("display","block")}this.Visible=A};ErmJS.Controls.TextMarkers.prototype.redraw=function(J,O){if(this.Visible&&(J==true||O!=null)){var G=this.map.getSize();var A=this.node.getPosition(this.map.getContainer());var F={NorthEast:this.map.fromContainerPixelToLatLng(new GPoint(G.width*2,0-G.height)),SouthWest:this.map.fromContainerPixelToLatLng(new GPoint(0-G.width,G.height*2))};var C=this.markers;var K=C.length;var N=[];while(K--){var I=$("marker"+C[K].id);var D=this.map.fromLatLngToDivPixel(C[K].Point);if(I==null){I=new Element("div",{id:"marker"+C[K].id,styles:{position:"absolute",visibility:"hidden",left:D.x,top:D.y,"z-index":this.pinZIndex}});var H=new Element("span",{"class":"maptextmarkerarrow",styles:{"z-index":this.pinZIndex+1}});var E=new Element("div",{"class":"maptextmarker rounded-5-all",html:C[K].Text});E.addEvent("click",C[K].ClickEvent);I.adopt(H);I.adopt(E);this.node.adopt(I)}else{I.setStyles({left:D.x,top:D.y})}var L=I.getSize();var M=I.getPosition(this.map.getContainer());var B={left:I.getStyle("left").toInt()-Math.round(L.x/2),top:I.getStyle("top").toInt()-Math.round(L.y/2)-12};if(B.left+A.x<0){B.left=(0-A.x)+10}else{if(B.left+A.x>(G.width-L.x)){B.left=(0-A.x)+G.width-L.x-10}}if(B.top+A.y<0){B.top=(0-A.y)+10}else{if(B.top+A.y>(G.height-L.y)){B.top=(0-A.y)+G.height-L.y-10-12}}I.setStyles({"left":B.left,"top":B.top,"visibility":"visible"})}}};ErmJS.Controls.TextMarkers.prototype.getNode=function(){return this.node};