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(g_pRfgRadiusInProgress.fDistance>0.05){try{var C=2;var A=RfgGenerateCirclePoints(g_pRfgRadiusInProgress.pCenterPoint.Latitude,g_pRfgRadiusInProgress.pCenterPoint.Longitude,g_pRfgRadiusInProgress.fDistance);
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 RfgRadiusDrawOnMouseDown(A){if(!A){A=window.event}if(g_pRfgRadiusInProgress.bInDrag){RfgRadiusDrawOnMouseUp(A);return }g_pRfgRadiusInProgress.startX=A.pageX?A.pageX:A.clientX;
g_pRfgRadiusInProgress.startY=A.pageY?A.pageY:A.clientY;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
}function RfgRadiusDrawOnMouseUp(A){if(!A){A=window.event}if(!g_pRfgRadiusInProgress.bInDrag){return }g_pRfgRadiusInProgress.endX=A.pageX?A.pageX:A.clientX;g_pRfgRadiusInProgress.endY=A.pageY?A.pageY:A.clientY;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)
}function RfgRadiusDrawOnMouseMove(A){if(!g_pRfgRadiusInProgress.bInDrag){return }if(!A){A=window.event}g_pRfgRadiusInProgress.endX=A.pageX?A.pageX:A.clientX;g_pRfgRadiusInProgress.endY=A.pageY?A.pageY:A.clientY;rfgDrawRadiusInProgress()}function RfgStartRadiusDrawMode(strMapObjectId,pCallback,bAlwaysNull){var pMap=g_pRfgMapContainer[strMapObjectId];if(pMap){try{pMap.HideDashboard();var pMapContainerDiv=document.getElementById(strMapObjectId);var iMapWidth=parseInt(pMapContainerDiv.offsetWidth);var iMapHeight=parseInt(pMapContainerDiv.offsetHeight);
if(g_pRfgRadiusDrawLayers[strMapObjectId]){if(bAlwaysNull==null){setTimeout(function(){RfgStartRadiusDrawMode(strMapObjectId,pCallback,true)},50);return }}else{g_pRfgRadiusDrawLayers[strMapObjectId]=new Object();g_pRfgRadiusDrawLayers[strMapObjectId].mask=document.createElement("div");g_pRfgRadiusDrawLayers[strMapObjectId].mask.id="radiusdrawmask_"+strMapObjectId}g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.top="0px";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.left="0px";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.width=iMapWidth+"px";
g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.height=iMapHeight+"px";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.filter="alpha(opacity=05)";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.opacity=0.05;g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.MozOpacity=0.05;g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.background="#000";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.display="block";g_pRfgRadiusDrawLayers[strMapObjectId].mask.style.visibility="visible";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;g_pRfgRadiusDrawLayers[A].mask.style.display="none";C.DeleteControl(g_pRfgRadiusDrawLayers[A].mask)}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)}}};