var g_pRfgRadiusDrawLayers=new Array();var g_pRfgRadiusInProgress=null;var g_iRadiusInProgressCount=0;function RfgRadius(){this.pPoly=null;this.startX=0;this.startY=0;this.canvasX=0;this.canvasY=0;this.endX=0;this.endY=0;this.pCenterPoint=null;this.fDistance=0;this.bInDrag=false;this.pCallback=null}function RfgLatLonToRadians(A){return A*g_PI180}function RfgGetDistanceBetweenTwoPoints(H,G){var D=0;try{var L=new Object;var J=new Object;L.Latitude=RfgLatLonToRadians(H.Latitude);L.Longitude=RfgLatLonToRadians(H.Longitude);
J.Latitude=RfgLatLonToRadians(G.Latitude);J.Longitude=RfgLatLonToRadians(G.Longitude);var B=6371;var E=J.Latitude-L.Latitude;var K=J.Longitude-L.Longitude;var I=Math.sin(E/2)*Math.sin(E/2)+Math.cos(L.Latitude)*Math.cos(J.Latitude)*Math.sin(K/2)*Math.sin(K/2);var F=2*Math.atan2(Math.sqrt(I),Math.sqrt(1-I));var A=B*F;var D=A*0.6214}catch(C){alert(C.message)}return(D)}function RfgGenerateCirclePoints(B,C,I){var F=new Array();var E=B*Math.PI/180;var H=C*Math.PI/180;var J=I/3956;var L;for(L=0;L<=360;L++){var D=(L/90)*Math.PI/2;
var K=Math.asin(Math.sin(E)*Math.cos(J)+Math.cos(E)*Math.sin(J)*Math.cos(D));K=180*K/Math.PI;var A;if(Math.cos(E)==0){A=C}else{A=((H-Math.asin(Math.sin(D)*Math.sin(J)/Math.cos(E))+Math.PI)%(2*Math.PI))-Math.PI}A=180*A/Math.PI;if(L%4==0){var G=new VELatLong(K,A);F.push(G)}}return F}function RfgHexStringToColor(B,E){var C=0;var D=0;var A=0;if(E<0||E>1){E=1}if(B.charAt(0)=="#"){B=B.substring(1,6)}if(B.length==6){C=parseInt("0x"+B.substring(0,2));D=parseInt("0x"+B.substring(2,4));A=parseInt("0x"+B.substring(4,6));
if(!(C>=0&&C<=255)){C=0}if(!(D>=0&&D<=255)){D=0}if(!(A>=0&&A<=255)){A=0}}return new VEColor(C,D,A,E)}function RfgShowRadius(J,H,N,M,I,C,G){if(H==0&&N==0){return }if(M<=0){return }var L=g_pRfgMapContainer[J];if(L){try{g_iRadiusSeq++;var D=2;var K=null;var B=null;var F=RfgGenerateCirclePoints(H,N,M);if(C instanceof VEColor){K=C}else{K=RfgHexStringToColor(C,1)}if(G instanceof VEColor){B=G}else{B=RfgHexStringToColor(G,0.2)}var A=new VEPolygon(g_iRadiusSeq,F,B,K,D);L.AddPolygon(A);if(I){L.SetMapView(F)}}catch(E){if(g_bShowErrorInformation){alert(E.message)
}}}}function rfgDrawRadiusInProgress(){var D=RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,(g_pRfgRadiusInProgress.endX-g_pRfgRadiusInProgress.canvasX),(g_pRfgRadiusInProgress.endY-g_pRfgRadiusInProgress.canvasY));g_pRfgRadiusInProgress.fDistance=RfgGetDistanceBetweenTwoPoints(g_pRfgRadiusInProgress.pCenterPoint,D);if(obj("searcharea")){obj("searcharea").innerHTML=parseInt(Math.pow(g_pRfgRadiusInProgress.fDistance,2)*Math.PI)}if(g_pRfgRadiusInProgress.fDistance>0.05){try{var C=2;var A=RfgGenerateCirclePoints(g_pRfgRadiusInProgress.pCenterPoint.Latitude,g_pRfgRadiusInProgress.pCenterPoint.Longitude,g_pRfgRadiusInProgress.fDistance);
g_pRfgRadiusInProgress.aLocs=[new VELatLong(g_pRfgRadiusInProgress.pCenterPoint.Latitude,g_pRfgRadiusInProgress.pCenterPoint.Longitude)];if(g_pRfgRadiusInProgress.pPoly){g_pRfgRadiusInProgress.pMap.DeletePolygon(g_iRadiusInProgressCount)}g_iRadiusInProgressCount++;g_pRfgRadiusInProgress.pPoly=new VEPolygon(g_iRadiusInProgressCount,A,g_pRfgRadiusInProgress.fillColor,g_pRfgRadiusInProgress.edgeColor,C);g_pRfgRadiusInProgress.pMap.AddPolygon(g_pRfgRadiusInProgress.pPoly)}catch(B){}}}function RfgDrawRadius(B,G,D,F){var E=g_pRfgMapContainer[B];
var A=RfgGenerateCirclePoints(D,F,G);var C=new VEPolygon(A.length,A,RfgHexStringToColor("FF0000",0.2),RfgHexStringToColor("FF0000",1),2);E.AddPolygon(C);return C}function RfgDrawPolygon(B){var D=g_pRfgMapContainer[B];var A=[];for(var C=1;C<arguments.length;C+=2){A.push(new VELatLong(arguments[C],arguments[C+1]))}D.AddPolygon(new VEPolygon(A.length,A,RfgHexStringToColor("FF0000",0.2),RfgHexStringToColor("FF0000",1),2))}function RfgRadiusDrawOnMouseDown(B){if(!B){B=window.event}if(g_pRfgRadiusInProgress.bInDrag){RfgRadiusDrawOnMouseUp(B);
return }g_pRfgRadiusInProgress.startX=B.pageX?B.pageX:(B.clientX+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft));g_pRfgRadiusInProgress.startY=B.pageY?B.pageY:(B.clientY+Math.max(document.documentElement.scrollTop,document.body.scrollTop));g_pRfgRadiusInProgress.bNeedsScrollOffset=false;var A=parseFloat(navigator.appVersion.split("MSIE")[1]);if(A>=5.5){g_pRfgRadiusInProgress.bNeedsScrollOffset=true}g_pRfgRadiusInProgress.canvasX=RfgFindPosX(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);
g_pRfgRadiusInProgress.canvasY=RfgFindPosY(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);g_pRfgRadiusInProgress.pCenterPoint=RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,(g_pRfgRadiusInProgress.startX-g_pRfgRadiusInProgress.canvasX),(g_pRfgRadiusInProgress.startY-g_pRfgRadiusInProgress.canvasY));g_pRfgRadiusInProgress.bInDrag=true;if(B.stopPropagation){B.stopPropagation();B.preventDefault()}else{document.onselectstart=function(){return false}}}function RfgRadiusDrawOnMouseUp(A){if(!A){A=window.event
}if(!g_pRfgRadiusInProgress.bInDrag){return }g_pRfgRadiusInProgress.endX=A.pageX?A.pageX:(A.clientX+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft));g_pRfgRadiusInProgress.endY=A.pageY?A.pageY:(A.clientY+Math.max(document.documentElement.scrollTop,document.body.scrollTop));if(g_pRfgRadiusInProgress.endX==g_pRfgRadiusInProgress.startX&&g_pRfgRadiusInProgress.endY==g_pRfgRadiusInProgress.startY){return }rfgDrawRadiusInProgress();g_pRfgRadiusInProgress.bInDrag=false;g_pRfgRadiusInProgress.pCallback(g_pRfgRadiusInProgress);
RfgEndRadiusDrawMode(g_pRfgRadiusInProgress.strMapObjectId);document.onselectstart=null}function RfgRadiusDrawOnMouseMove(A){if(!g_pRfgRadiusInProgress.bInDrag){return }var A=A||event;g_pRfgRadiusInProgress.endX=A.pageX?A.pageX:(A.clientX+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft));g_pRfgRadiusInProgress.endY=A.pageY?A.pageY:(A.clientY+Math.max(document.documentElement.scrollTop,document.body.scrollTop));rfgDrawRadiusInProgress()}function RfgStartRectangleDrawMode(strMapObjectId,pCallback,bAlwaysNull){var pMap=g_pRfgMapContainer[strMapObjectId];
if(pMap){try{var pMapContainerDiv=document.getElementById(strMapObjectId);var iMapWidth=parseInt(pMapContainerDiv.offsetWidth);var iMapHeight=parseInt(pMapContainerDiv.offsetHeight);g_pRfgRadiusDrawLayers[strMapObjectId]=new Object();var g_pRfgDrawLayer=g_pRfgRadiusDrawLayers[strMapObjectId];g_pRfgDrawLayer.mask=RfgCreateMask(strMapObjectId);g_pRfgDrawLayer.mask.onmousedown=function(e){if(!e){e=window.event}var b=document.body;g_pRfgRadiusInProgress.startX=e.pageX?e.pageX:(e.clientX+document.documentElement.scrollLeft);
g_pRfgRadiusInProgress.startY=e.pageY?e.pageY:(e.clientY+document.documentElement.scrollTop);DrawRectangle(g_pRfgRadiusInProgress.startY,g_pRfgRadiusInProgress.startX,10,10);this.onmousemove=MouseMove;if(e.stopPropagation){e.stopPropagation();e.preventDefault()}else{document.onselectstart=function(){return false}}return false};var oTop,oLeft,oWidth,oHeight;function DrawRectangle(top,left,width,height){oTop=top;oLeft=left;oWidth=width;oHeight=height;left-=RfgFindPosX(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);
top-=RfgFindPosY(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);try{var iLineStroke=2;var aLocs=[];aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left,top));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left+width,top));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left+width,top+height));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left,top+height));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left,top));
if(g_pRfgRadiusInProgress.pPoly){g_pRfgRadiusInProgress.pMap.DeletePolygon(g_iRadiusInProgressCount)}g_pRfgRadiusInProgress.pPoly=new VEPolygon(g_iRadiusInProgressCount,aLocs,g_pRfgRadiusInProgress.fillColor,g_pRfgRadiusInProgress.edgeColor,iLineStroke);g_pRfgRadiusInProgress.pMap.AddPolygon(g_pRfgRadiusInProgress.pPoly)}catch(xE){}g_pRfgRadiusInProgress.aLocs=aLocs;if(obj("searcharea")){obj("searcharea").innerHTML=parseInt(RfgGetDistanceBetweenTwoPoints(aLocs[0],aLocs[1])*RfgGetDistanceBetweenTwoPoints(aLocs[0],aLocs[3]))
}}g_pRfgDrawLayer.mask.onmouseup=function(e){g_pRfgRadiusInProgress.pCallback(g_pRfgRadiusInProgress);pMap.DeleteControl(this);g_pRfgRadiusDrawLayers.resultmap.mask=null;document.onselectstart=null};function MouseMove(e){if(!e){e=window.event}var startX=g_pRfgRadiusInProgress.startX;var startY=g_pRfgRadiusInProgress.startY;var oldLeft=oLeft;var oldTop=oTop;var oldHeight=oHeight;var oldWidth=oWidth;var x=e.pageX?e.pageX:e.clientX+document.documentElement.scrollLeft;var y=e.pageY?e.pageY:e.clientY+document.documentElement.scrollTop;
var top=oldTop,left=oldLeft,width=oldWidth,height=oldHeight;if(x>startX){width=x-oldLeft}else{width=oldWidth+(oldLeft-x);left=x}if(y>startY){height=y-oldTop}else{top=y;height=oldHeight+(oldTop-y)}DrawRectangle(top,left,width,height);e.returnValue=false;e.cancelBubble=true;return false}g_pRfgRadiusInProgress={};g_pRfgRadiusInProgress.strMapObjectId=strMapObjectId;g_pRfgRadiusInProgress.pMap=pMap;g_pRfgRadiusInProgress.edgeColor=RfgHexStringToColor("FF0000",1);g_pRfgRadiusInProgress.fillColor=RfgHexStringToColor("FF0000",0.2);
pMap.AddControl(g_pRfgRadiusDrawLayers[strMapObjectId].mask,null);if(typeof pCallback=="string"){g_pRfgRadiusInProgress.pCallback=function(p){eval(pCallback+"(p)")}}else{g_pRfgRadiusInProgress.pCallback=pCallback}}catch(xE){if(g_bShowErrorInformation){alert(xE.message)}RfgAjaxErrorLogger("rfg",exception.message)}}}function RfgCreateMask(strMapId){var mask=document.createElement("div");var pMapContainerDiv=document.getElementById(strMapId);var iMapWidth=parseInt(pMapContainerDiv.offsetWidth);var iMapHeight=parseInt(pMapContainerDiv.offsetHeight);
mask.id="radiusdrawmask_"+strMapId;with(mask.style){top="0px";left="0px";width=iMapWidth+"px";height=iMapHeight+"px";filter="alpha(opacity=05)";opacity=0.05;MozOpacity=0.05;background="#000";display="block";visibility="visible"}return mask}function RfgStartTriangleDrawMode(strMapObjectId,pCallback,bAlwaysNull){var pMap=g_pRfgMapContainer[strMapObjectId];if(pMap){try{var pMapContainerDiv=document.getElementById(strMapObjectId);g_pRfgRadiusDrawLayers[strMapObjectId]=new Object();var g_pRfgDrawLayer=g_pRfgRadiusDrawLayers[strMapObjectId];
g_pRfgDrawLayer.mask=RfgCreateMask(strMapObjectId);g_pRfgDrawLayer.mask.onmousedown=function(e){var e=e||event;g_pRfgRadiusInProgress.startX=e.pageX?e.pageX:(e.clientX+document.documentElement.scrollLeft);g_pRfgRadiusInProgress.startY=e.pageY?e.pageY:(e.clientY+document.documentElement.scrollTop);DrawTriangle(g_pRfgRadiusInProgress.startX,g_pRfgRadiusInProgress.startY,10,10,g_pRfgRadiusInProgress.startX+10,g_pRfgRadiusInProgress.startY+10);this.onmousemove=MouseMove;if(e.stopPropagation){e.stopPropagation();
e.preventDefault()}else{document.onselectstart=function(){return false}}return false};var oTop,oLeft,oWidth,oHeight;function DrawTriangle(top,left,width,height,x,y){var sX=g_pRfgRadiusInProgress.startX;var sY=g_pRfgRadiusInProgress.startY;oTop=top;oLeft=left;oWidth=width;oHeight=height;left-=RfgFindPosX(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);top-=RfgFindPosY(g_pRfgRadiusDrawLayers[g_pRfgRadiusInProgress.strMapObjectId].mask);try{var iLineStroke=2;var aLocs=[];aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left,top));
aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left,top+height));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left+width,top+height));aLocs.push(RfgLatLongFromPixel(g_pRfgRadiusInProgress.strMapObjectId,left+width,top));if(sX>x){if(sY>=y){aLocs.splice(0,1)}else{aLocs.splice(1,1)}}else{if(sY>=y){aLocs.splice(3,1)}else{aLocs.splice(2,1)}}aLocs.push(aLocs[0]);if(g_pRfgRadiusInProgress.pPoly){g_pRfgRadiusInProgress.pMap.DeletePolygon(g_iRadiusInProgressCount)}g_pRfgRadiusInProgress.pPoly=new VEPolygon(g_iRadiusInProgressCount,aLocs,g_pRfgRadiusInProgress.fillColor,g_pRfgRadiusInProgress.edgeColor,iLineStroke);
g_pRfgRadiusInProgress.pMap.AddPolygon(g_pRfgRadiusInProgress.pPoly)}catch(xE){}g_pRfgRadiusInProgress.aLocs=aLocs;if(obj("searcharea")){obj("searcharea").innerHTML=(parseInt(RfgGetDistanceBetweenTwoPoints(aLocs[0],aLocs[1])*RfgGetDistanceBetweenTwoPoints(aLocs[0],aLocs[2])))>>1}}g_pRfgDrawLayer.mask.onmouseup=function(e){g_pRfgRadiusInProgress.pCallback(g_pRfgRadiusInProgress);pMap.DeleteControl(this);g_pRfgRadiusDrawLayers[strMapObjectId].mask=null;document.onselectstart=null};function MouseMove(e){if(!e){e=window.event
}var startX=g_pRfgRadiusInProgress.startX;var startY=g_pRfgRadiusInProgress.startY;var oldLeft=oLeft;var oldTop=oTop;var oldHeight=oHeight;var oldWidth=oWidth;var x=e.pageX?e.pageX:e.clientX+document.documentElement.scrollLeft;var y=e.pageY?e.pageY:e.clientY+document.documentElement.scrollTop;var top=oldTop,left=oldLeft,width=oldWidth,height=oldHeight;if(x>startX){width=x-oldLeft}else{width=oldWidth+(oldLeft-x);left=x}if(y>startY){height=y-oldTop}else{top=y;height=oldHeight+(oldTop-y)}DrawTriangle(top,left,width,height,x,y)
}g_pRfgRadiusInProgress={};g_pRfgRadiusInProgress.strMapObjectId=strMapObjectId;g_pRfgRadiusInProgress.pMap=pMap;g_pRfgRadiusInProgress.edgeColor=RfgHexStringToColor("FF0000",1);g_pRfgRadiusInProgress.fillColor=RfgHexStringToColor("FF0000",0.2);pMap.AddControl(g_pRfgRadiusDrawLayers[strMapObjectId].mask,null);if(typeof pCallback=="string"){g_pRfgRadiusInProgress.pCallback=function(p){eval(pCallback+"(p)")}}else{g_pRfgRadiusInProgress.pCallback=pCallback}}catch(xE){if(g_bShowErrorInformation){alert(xE.message)
}RfgAjaxErrorLogger("rfg",exception.message)}}}function RfgStartRadiusDrawMode(strMapObjectId,pCallback,bAlwaysNull){var pMap=g_pRfgMapContainer[strMapObjectId];if(pMap){try{var pMapContainerDiv=document.getElementById(strMapObjectId);g_pRfgRadiusDrawLayers[strMapObjectId]=new Object();g_pRfgRadiusDrawLayers[strMapObjectId].mask=RfgCreateMask(strMapObjectId);g_pRfgRadiusDrawLayers[strMapObjectId].mask.onmousedown=RfgRadiusDrawOnMouseDown;g_pRfgRadiusDrawLayers[strMapObjectId].mask.onmouseup=RfgRadiusDrawOnMouseUp;
g_pRfgRadiusDrawLayers[strMapObjectId].mask.onmousemove=RfgRadiusDrawOnMouseMove;pMap.AddControl(g_pRfgRadiusDrawLayers[strMapObjectId].mask,null);g_pRfgRadiusInProgress=new RfgRadius();g_pRfgRadiusInProgress.strMapObjectId=strMapObjectId;g_pRfgRadiusInProgress.pMap=g_pRfgMapContainer[strMapObjectId];g_pRfgRadiusInProgress.edgeColor=RfgHexStringToColor("FF0000",1);g_pRfgRadiusInProgress.fillColor=RfgHexStringToColor("FF0000",0.2);if(typeof pCallback=="string"){g_pRfgRadiusInProgress.pCallback=function(p){eval(pCallback+"(p)")
}}else{g_pRfgRadiusInProgress.pCallback=pCallback}}catch(xE){if(g_bShowErrorInformation){alert(xE.message)}RfgAjaxErrorLogger("rfg",exception.message)}}}function RfgEndRadiusDrawMode(A){var C=g_pRfgMapContainer[A];if(C){try{if(g_pRfgRadiusDrawLayers[A]){g_pRfgRadiusDrawLayers[A].mask.onmousedown=null;g_pRfgRadiusDrawLayers[A].mask.onmouseup=null;g_pRfgRadiusDrawLayers[A].mask.onmousemove=null;C.DeleteControl(g_pRfgRadiusDrawLayers[A].mask);g_pRfgRadiusDrawLayers[A].mask=null}g_pRfgRadiusInProgress=new RfgRadius()
}catch(B){if(g_bShowErrorInformation){alert(B.message)}RfgAjaxErrorLogger("rfg",exception.message)}}}function RfgStartPolygonDrawMode(A,C,F,E){var D=g_pRfgMapContainer[A];if(D){try{g_iRadiusSeq++}catch(B){if(g_bShowErrorInformation){alert(B.message)}RfgAjaxErrorLogger("rfg",exception.message)}}}function RfgAutoSizeMapToRadius(F,E){try{var B=new Array();var D=E.pCenterPoint.Latitude;var A=E.pCenterPoint.Longitude;var G=E.fDistance;NorthLoc=new VELatLong(RfgAddMilesToLatitude(D,E.distance),A);SouthLoc=new VELatLong(RfgAddMilesToLatitude(D,(-1*G)),A);
EastLoc=new VELatLong(Latitude,RfgAddMilesToLongitude(A,D,G));WestLoc=new VELatLong(Latitude,RfgAddMilesToLongitude(A,D,(-1*G)));B.push(NorthLoc);B.push(SouthLoc);B.push(EastLoc);B.push(WestLoc);F.SetMapView(B)}catch(C){if(g_bShowErrorInformation){alert(C.message)}}};