var g_DELTA=69.09758507348;
var g_PI180=(3.141952653/180);
var g_EARTH_RADIUS=3963.17;
var g_PI=3.141592653589793;
var g_EARTH_CIR=(2*g_PI*g_EARTH_RADIUS);
var g_MILES_PER_DEGREE_LATITUDE=(g_EARTH_CIR/360);
var g_DEGREES_PER_MILE_LATITUDE=(360/g_EARTH_CIR);
var g_pRfgMapContainer=new Array();
var g_pRfgWaitDlgContainer=new Array();
var g_iPushPinSeq=10000;
var g_iRadiusSeq=0;
var g_bShowErrorInformation=true;
var g_strErrorLogUrlFormat="";
var g_strErrorLogFunction="";
var g_RfgAjaxHandler=null;
var g_bVirtualEarthSupported=true;
var g_bDisableAllBirdseye=false;
var g_iRfgSearchTipPosLeft=0;
var g_iRfgSearchTipPosRight=0;
var g_iRfgSearchTipPosTop=0;
var g_iRfgSearchTipPosBottom=0;
var g_bRfgSearchTipCancelCloseRequest=false;
var g_bRfgSearchTipTimeoutActive=false;
var g_bRfgSearchTipVisible=false;
var g_objRfgLastTooltip=new Object();
var g_bRfgShowDetailsOnMouseOver=true;
var g_pRfgVepOnMouseOverCallback=null;
var g_pLastMapObjectId=null;
var strMapObjectId="";
if(typeof g_aRfgCommandQueue=="undefined")
{
    g_aRfgCommandQueue=new Array()
}
if(typeof g_bRfgOnLoadComplete=="undefined")
{
    g_bRfgOnLoadComplete=false
}
if(!window.onload||window.onload.toString().indexOf("RfgOnPageLoad")==-1)
{
    g_pOldOnLoad=window.onload;
    window.onload=RfgOnPageLoad
}

function RfgQueueCommand(strEncodedCommand)
{
    var strCommand=unescape(strEncodedCommand.replace(/\+/g," "));
    if(!g_bRfgOnLoadComplete)
    {
        g_aRfgCommandQueue.push(strCommand)
    }
    else
    {
        eval(strCommand)
    }
}

function RfgJsErrorHandler(strService,exception)
{
    var bResult=false;
    if(g_strErrorLogFunction!="")
    {
        try
        {
            bResult=eval(g_strErrorLogFunction+"('"+strService+"', exception);")
        }
        catch(e)
        {
         bResult=false
        }
    } 
    return bResult
}

function RfgAjaxErrorLogger(B,C)
{
    if(g_strErrorLogUrlFormat==""){return }if(B=="")
    {
        B=="unknown"}
        if(g_RfgAjaxHandler==null)
        {
            if(window.XMLHttpRequest)
            {
                g_RfgAjaxHandler=new XMLHttpRequest()
            }
            else
            {
                if(window.ActiveXObject)
                {
                    g_RfgAjaxHandler=new ActiveXObject("Microsoft.XMLHTTP")
                }
            }
        }
    if(g_RfgAjaxHandler)
    {
        var A=String.format(g_strErrorLogUrlFormat,escape(C));
        g_RfgAjaxHandler.onreadystatechange=RfgAjaxErrorReplyHandler;g_RfgAjaxHandler.open("GET",A,true);
        g_RfgAjaxHandler.send(null)
    }
}
function RfgAjaxErrorReplyHandler()
{
    if(g_RfgAjaxHandler.readyState==4)
    {
        if(g_RfgAjaxHandler.status==200)
        {
            if(g_RfgAjaxHandler.responseText=="")
            {
                return false;
            }
            else
            {
                try
                {
                    eval(g_RfgAjaxHandler.responseText)
                }
                catch(e){}
            }
        }
    }
}
function IsBrowserVECompliant()
{
    return true;
}
function RfgMapDefaults(D,C,B,A)
{
    this.m_pLatLong=D;
    this.m_iZoomLevel=C;
    this.m_strVeMapStyle=B;
    this.m_bFixedView=A;
}
function rfgGetVeMapStyle(A)
{
    return 1;
//try
//{
//B=1;
//var B= VEMapStyle.Hybrid;
//if(A.toLowerCase()=="aerialve")
//    {B=VEMapStyle.Aerial}
//    else
//    {
//        if(A.toLowerCase()=="roadve")
//            {B=VEMapStyle.Road}
//        else
//        {
//        if(A.toLowerCase()=="hybridve")
//            {B=VEMapStyle.Hybrid}
//        else
//            {
//                if(A.toLowerCase()=="obliqueve")
//                {B=VEMapStyle.Birdseye}
//                else{B=A}
//              }
//          }
//           }return B
//    }
//    catch( B  )
     
}
//-------------------------------------------------------

function RfgCreateMap(strMapObjectId,strMapStyle,bAutoSize,fLatitude,fLongitude,iZoomLevel,bDelayMapRender,bFixedView,callback)
{
    var strMapObjectId="RoadMWS";
    try
    {
        var bForcedFallback=false;
        var bNeedDelayedAutoRender=false;
        g_bVirtualEarthSupported=IsBrowserVECompliant();
        var strCallback=null;
        if(callback&&callback!="")
        {
            strCallback=callback;
        }
        if(strMapStyle.indexOf("MWS")>=0)
        {
            bFixedView=null;
        }
        else
        {
            if(!g_bVirtualEarthSupported)
            {
                bFixedView=null;strMapStyle="RoadMWS";
                bForcedFallback=true;bAutoSize=false;
                if(!bDelayMapRender)
                {   bNeedDelayedAutoRender=true;
                    bDelayMapRender=true
                }
            }
        }
        var pContainerDiv="";
        //var pContainerDiv=document.getElementById(strMapObjectId);
        if(pContainerDiv)
        {
            pContainerDiv.innerHTML="";
        }
           
            var strVeMapStyle=rfgGetVeMapStyle(strMapStyle);

//===========================================================
            if(bDelayMapRender&&bDelayMapRender==true)
            {
            
                //g_pRfgMapContainer[strMapObjectId]=new VEMap(strMapObjectId);
                if(callback&&callback!="")
                {
                    if(typeof callback=="string")
                    {
                        g_pRfgMapContainer[strMapObjectId].onLoadMap=function()
                        {
                            eval(callback+"()")
                        }
                    }
                    else
                    {
                        g_pRfgMapContainer[strMapObjectId].onLoadMap=callback;
                    }
                }
            }
            else
            {
                var g_pRfgMapContainer=new Array();
                //g_pRfgMapContainer[strMapObjectId]=new VEMap(strMapObjectId);

//===========================================================
                if(callback&&callback!="")
                {
                    if(typeof callback=="string")
                    {
                        g_pRfgMapContainer[strMapObjectId].onLoadMap= function()
                        {
                            eval(callback+"()");
                        }
                    }
                    else
                    {
                        g_pRfgMapContainer[strMapObjectId].onLoadMap=callback
                    }
                }
                if(g_bDisableAllBirdseye)
                {
                    var mapOptions=new VEMapOptions();
                    mapOptions.EnableBirdseye=false;
                    g_pRfgMapContainer[strMapObjectId].LoadMap(new VELatLong(fLatitude,fLongitude),iZoomLevel,strVeMapStyle,bFixedView,null,null,null,mapOptions)
                }
                else
                {
                    g_pRfgMapContainer[strMapObjectId].LoadMap(new VELatLong(fLatitude,fLongitude),iZoomLevel,strVeMapStyle,bFixedView)
                }
            }
            g_pRfgMapContainer[strMapObjectId].pRfgMapDefaults=new RfgMapDefaults(new VELatLong(fLatitude,fLongitude),iZoomLevel,strVeMapStyle,bFixedView);
            g_pRfgMapContainer[strMapObjectId].autoSize=bAutoSize;
            g_pRfgMapContainer[strMapObjectId].bRfgMapForcedFallback=bForcedFallback;
            g_pRfgMapContainer[strMapObjectId].AttachEvent("onmouseover",RfgInternalOnMouseOverCallback);
            g_pLastMapObjectId=strMapObjectId;if(bNeedDelayedAutoRender)
            {
                setTimeout(function()
                {RfgRenderMap(strMapObjectId)},1000)
            }
        }
        catch(xE)
        {
            if(g_bShowErrorInformation){alert(xE.message)
        }
    }
}
//-------------------------------------------------------

function RfgRenderMap(A,D)
{var C=g_pRfgMapContainer[A];if(C)
{try{if(C.pRfgMapDefaults){C.LoadMap(C.pRfgMapDefaults.m_pLatLong,C.pRfgMapDefaults.m_iZoomLevel,C.pRfgMapDefaults.m_strVeMapStyle,C.pRfgMapDefaults.m_bFixedView)}}catch(B){if(g_bShowErrorInformation){alert(B.message)}}}}
function RfgShowMapDashboard(B,A)
{var D=g_pRfgMapContainer[B];if(D){if(D.bRfgMapForcedFallback){return }try{if(A){D.ShowDashboard()}else{D.HideDashboard()}}catch(C){if(g_bShowErrorInformation){alert(C.message)}}}}
function RfgGetMapById(A)
{
    return g_pRfgMapContainer[A]
}

function RfgMapEventsEnum()
{
this.ONCLICK="onclick";
this.ONMOUSEUP="onmouseup";this.ONCHANGEVIEW="onchangeview";this.ONCONTEXTMENU="onclick";
this.ONSTARTCONTINUOUSPAN="onstartpan";this.ONENDCONTINUOUSPAN="onendpan";
this.ONSTARTZOOM="onstartzoom";this.ONENDZOOM="onendzoom";
this.ONERROR="onerror";this.ONCHANGEMAPSTYLE="onchangemapstyle";
this.ONOBLIQUECHANGE="onobliquechange";
this.ONOBLIQUEENTER="onobliqueenter";this.ONOBLIQUELEAVE="onobliqueleave";
this.ONDOUBLECLICK="ondoubleclick";this.ONMOUSEMOVE="onmousemove";
this.ONMOUSEOVER="onmouseover";this.ONMOUSEOUT="onmouseout";
this.ONMOUSEDOWN="onmousedown";
this.ONMOUSEWHEEL="onmousewheel";this.ONMODENOTAVAILABLE="onmodenotavailable";
this.ONKEYPRESS="onkeypress";this.ONKEYDOWN="onkeydown";this.ONKEYUP="onkeyup";
this.MWS="MWS";this.VE="VE";this.MWSHash=new Array();this.VEHash=new Array();
this.MWSHash[this.ONCLICK]="1";this.MWSHash[this.ONMOUSEUP]="1";this.VEHash[this.ONCLICK]="1";this.VEHash[this.ONMOUSEUP]="1";this.VEHash[this.ONCHANGEVIEW]="1";this.VEHash[this.ONCONTEXTMENU]="1";
this.VEHash[this.ONENDCONTINUOUSPAN]="1";this.VEHash[this.ONENDZOOM]="1";
this.VEHash[this.ONERROR]="1";this.VEHash[this.ONCHANGEMAPSTYLE]="1";
this.VEHash[this.ONOBLIQUECHANGE]="1";this.VEHash[this.ONOBLIQUEENTER]="1";
this.VEHash[this.ONOBLIQUELEAVE]="1";this.VEHash[this.ONSTARTZOOM]="1";this.VEHash[this.ONSTARTCONTINUOUSPAN]="1";this.VEHash[this.ONDOUBLECLICK]="1";this.VEHash[this.ONMOUSEMOVE]="1";this.VEHash[this.ONMOUSEOVER]="1";this.VEHash[this.ONMOUSEOUT]="1";this.VEHash[this.ONMOUSEDOWN]="1";this.VEHash[this.ONMOUSEWHEEL]="1";
this.VEHash[this.ONKEYPRESS]="1";this.VEHash[this.ONKEYDOWN]="1";
this.VEHash[this.ONKEYUP]="1";this.VEHash[this.ONMODENOTAVAILABLE]="1";
this.VerifyEvent=function(A,C)
{
var B;
if(C==this.MWS)
    {
    return typeof (this.MWSHash[A])!="undefined"}
    else{
return typeof (this.VEHash[A])!="undefined"}}}var Events=new RfgMapEventsEnum();function RfgAttachMapEvent(A,C,E){var D=g_pRfgMapContainer[A];if(D){if(D.bRfgMapForcedFallback){return }try{D.AttachEvent(C,E)}catch(B){if(g_bShowErrorInformation){alert(B.message)}RfgAjaxErrorLogger("rfg",exception.message)
}
}
}

function RfgDetachMapEvent(A,C,E){var D=g_pRfgMapContainer[A];
if(D){if(D.bRfgMapForcedFallback)
    {return }
try{D.DetachEvent(C,E)}catch(B)
{
if(g_bShowErrorInformation)
    {alert(B.message)}
RfgAjaxErrorLogger("rfg",exception.message)}
}
}


function RfgGetCurrentMapView(A)
{var B=g_pRfgMapContainer[A];if(B){return B.GetMapView()}
return null}function RfgSetCurrentMapView(B,A){var D=g_pRfgMapContainer[B];if(D){
if(A==null||(!(A instanceof MapView)&&!(A instanceof MapViewSpecification)&&!(A instanceof VEMapViewSpecification))){throw (new TypeError("mapView invalid type - expecting a MapView or MapViewSpecification object"))
}if(A instanceof VEMapViewSpecification){D.SetMapView(A)}else{if(A instanceof MapViewSpecification){D.SetMapView(A.getVEMapViewSpecification())}else{var C=new Array();C.push(new VELatLong(A.neLatLong.latitude,A.neLatLong.longitude));C.push(new VELatLong(A.swLatLong.latitude,A.swLatLong.longitude));D.SetMapView(C)}}}}function RfgToggle3dMode(A,B){var C=g_pRfgMapContainer[A];if(C){if(B){C.SetMapMode(VEMapMode.Mode3D)}else{C.SetMapMode(VEMapMode.Mode2D)}}}function RfgSetMapStyle(A,B){var D=g_pRfgMapContainer[A];
if(D){var C=rfgGetVeMapStyle(B);D.SetMapStyle(C)}}function RfgSetZoomLevel(A,B){
var C=g_pRfgMapContainer[A];if(C){C.SetZoomLevel(B)}}function RfgGetZoomLevel(A){var B=g_pRfgMapContainer[A];if(B){return B.GetZoomLevel()}return 0}function RfgZoomIn(A){var B=g_pRfgMapContainer[A];if(B){B.SetZoomLevel(B.GetZoomLevel()+1)}}function RfgZoomOut(A){var B=g_pRfgMapContainer[A];if(B){B.SetZoomLevel(B.GetZoomLevel()-1)}}function RfgEnableBirdseyeWhereAvailable(B,A){var C=g_pRfgMapContainer[B];if(C){if(C.IsBirdseyeAvailable()){
C.SetMapStyle(VEMapStyle.Birdseye)
}else{if(A==null){A=0}if(A<10){setTimeout(function(){RfgEnableBirdseyeWhereAvailable(B,(A+1))},100)}}}}function OnCompleteRfgAddGeoRssFeed(pThisAjaxReq,strMapObjectId,onCompleteCallback){if(pThisAjaxReq.readyState!=4){return }var pMap=g_pRfgMapContainer[strMapObjectId];if(!pMap){if(g_bShowErrorInformation){alert("Could not display GeoRSS pushpins, invalid map id")}return }var pGeoRssNode=pThisAjaxReq.responseXML.getElementsByTagName("georss");if(!pGeoRssNode.length||pGeoRssNode.length==0){if(g_bShowErrorInformation){alert("Could not load GeoRss feed.")
}return }var pLocationNodes=pGeoRssNode[0].getElementsByTagName("location");
var aPushpins=new Array();for(var i=0;i<pLocationNodes.length;i++){var pThisLoc=pLocationNodes[i];var strName=AjaxGetNodeValue(pThisLoc,"name");var strEntityId=AjaxGetNodeValue(pThisLoc,"entityId");var strLat=null;var strLon=null;var strDesc=null;var strIconUrl=null;var strIconStyle=null;var pWhereNode=pThisLoc.getElementsByTagName("where");if(pWhereNode&&pWhereNode[0]){strLat=AjaxGetNodeValue(pWhereNode[0],"lat");strLon=AjaxGetNodeValue(pWhereNode[0],"long")
}var pDataMarkerNode=pThisLoc.getElementsByTagName("datamarker");if(pDataMarkerNode&&pDataMarkerNode[0]){strDesc=AjaxGetNodeValue(pDataMarkerNode[0],"description");strIconUrl=AjaxGetNodeValue(pDataMarkerNode[0],"icon");strIconStyle=AjaxGetNodeValue(pDataMarkerNode[0],"iconStyle")}if(strLat==null||strLon==null){continue}var veLatLong=new VELatLong(strLat,strLon);var vePushpin=new VEShape(VEShapeType.Pushpin,veLatLong);if(strIconUrl!=null&&strIconUrl!=""){vePushpin.SetCustomIcon(strIconUrl)}if(strDesc!=null&&strDesc!=""){vePushpin.SetDescription(strDesc)
}if(strName!=null&&strName!=""){vePushpin.SetTitle(strName)}aPushpins.push(vePushpin);pMap.AddShape(vePushpin)}if(onCompleteCallback!=null){try{if(typeof onCompleteCallback=="string"){eval(onCompleteCallback+"(aPushpins)")}else{onCompleteCallback(aPushpins)}}catch(e){if(g_bShowErrorInformation){alert(e.message)}}}}function RfgAddGeoRssFeed(B,A,D){var E=g_pRfgMapContainer[B];if(E){if(E.bRfgMapForcedFallback){return }try{g_AjaxQueue.schedule("RfgGeoRssFeed"+B,A,function(F){OnCompleteRfgAddGeoRssFeed(F,B,D)});document.attachEvent("onmouseover",RfgMoveSearchToolTip);
document.attachEvent("onmouseout",RfgMoveSearchToolTip)}catch(C){if(g_bShowErrorInformation){alert(C.message)}}}}function RfgAddGeoRss2Feed(B,A,E,G){var H=g_pRfgMapContainer[B];if(H){if(H.bRfgMapForcedFallback){return }try{var F=new VEShapeLayer();var C=new VEShapeSourceSpecification(VEDataType.GeoRSS,A,F);H.ImportShapeLayerData(C,G,E);document.attachEvent("onmouseover",RfgMoveSearchToolTip);document.attachEvent("onmouseout",RfgMoveSearchToolTip)}catch(D){if(g_bShowErrorInformation){alert(D.message)}}}}function RfgAddPushPin(I,G,L,B,C,E){var J=unescape(B.replace(/\+/g," "));
var H=unescape(C.replace(/\+/g," "));if(G==0&&L==0){return }if(E==""){E=null}var K=g_pRfgMapContainer[I];if(K){try{g_iPushPinSeq++;var F=new VELatLong(G,L);var A=new VEShape(VEShapeType.Pushpin,F);if(J!=null&&J!=""){A.SetTitle(J)}if(E!=null&&E!=""){A.SetCustomIcon(E)}if(H!=null&&H!=""){A.SetDescription(H)}K.AddShape(A);return A}catch(D){if(g_bShowErrorInformation){alert(D.message)}}}}function RfgDeleteAllPushpins(A){var B=g_pRfgMapContainer[A];if(B){B.DeleteAllPushpins()}}function RfgResizeMapToPoints(B,A){var D=g_pRfgMapContainer[B];
if(D){if(D.bRfgMapForcedFallback){return }try{D.SetMapView(A)}catch(C){if(g_bShowErrorInformation){alert(C.message)}}}}

//-------------------------------------------
function RfgOnPageLoad()
{
    g_bRfgOnLoadComplete=true;
    while(g_aRfgCommandQueue.length>0)
    {
        var strCmd=g_aRfgCommandQueue.shift();
        try
        {
            eval(strCmd)
        }catch(xE){}
    }
    if(g_pOldOnLoad)
    {
       g_pOldOnLoad()
    }
}
        
//     
   function RfgAddMilesToLatitude(B,A)
   {
        return B+(A*g_DEGREES_PER_MILE_LATITUDE)
   }
   function RfgAddMilesToLongitude(C,B,A)
   {
        return A*(360/(2*g_PI*g_EARTH_RADIUS*Math.cos(g_PI180*Math.abs(B))))+C
   }
   function RfgShowWaitDialog(K,J,D,M)
   {
        if(D==null)
        {
            D="";
        }
        var I='<table cellpadding=2 cellspacing=0 width="100%" height="100%"><tr><td style="background-color: #B8B898; height: 19px;"><img src="'+g_strRfgClientSupportUrl+'/wait.gif" alt="Please Wait..."></td><td align=right style="background-color: #B8B898;"><img src="'+g_strRfgClientSupportUrl+'/close.gif" alt="X" border=0 onClick="RfgHideWaitDialog(\''+K+'\');"></td></tr><tr><td colspan=2 style="font-family: arial,helvetica;font-size:10px;">'+D+'</td></tr><tr><td colspan=2><img src="'+g_strRfgClientSupportUrl+'/progressbar.gif"></td></tr></table>';
        var N=g_pRfgMapContainer[K];
        if(N)
        {
            try
            {
                if(g_pRfgWaitDlgContainer[K])
                {
                    g_pRfgWaitDlgContainer[K].dlg.style.visibility="visible";
                    if(J)
                    {
                        g_pRfgWaitDlgContainer[K].mask.style.visibility="visible";
                    }
                    if(M)
                    {
                        g_pRfgWaitDlgContainer[K].dlg.innerHTML=M;
                    }
                    else
                    {
                        g_pRfgWaitDlgContainer[K].dlg.innerHTML=I
                    }
                }
                else
                {
                    var B=document.getElementById(K);
                    var F=parseInt(B.offsetWidth);
                    var L=parseInt(B.offsetHeight);
                    g_pRfgWaitDlgContainer[K]=new Object();
                    g_pRfgWaitDlgContainer[K].mask=document.createElement("div");
                    g_pRfgWaitDlgContainer[K].mask.id="waitdlgmask_"+K;
                    g_pRfgWaitDlgContainer[K].mask.style.top="0px";
                    g_pRfgWaitDlgContainer[K].mask.style.left="0px";
                    g_pRfgWaitDlgContainer[K].mask.style.width=F+"px";
                    g_pRfgWaitDlgContainer[K].mask.style.height=L+"px";
                    g_pRfgWaitDlgContainer[K].mask.style.filter="alpha(opacity=69)";
                    g_pRfgWaitDlgContainer[K].mask.style.opacity=0.69;
                    g_pRfgWaitDlgContainer[K].mask.style.MozOpacity=0.69;
                    g_pRfgWaitDlgContainer[K].mask.style.background="White";
                    if(J)
                    {
                        g_pRfgWaitDlgContainer[K].mask.style.visibility="visible";
                    }
                    else
                    {
                        g_pRfgWaitDlgContainer[K].mask.style.visibility="hidden";
                    }
                    var C=289;
                    var H=87;
                    var G=parseInt((F-C)/2);
                    var E=parseInt((L-H)/2);
                    g_pRfgWaitDlgContainer[K].dlg=document.createElement("div");
                    g_pRfgWaitDlgContainer[K].dlg.id="waitdlgdlg_"+K;
                    g_pRfgWaitDlgContainer[K].dlg.style.top=E+"px";
                    g_pRfgWaitDlgContainer[K].dlg.style.left=G+"px";
                    g_pRfgWaitDlgContainer[K].dlg.style.width=C+"px";
                    g_pRfgWaitDlgContainer[K].dlg.style.height=H+"px";
                    g_pRfgWaitDlgContainer[K].dlg.style.background="#F0F0E4";
                    g_pRfgWaitDlgContainer[K].dlg.style.border="1px solid #989890";
                    if(M)
                    {
                        g_pRfgWaitDlgContainer[K].dlg.innerHTML=M
                    }
                    else
                    {
                        g_pRfgWaitDlgContainer[K].dlg.innerHTML=I
                    }
                    if(N.GetMapStyle().indexOf("MWS")>=0)
                    {
                        g_pRfgWaitDlgContainer[K].mask.style.zIndex=9999999998;
                        g_pRfgWaitDlgContainer[K].dlg.style.zIndex=9999999999;
                        g_pRfgWaitDlgContainer[K].dlg.style.position="absolute";
                        B.appendChild(g_pRfgWaitDlgContainer[K].mask);
                        B.appendChild(g_pRfgWaitDlgContainer[K].dlg)
                    }
                    else
                    {
                        N.AddControl(g_pRfgWaitDlgContainer[K].mask,null);
                        N.AddControl(g_pRfgWaitDlgContainer[K].dlg,null)
                    }
                }
            }
            catch(A)
            {
                if(g_bShowErrorInformation){alert(A.message)
            }
        }
    }
}

function RfgHideWaitDialog(A)
{
    var C=g_pRfgMapContainer[A];
    if(C)
    {
        try
        {
            if(g_pRfgWaitDlgContainer[A])
            {
                g_pRfgWaitDlgContainer[A].dlg.style.visibility="hidden";
                g_pRfgWaitDlgContainer[A].mask.style.visibility="hidden";
            }
        }
        catch(B)
        {
            if(g_bShowErrorInformation)
            {
                alert(B.message)
            }
        }
    }
}
function RfgStartPanMap(B,C,F,A)
{
    var E=RfgGetMapById(B);
    if(E)
    {
        try
        {
            E.StartContinuousPan(C,F)
        }
        catch(D){}
    }
}
function RfgStopPanMap(B,A)
{
    var D=RfgGetMapById(B);
    if(D)
    {
        try
        {
            D.EndContinuousPan()
        }
        catch(C)
        {}
    }
}
function RfgAddMapMicroDashboard(I)
{
    var K=g_pRfgMapContainer[I];
    if(K)
    {
        var F="RfgStartPanMap('"+I+"', 15, 0);";
        var D="RfgStartPanMap('"+I+"', -15, 0);";
        var C="RfgStartPanMap('"+I+"', 0, -15);";
        var B="RfgStartPanMap('"+I+"', 0, 15);";
        var H="RfgStopPanMap('"+I+"');";
        var G="RfgSetZoomLevel('"+I+"', RfgGetZoomLevel('"+I+"') + 1);";
        var A="RfgSetZoomLevel('"+I+"', RfgGetZoomLevel('"+I+"') - 1);";
        var E="RfgSetMapStyle('"+I+"', 'RoadVE');";
        var J="RfgSetMapStyle('"+I+"', 'HybridVE');";
        var L=document.createElement("div");
        L.id="rfgmicrocontrol_"+I;
        L.style.top="4px";
        L.style.left="4px";
        L.style.width="51px";
        L.style.height="112px";
        L.style.filter="alpha(opacity=90)";
        L.style.opacity=0.9;
        L.style.MozOpacity=0.9;
        L.style.background="White";
        L.style.border="2px solid #C0C0C0";
        L.innerHTML='<table cellpadding=0 cellspacing=0 width=51 heigt=112><tr><td align="center" valign="middle" bgcolor="#C8C8C8"><img src="'+g_strRfgClientSupportUrl+'/scheader.gif" width=49 height=10 border=0></td></tr></table><table cellpadding=2 cellspacing=0 width=51 heigt=71><tr><td align="center" valign="middle"><table cellpadding=0 cellspacing=0><tr><td></td><td><img src="'+g_strRfgClientSupportUrl+'/scnorth.gif" onMouseDown="'+C+'" onMouseUp="'+H+'" onMouseOut="'+H+'" width=16 height=15 border=0></td><td></td></tr><tr><td><img src="'+g_strRfgClientSupportUrl+'/scwest.gif" onMouseDown="'+D+'" onMouseUp="'+H+'" onMouseOut="'+H+'" width=15 height=16 border=0></td><td><img src="'+g_strRfgClientSupportUrl+'/sccenter.gif" width=16 height=16 border=0></td><td><img src="'+g_strRfgClientSupportUrl+'/sceast.gif" onMouseDown="'+F+'" onMouseUp="'+H+'" onMouseOut="'+H+'" width=15 height=16 border=0></td></tr><tr><td></td><td><img src="'+g_strRfgClientSupportUrl+'/scsouth.gif" onMouseDown="'+B+'" onMouseUp="'+H+'" onMouseOut="'+H+'" width=16 height=15 border=0></td><td></td></tr></table><table cellpadding=0 cellspacing=0><tr><td colspan=2><img src="'+g_strRfgClientSupportUrl+'/spacer.gif" width=2 height=2 border=0></td></tr><tr><td><a href="Javascript:'+A+'"><img src="'+g_strRfgClientSupportUrl+'/sczoomout.gif" width=18 height=16 border=0></a></td><td><img src="'+g_strRfgClientSupportUrl+'/spacer.gif" width=2 height=2 border=0></td><td><a href="Javascript:'+G+'"><img src="'+g_strRfgClientSupportUrl+'/sczoomin.gif" width=18 height=16 border=0></a></td></tr><tr><td colspan=2><img src="'+g_strRfgClientSupportUrl+'/spacer.gif" width=2 height=2 border=0></td></tr></table><table cellpadding=0 cellspacing=0 width=47><tr><td style="border-top: 1px solid #C0C0C0;" align="center"><a href="Javascript:'+E+'" style="font-family:arial,helvetica;font-size:9px;text-decoration:none;color:black;">Road</a></td></tr><tr><td style="border-top: 1px solid #C0C0C0;" align="center"><a href="Javascript:'+J+'" style="font-family:arial,helvetica;font-size:9px;text-decoration:none;color:black;">Hybrid</a></td></tr></td></tr></table>';
        K.AddControl(L,null)
    
    }
}

function RfgSetObjectPosition(C,D,B)
{
    var A=C.style||C;A.left=D+"px";A.top=B+"px"
}
function RfgGetMouseXPosition(A,B)
{
    var C=B;
    if(A)
    {
        if(A.pageX)
        {
            C=A.pageX
        }
        else
        {
            if(A.clientX)
            {
                C=A.clientX+(document.body.scrollLeft?document.body.scrollLeft:0)
            }
        }
    }
    return C;
}
function RfgGetMouseYPosition(A,B)
{
    var C=B;if(A)
    {
        if(A.pageY)
        {
            C=A.pageY;
        }
        else
        {
            if(A.clientY)
            {
                C=A.clientY+(document.body.scrollTop?document.body.scrollTop:0)
            }
        }
    }
    return C;
}
function RfgFindWidth(B)
{
    var A=0;
    if(document.getElementById||document.all)
    {
        A=B.offsetWidth;
    }
    else
    {
        if(document.layers)
        {
            B.width;
        }
    }
    return A;
}
function RfgFindHeight(B)
{
    var A=0;
    if(document.getElementById||document.all)
    {
        A=B.offsetHeight;
    }
    else
    {
        if(document.layers)
        {
            B.height;
        }
    }
    return A;
}
function RfgFindPosX(A)
{
    var B=0;
    if(document.getElementById||document.all)
    {
        while(A.offsetParent)
        {
            B+=A.offsetLeft;A=A.offsetParent
        }
    }
    else
    {
        if(document.layers)
        {
            B+=A.x;
        }
    }
    return B;
}
function RfgFindPosY(B)
{
    var A=0;
    if(document.getElementById||document.all)
    {
        if(!B.offsetParent)
        {
            A+=B.offsetTop
        }
        while(B.offsetParent)
        {
            B+=B.offsetTop;B=B.offsetParent;
        }
    }
    else
    {
        if(document.layers)
        {
            A+=B.y;
        }
    }
    return A;
}
function RfgShowSearchTooltip(C,I,A,B)
{
    var H=unescape(A);
    var G=unescape(B);
    if(g_bRfgSearchTipVisible)
    {
        if(g_objRfgLastTooltip)
        {
            if(g_objRfgLastTooltip.iXPos==C&&g_objRfgLastTooltip.iYPos==I&&g_objRfgLastTooltip.strTitle==A&&g_objRfgLastTooltip.strDetails==B)
            {
                return 
            }
        }
        RfgHideSearchToolTip()
    }
    g_bRfgSearchTipVisible=true;
    g_bRfgSearchTipCancelCloseRequest=true;
    g_bRfgSearchTipTimeoutActive=true;
    g_bRfgSearchTipNeedsRepositioned=false;
    if(g_objRfgLastTooltip)
    {
        g_objRfgLastTooltip.iXPos=C;
        g_objRfgLastTooltip.iYPos=I;
        g_objRfgLastTooltip.strTitle=A;
        g_objRfgLastTooltip.strDetails=B
    }
    var F=RfgGetMouseXPosition(window.event,C);
    var E=RfgGetMouseYPosition(window.event,I);
    var D=document.getElementById("RfgMapHoverDiv");
    if(D==null)
    {
        D=document.createElement("div");
        D.id="RfgMapHoverDiv";
        D.style.position="absolute";
        D.style.display="none";
        D.style.border="1px solid windowframe";
        D.style.background="#FFFFEA";
        D.style.zIndex=99;
        document.body.appendChild(D)
    }
    D.innerHTML="<table border=0><tr><td><b>"+H+"</b><br>"+G+"</td></tr></table>";
    RfgSetObjectPosition(D,F+5,E-20);D.style.display="block";
    if(!window.event)
    {
        if(document.addEventListener)
        {
            document.addEventListener("mousemove",RfgMoveSearchToolTip,true)
        }
        else
        {
            document.attachEvent("onmousemove",RfgMoveSearchToolTip);
            document.attachEvent("onmouseover",RfgMoveSearchToolTip);
            document.attachEvent("onmouseout",RfgMoveSearchToolTip)
        }
    }
    else
    {
        setTimeout(RfgBeginShowSearchTip,400);
    }
}
function RfgTrackSearchToolTip(D)
{
    var A=document.getElementById("RfgMapHoverDiv");
    if(A!=null)
    {
        var C=RfgGetMouseXPosition(D,0);
        var B=RfgGetMouseYPosition(D,0);
        if(C<g_iRfgSearchTipPosLeft||C>g_iRfgSearchTipPosRight)
        {
            if(!g_bRfgSearchTipTimeoutActive)
            {
                g_bRfgSearchTipCancelCloseRequest=false;
                setTimeout(RfgRequestHideSearchToolTip,400);
                g_bRfgSearchTipTimeoutActive=true;
            }
            return 
        }
        if(B<g_iRfgSearchTipPosTop||B>g_iRfgSearchTipPosBottom)
        {
            if(!g_bRfgSearchTipTimeoutActive)
            {
                g_bRfgSearchTipCancelCloseRequest=false;
                setTimeout(RfgRequestHideSearchToolTip,400);
                g_bRfgSearchTipTimeoutActive=true;
            }
            return 
        }
        g_bRfgSearchTipCancelCloseRequest=true;
    }
}
function RfgRequestHideSearchToolTip()
{
    var A=document.getElementById("RfgMapHoverDiv");
    if(A!=null)
    {
        g_bRfgSearchTipTimeoutActive=false;
        if(!g_bRfgSearchTipCancelCloseRequest)
        {
            RfgHideSearchToolTip()
        }
    }
}
function RfgHideSearchToolTip()
{
    var A=document.getElementById("RfgMapHoverDiv");
    if(A!=null)
    {
        if(document.removeEventListener)
        {
            document.removeEventListener("mousemove",RfgTrackSearchToolTip,true)
        }
        else
        {
            document.detachEvent("onmousemove",RfgTrackSearchToolTip);
            document.detachEvent("onmouseover",RfgTrackSearchToolTip);
            document.detachEvent("onmouseout",RfgTrackSearchToolTip);
        }
        A.style.display="none";
        g_bRfgSearchTipVisible=false;
        g_bRfgSearchTipCurrentId="";
    }
}

function RfgMoveSearchToolTip(D)
{
    if(document.removeEventListener)
    {
        document.removeEventListener("mousemove",RfgMoveSearchToolTip,true);
        document.removeEventListener("mousemove",RfgMoveSearchToolTip,true);
        document.removeEventListener("mousemove",RfgMoveSearchToolTip,true);
    }
    else
    {
        document.detachEvent("onmousemove",RfgMoveSearchToolTip);
    }
    if(!D)
    {
        D=window.event;
    }
    var C=RfgGetMouseXPosition(D,0);
    var B=RfgGetMouseYPosition(D,0);
    var A=document.getElementById("RfgMapHoverDiv");
    if(A!=null)
    {
        RfgSetObjectPosition(A,C+5,B-20);
    }
        setTimeout(RfgBeginShowSearchTip,400);
    }
function RfgBeginShowSearchTip()
{
    var A=document.getElementById("RfgMapHoverDiv");
    if(A!=null)
    {
        g_iRfgSearchTipPosLeft=RfgFindPosX(A);
        g_iRfgSearchTipPosRight=g_iRfgSearchTipPosLeft+RfgFindWidth(A);
        g_iRfgSearchTipPosTop=RfgFindPosY(A)-30;
        g_iRfgSearchTipPosBottom=g_iRfgSearchTipPosTop+RfgFindHeight(A)+30;
        if(document.addEventListener)
        {
            document.addEventListener("mousemove",RfgTrackSearchToolTip,true);
        }
        else
        {
            document.attachEvent("onmousemove",RfgTrackSearchToolTip);
        }
        setTimeout(RfgRequestHideSearchToolTip,400);
    }
}
function RfgClearMap(A)
{
    var B=g_pRfgMapContainer[A];
    if(B)
    {
        B.DeleteAllPushpins();
        B.DeleteAllPolygons();
        B.DeleteAllPolylines();
        B.Clear();
    }
}
function Address(G,C,D,F,E,A,B)
{
    this.addressLine=G;
    this.primaryCity=C;
    this.state=D;
    this.secondaryCity=B;
    this.postalCode=E;
    this.country=F;
    this.formattedAddress=A;
}
function RfgFindLocation(I,F,L,K,B)
{
    var J=g_pRfgMapContainer[I];
    if(J)
    {
        var E=null;
        var D=null;
        var C=0;
        var H=15;
        var G=false;
        var A=false;
        if(F instanceof Address)
        {
            E=F.addressLine+" "+F.primaryCity+", "+F.state+" "+F.postalCode;
        }
        else
        {
            E=F;
        }
        J.Find(D,E,null,null,C,H,G,A,L,K,B);
    }
}

function RfgReverseGeocode(B,C,D,A)
{
    var G=g_pRfgMapContainer[B];
    if(G)
    {
        var F=new VELatLong(C,D);
        try
        {
            G.FindLocations(F,A)
        }
        catch(E)
        {
            alert(E.message)
        }
    }
}
var SHORTEST_ROUTE="s";
var QUICKEST_ROUTE="q";
function RfgGenerateRoute(strMapObjectId,startLatLong,endLatLong,routeType,callbackFunction)
{
    if(startLatLong==null||(startLatLong!=null&&!(startLatLong instanceof VELatLong)))
    {
        throw (new TypeError("startLatLong invalid type - expecting a VELatLong object"))
    }
    if(endLatLong==null||(endLatLong!=null&&!(endLatLong instanceof VELatLong)))
    {
        throw (new TypeError("endLatLong invalid type - expecting a VELatLong object"))
    }
    if(routeType==null)
    {
        routeType=VERouteType.Quickest
    }
    var callback=null;
    if(typeof callbackFunction=="string")
    {
        callback=function(rt)
        {
            eval(callbackFunction+"(rt);")
        }
    }
    else
    {
        callback=callbackFunction
    }
    var pMap=g_pRfgMapContainer[strMapObjectId];
    if(pMap)
    {
        pMap.GetRoute(startLatLong,endLatLong,VEDistanceUnit.Miles,routeType,callback)
    }
}

function RfgLatLongFromPixel(C,A,F)
{
    var E=g_pRfgMapContainer[C];
    if(E)
    {
        var B=new VEPixel(A,F);
        var D=E.PixelToLatLong(B);
        return D;
    }
    return null;
}
function RfgPixelFromLatLong(D,A,B)
{
    var E=g_pRfgMapContainer[D];
    if(E)
    {
        var C=null;
        if(typeof A=="object")
        {
            C=E.LatLongToPixel(A);
        }
        else
        {
            C=E.LatLongToPixel(new VELatLong(A,B))
        }
        return C;
    }
    return null;
}
function RfgInternalOnMouseOverCallback(B)
{
    if(g_pLastMapObjectId!=null)
    {
        var C=g_pRfgMapContainer[g_pLastMapObjectId];
        var A=C.GetShapeByID(B.elementID);
        if(A!=null&&A instanceof VEShape&&A.GetType()==VEShapeType.Pushpin)
        {
            if(g_pRfgVepOnMouseOverCallback!=null)
            {
                g_pRfgVepOnMouseOverCallback(B.clientX,B.clientY,A.GetTitle(),A.GetDescription());
                return !(g_bRfgShowDetailsOnMouseOver)
            }
        }
    }
}

function RfgShowDetailOnMouseOver(A)
{
    g_bRfgShowDetailsOnMouseOver=A;
}
function RfgAddVEPushpinOnMouseOver(A)
{
    g_pRfgVepOnMouseOverCallback=A;
}
function RenderServiceException(A)
{
    if(!RfgJsErrorHandler("render",A))
    {
        if(g_bShowErrorInformation)
        {
            alert(A.message+" (Render Service)")
        }
        RfgAjaxErrorLogger("render",A.message)
    }
}
function FindServiceException(A)
{
    if(!RfgJsErrorHandler("find",A))
    {
        if(g_bShowErrorInformation)
        {
            alert(A.message+" (Find Service)")
        }
        RfgAjaxErrorLogger("find",A.message)
    }
}
function MapServiceException(A)
{
    if(!RfgJsErrorHandler("map",A))
    {
        if(g_bShowErrorInformation)
        {
            alert(A.message+" (Map Service)")
        }
        RfgAjaxErrorLogger("map",A.message)
    }
}
function RouteServiceException(A)
{
    if(!RfgJsErrorHandler("route",A))
    {
        if(g_bShowErrorInformation)
            {
            alert(A.message+" (Route Service)")
            }
        RfgAjaxErrorLogger("route",A.message)
    }
}

function CommonServiceException(A)
{
    if(!RfgJsErrorHandler("common",A))
    {
        if(g_bShowErrorInformation)
            {
                alert(A.message+" (Common Service)")
            }
            RfgAjaxErrorLogger("common",A.message)
    }
}
function CommunicationServerException(A)
{
    if(!RfgJsErrorHandler("communication",A))
    {
        if(g_bShowErrorInformation)
        {
            alert(A.message+" (Communication Server)")
        }
        RfgAjaxErrorLogger("communication",A.message)
     }
}