/*
eNavigator - Copyright 2008 Top Producer/Broker Solutions
Utilizes the Microsoft Virtual Earth Commercial v6 API
June 2008
Joe Wiesner
*/

/* *** Objects *** */
function map_Point()
{
    this.latitude = 0;
    this.longitude = 0;
    this.tooltipHtml = '';
    this.statsHtml = '';
    this.tooltipClassName = '';
    this.popupTabs = new Array();
    this.pushPin = null;
    this.pushPinShadow = null;
    this.pushPinOrientation = 'BottomMiddle';
}

function Map_PointIconSet()
{
    this.iconImage = '/images/mapping/Default_Pin.gif';
    this.iconImageShadow = '';
    this.pushpinWidth = 15;
    this.pushpinHeight = 20;
    this.tooltipClassName = 'Map_Default_ToolTip';
    this.isGrouping = false;
}

/**** GLOBAL VARIABLES *** */
var map_ArrayPoints = new Array();                  //array that stores all the points that are plotted.
var map_ArrayPointsCoordinates = new Array();       //array that stored all the point coordinates that are plotted.
var map_ArrayBulkShapes = new Array();              //used for bulk loading of pins/shapes 
var map_ArrayBulkShapesShadow = new Array();        //used for bulk loading of shadow shapes
var map_Interactive_AJAXObject = null;
var map_Detail_Tab_Array = new Array();
var map_ShowingDetails = false;
var map_ClickOnDetail = false;                      
var map_PointName = '';
var map_ShowDebugInfo = false;
var map_ShowStats = false;
var map_IsBirdseyeMode;
var map_LastPointClickedID = '';
var map_MLSNoArray = new Array();
var intrvlCt = 0;
var intrvl2;

/*  
below are pin position adjustments.  Our listing/office/whatever pins are 19px wide x 40px high, and base should always be set at the lat/long
of the place we are plotting.  Because of this, scrolling out makes the pins appear to drift south and west.  They're actually staying centered
over the selected lat/long.  We solve this by moving the pin up and to the right in its <div> when it is place.
The group pins (the stars) are symmetrical so they do not appear to drift on zoom...thus the 0 offsets for group pins
*/
var dtl_pin_vert_offset = -25;
var dtl_pin_horiz_offset = 3; 
var grp_pin_vert_offset = 0;  
var grp_pin_horiz_offset = 0; 

/*variables used for the Interactive Search*/
var map_LoadPointURL = '';
var map_LoadPointGroupingURL = '';
var map_MinGroupingZoomLevel = 0;
var map_LoadPointZoomLevel = 0;
var map_CenterPointOnClick = true;
var map_LoadMapAreaURL = '';

/* *********** */
var map_RequestCount_Area = 0;
var map_RequestCount_Group = 0;
var map_RequestCount_Point = 0;
/* *********** */

function Map_browserIsIE(){if(navigator.userAgent.indexOf("MSIE") == -1){return false;}else{return true;}}
function Map_browserIsFirefox(){if(navigator.userAgent.indexOf("Firefox") == -1){return false;}else{return true;}}
//Chrome released 9/2/2008.  Intent is to support Chrome when it is out of Beta.
function Map_browserIsChrome(){if(navigator.userAgent.indexOf("Chrome") == -1){return false;}else{return true;}}
function Map_ShowToolTip(hOffset, vOffset, elem, id)
{
    var tooltipHtml = '';
    var tooltipClassName = '';
    var statsHtml = '';
    if(map_ArrayPoints[id])
    {
        tooltipHtml = map_ArrayPoints[id].tooltipHtml;
        tooltipClassName = map_ArrayPoints[id].tooltipClassName;
        statsHtml = map_ArrayPoints[id].statsHtml;
    }
    if(tooltipHtml.length > 0 && map_ShowTooltips)
    {
        document.getElementById('Map_ToolTip').innerHTML = tooltipHtml;
        document.getElementById('Map_ToolTip').className = tooltipClassName;
        document.getElementById('Map_ToolTip').style.display = '';
        
        document.getElementById('Map_ToolTip').style.top = map_findElementTop(elem) + vOffset + 'px';
        document.getElementById('Map_ToolTip').style.left = map_findElementLeft(elem) + elem.offsetWidth + hOffset + 6 + 'px';        
    }
    Map_SetStats(statsHtml);
    
    if(Map_browserIsIE6Below()) map_HideFormElm();
    if(window.Map_TooltipShown) Map_TooltipShown(document.getElementById('Map_Tooltip'));
}

function Map_UpdateDetailPane()
{
    var link = document.getElementById('Map_InteractiveLink');
    if(map_MLSNoArray.length > 0 && map_MLSNoArray.length <= 100)
    {
        link.style.display = '';
        link.innerHTML = map_MLSNoArray.length + ' listing(s) plotted.<br /><a href="/property/proplist.asp?source=interactivemap">See details</a>';
        var strList = '';
        for(var x=0; x<map_MLSNoArray.length; x++){strList += map_MLSNoArray[x] + ',';}
        strList = strList.slice(0, -1);
        Map_SetCookie('eNavigator_MLSNoList', strList);
    }
    else
    {
        link.style.display = 'none';
    }
    
    intrvlCt++;
    if(intrvlCt >= 4) clearInterval(intrvl2);
}

function Map_ShowLoadingMessage()
{
    var loadmsg = document.getElementById('Map_Loading');
    loadmsg.style.display = '';
    var container = document.getElementById('Map_Container');
    var relativetop = (container.offsetHeight / 2) - (loadmsg.offsetHeight / 2);
    var relativeleft = (container.offsetWidth / 2) - (loadmsg.offsetWidth / 2);
    loadmsg.style.top = container.offsetTop + relativetop + 'px';
    loadmsg.style.left = container.offsetLeft + relativeleft + 'px';
}
function Map_HideLoadingMessage(){document.getElementById('Map_Loading').style.display = 'none';}
function Map_HideToolTip(){if(map_ShowTooltips) document.getElementById('Map_ToolTip').style.display = 'none';Map_SetStats('');if(Map_browserIsIE6Below() && !map_ShowingDetails) map_ShowFormElm();if(window.Map_TooltipHidden) Map_TooltipHidden(document.getElementById('Map_ToolTip'));}
function Map_ZoomToZipCounty(strVal)
{
    var ZipCode_AJAX_Request = GetXmlHttp();
    if(ZipCode_AJAX_Request != null)
    {
        ZipCode_AJAX_Request.open('GET', '/_include/Common/Mapping_VE_v6/MapAJAX_GetZipCountyGeoCode.asp?ZipCounty=' + strVal, true);
        ZipCode_AJAX_Request.onreadystatechange = function()
        {
            if(ZipCode_AJAX_Request.readyState == 4)
            {
                var myXmlDoc;
                if(Map_browserIsIE())
                {   /*Internet Explorer*/
                    myXmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
                    myXmlDoc.loadXML(ZipCode_AJAX_Request.responseText);
                    if (myXmlDoc.parseError.errorCode != 0)
                    {
                        Map_ShowMessage('An error occurred finding the requested Zip/County', 5000);
                        Map_HideZoomToZipCode();
                        return;
                    }
                }
                else
                {   /*Firefox, Safari, etc.*/
                    try 
                    {
                        myXmlDoc = ZipCode_AJAX_Request.responseXML;
                    }
                    catch(e)
                    {
                        Map_ShowMessage('An error occurred finding the requested Zip/County', 5000);
                        Map_HideZoomToZipCode();
                        return;
                    }
                }
                var markers = myXmlDoc.documentElement.getElementsByTagName("marker");
                if(markers.length == 0)
                {   
                    Map_ShowMessage('The requested Zip/County was not found.', 5000);
                }
                else
                {
                    if(markers[0].getAttribute("lat") != '0' && markers[0].getAttribute("lng") != '0')
                    {
                        Map_SetCenter(markers[0].getAttribute("lat"), markers[0].getAttribute("lng"));
                        Map_SetZoom(12);
                        if(map_ShowStats) Map_SetStats(strVal);
                    }
                    else
                    {
                        Map_ShowMessage('The requested Zip/County was not found.', 5000);
                    }
                }
                Map_HideZoomToZipCode();
            }
        };
        ZipCode_AJAX_Request.send(null);
    }
    else
    {
        Map_ShowMessage('An error occurred finding the requested Zip/County.');
        Map_HideZoomToZipCode();
    }
}

function Map_ClearPoints(){map.DeleteAllShapes();map_ArrayPoints = new Array();map_MLSNoArray = new Array();map_ArrayPointsCoordinates = new Array();map_ArrayBulkShapes = new Array();map_ArrayBulkShapesShadow = new Array();}
function Map_HideMessage(){document.getElementById('Map_Message').style.display = 'none';}
function Map_ShowMessage(strMessage, timeout)
{   
    var strhtml = '<table width="100%"><tr><td valign="top"><img src="/_include/Common/Mapping_VE_v6/Alert.gif"/></td>';
    strhtml += '<td style="text-align:left;">' 
    strhtml += strMessage
    strhtml += '</td><td valign="top" align="right"><a href="javascript:Map_HideMessage();">'
    strhtml += '<img src="/_include/Common/Mapping_VE_v6/redx.jpg" style="border:0px solid" alt="close" /></a></td></tr></table>';
    
    document.getElementById('Map_Message').innerHTML = strhtml;
    document.getElementById('Map_Message').style.display = '';
    if(timeout > 0) window.setTimeout("document.getElementById('Map_Message').style.display = 'none';", timeout);
}

function Map_browserIsIE6Below(){if(Map_browserIsIE()){var uas = navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5);uas = uas.substring(0, uas.indexOf(";"));if(parseFloat(uas) < 7){return true;}else{return false;}}else{return false;}}
function Map_ShowZoomToZipCode(){var elem = document.getElementById('Map_ZoomToZipCode');elem.style.display = '';var top = (document.getElementById('Map_Container').offsetHeight / 2) - (elem.offsetHeight / 2);var left = (document.getElementById('Map_Container').offsetWidth / 2) - (elem.offsetWidth / 2);elem.style.top = top + map_fix_offsetTop() + 'px';elem.style.left = left + map_fix_offsetLeft() + 'px';}
function Map_HideZoomToZipCode(){document.getElementById('Map_ZoomToZipCode').style.display = 'none';}
function Map_SetCenter(lat,lng){map.SetCenter(new VELatLong(lat, lng));}
function Map_HideDetails(){map_ShowingDetails = false;document.getElementById('Map_Detail').style.display = 'none';document.getElementById("Map_Debug_CurrentBubbleURL").innerHTML = '';if(Map_browserIsIE6Below()){map_ShowFormElm();}}
function Map_SetStats(strHtml){if(map_ShowStats){document.getElementById('Map_Stats').style.display = '';if(strHtml == '') document.getElementById('Map_Stats_Content').innerHTML = '';else document.getElementById('Map_Stats_Content').innerHTML = 'EASY STATS: ' + strHtml;}}
function Map_SetStyle(type){map.SetMapStyle(type);}
function Map_SetCookie(name, value){document.cookie=name + "=" + escape(value) + ";";}
function Map_SetDebugStatus(strVal){if(strVal.length > 0){document.getElementById('Map_Debug_Status').innerHTML = strVal;}else{document.getElementById('Map_Debug_Status').innerHTML = 'Idle';}}
function Map_HideHelp(){document.getElementById('Map_Help').style.display = 'none';}
function Map_GetCookie(name){var index = document.cookie.indexOf(name + "="); if (index == -1) return null; index = document.cookie.indexOf("=", index) + 1; /* first character */ var endstr = document.cookie.indexOf(";", index); if (endstr == -1) endstr = document.cookie.length; /* last character */ return unescape(document.cookie.substring(index, endstr));}
function Map_TranslateStyle(type){switch(type){case 'road':return VEMapStyle.Road;case 'hybrid':return VEMapStyle.Hybrid;case 'aerial':return VEMapStyle.Aerial; case 'birdseye':return VEMapStyle.Birdseye;case 'birdseyehybrid':return VEMapStyle.BirdseyeHybrid;case 'oblique':return VEMapStyle.Oblique;case 'shaded':return VEMapStyle.Shaded;default:return VEMapStyle.Road;}}
function Map_SetBirdLabels(labels){if(labels) Map_SetStyle(VEMapStyle.BirdseyeHybrid);else Map_SetStyle(VEMapStyle.Birdseye);}
function Map_Pan(dir){var pixelsToPan = 150; switch(dir){case 'R': map.Pan(pixelsToPan, 0);return;case 'D': map.Pan(0, pixelsToPan);return;case 'U': map.Pan(0, -pixelsToPan);return;case 'L': map.Pan(-pixelsToPan, 0);return;case 'UL': map.Pan(-pixelsToPan, -pixelsToPan);return;case 'DL': map.Pan(-pixelsToPan, pixelsToPan);return;case 'DR': map.Pan(pixelsToPan, pixelsToPan);return;case 'UR': map.Pan(pixelsToPan, -pixelsToPan);return;}}
function Map_SaveInteractiveParameters(e){if(map_IsInteractive && !map_IsBirdseyeMode){var center = map.GetCenter();Map_SetCookie('eNavigator_Prev_CenterLat', center.Latitude);Map_SetCookie('eNavigator_Prev_CenterLng', center.Longitude);Map_SetCookie('eNavigator_Prev_ZoomLevel', e.zoomLevel);Map_SetCookie('eNavigator_Prev_MapStyle', e.mapStyle);}}

function Map_SetSideControl()
{
    var container = document.getElementById('Map_Container');
    var compass = document.getElementById('Map_Compass');
    var dash = document.getElementById('Map_TypeDashboard');
    var zs;
    
    if(map_IsBirdseyeMode || map_IsTiny)
        zs = document.getElementById('Map_ZoomSliderSmall');
    else
        zs = document.getElementById('Map_ZoomSlider');
        
    if(compass.style.display != 'none')
        zs.style.top = compass.offsetTop + compass.offsetHeight + 'px';    
    else
        zs.style.top = dash.offsetTop + dash.offsetHeight + 'px';    

    var zoompane = document.getElementById('Map_ZoomControl');
    zoompane.style.top = dash.offsetTop + dash.offsetHeight + 'px';
    zoompane.style.left = container.offsetLeft + 'px';
    zs.style.left = container.offsetLeft + 4 + 'px';
    compass.style.left = container.offsetLeft + 'px';
    dash.style.left = container.offsetLeft + 'px';
    if(map_ShowStats) document.getElementById('Map_Stats').style.left = container.offsetLeft + 'px';
    if(map_KeyHTML.length > 0) document.getElementById('Map_Key').style.left = container.offsetLeft + 'px';
    
    if(map_IsBirdseyeMode)
    {
        var spin = document.getElementById('Map_Birdspin');
        spin.style.left = container.offsetLeft + 4 + 'px';
        spin.style.top = zs.offsetTop + zs.offsetHeight + 4 + 'px';
        zoompane.style.height = (spin.offsetTop + spin.offsetHeight) - (dash.offsetTop + dash.offsetHeight) + 'px';
    }
    else
    {
        zoompane.style.height = (zs.offsetTop + zs.offsetHeight + 4) - (dash.offsetTop + dash.offsetHeight) + 'px';
    }
}
     
function Map_SetOrientation(spin) 
{   //when in Oblique/Birdseye mode

    var orientation = map.GetBirdseyeScene().GetOrientation();
    var turnTo;
    if(spin == 1)
    {   //clockwise
        if(orientation == 'North') {map.SetBirdseyeOrientation(VEOrientation.East);document.getElementById('map_CompassGraphic').src = compass_e;turnTo = 'East';}
        if(orientation == 'East') {map.SetBirdseyeOrientation(VEOrientation.South);document.getElementById('map_CompassGraphic').src = compass_s;turnTo = 'South';}
        if(orientation == 'South') {map.SetBirdseyeOrientation(VEOrientation.West);document.getElementById('map_CompassGraphic').src = compass_w;turnTo = 'West';}
        if(orientation == 'West') {map.SetBirdseyeOrientation(VEOrientation.North);document.getElementById('map_CompassGraphic').src = compass_n;turnTo = 'North';}
    }
    else 
    {   //counterclockwise
        if(orientation == 'North') {map.SetBirdseyeOrientation(VEOrientation.West);document.getElementById('map_CompassGraphic').src = compass_w;turnTo = 'West';}
        if(orientation == 'East') {map.SetBirdseyeOrientation(VEOrientation.North);document.getElementById('map_CompassGraphic').src = compass_n;turnTo = 'North';}
        if(orientation == 'South') {map.SetBirdseyeOrientation(VEOrientation.East);document.getElementById('map_CompassGraphic').src = compass_e;turnTo = 'East';}
        if(orientation == 'West') {map.SetBirdseyeOrientation(VEOrientation.South);document.getElementById('map_CompassGraphic').src = compass_s;turnTo = 'South';}
    } 
    document.getElementById('Map_Directional').innerHTML = 'Looking ' + turnTo;
}

function Map_SetInteractiveMapView(minLat, maxLat, minLng, maxLng)
{
    if (map_IsInteractive)
    {
        Map_ShowLoadingMessage();
        Map_ClearPoints();
        Map_AddPoint('TopLeft', maxLat, minLng, null, '', 'BLANK', '')
        Map_AddPoint('BottomRight', minLat, maxLng, null, '', 'BLANK', '')
        Map_CenterOnPoints();
        if (map.GetZoomLevel() > 13) Map_SetZoom(13);
       
        //Map_LoadInteractivePoints(); <-- Don't call this method here, the map will automatically call it once the map is recentered
    }
}

function Map_GetBoundaryLatLong(tlPix, brPix)
{
    var strUrl = 'VAR_Min_Lat1=' + map.PixelToLatLong(brPix).Latitude;
    strUrl += '&VAR_Max_Lat1=' + map.PixelToLatLong(tlPix).Latitude;
    strUrl += '&VAR_Min_Lng1=' + map.PixelToLatLong(tlPix).Longitude;
    strUrl += '&VAR_Max_Lng1=' + map.PixelToLatLong(brPix).Longitude;
    return strUrl;
}

function Map_LoadInteractiveMapView()
{
    if (map_IsInteractive && map_LoadMapAreaURL.length != 0)
    {
        Map_ShowLoadingMessage();
        map_RequestCount_Area++;
        
        //Figure out which URL to use to get the XML representation of the map area to show
        var strUrl = map_LoadMapAreaURL;
        
        //Add QueryString Variables
        if(strUrl.indexOf('?') == -1) strUrl += '?';
        
        //Add Lat/Lng to the QueryString
        var tlPix = new VEPixel(0,0);                                               //top left
        var brPix = new VEPixel(document.getElementById('Map_Container').offsetWidth, document.getElementById('Map_Container').offsetHeight);     //bottom right
        strUrl += Map_GetBoundaryLatLong(tlPix, brPix);
        
        //Add Custom QueryString Variables
        var strQueryString = '';
        if(window.Map_CustomQueryString) strQueryString = Map_CustomQueryString();
        if(strQueryString.length > 0) strUrl += '&' + strQueryString;

        var request = GetXmlHttp();
        request.open("GET", strUrl, true);
        request.onreadystatechange = function(){
            if(request.readyState == 4)
            {
                Map_SetDebugStatus("Interactive Map - Map View Returned");
                if(request.status != "200")
                {
                    Map_SetDebugStatus('Interactive Map - Error occurred loading map view');
                    if(map_ShowDebugInfo)
                    {
                        Map_ShowMessage('An Error (' + request.status + ') Occurred loading map view.');
                        alert(request.responseText);
                    }
                }
                else
                {
                    var xmlDoc;
                    if(Map_browserIsIE())
                    {
                        xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
                        xmlDoc.loadXML(request.responseText);
                        if(xmlDoc.parseError.errorCode != 0)
                        {
                            if(map_ShowDebugInfo)
                            {
                                Map_ShowMessage("An error (" + xmlDoc.parseError.errorCode + ") occurred loading map view.");
                                alert(request.responseText);
                            }
                            Map_HideLoadingMessage();
                            return;
                        }
                    }
                    else        /*Firefox, Safari, etc.*/
                    {
                        try
                        {
                            xmlDoc = request.responseXML;
                        }
                        catch(e)
                        {
                            Map_ShowMessage("An error occurred finding the requested area.");
                            Map_HideLoadingMessage();
                            return;
                        }
                    }
                    
                    if (xmlDoc.documentElement.getAttribute("minlat") != null
                        && xmlDoc.documentElement.getAttribute("maxlat") != null
                        && xmlDoc.documentElement.getAttribute("minlng") != null
                        && xmlDoc.documentElement.getAttribute("maxlng") != null
                        
                        && xmlDoc.documentElement.getAttribute("minlat").length > 0
                        && xmlDoc.documentElement.getAttribute("maxlat").length > 0
                        && xmlDoc.documentElement.getAttribute("minlng").length > 0
                        && xmlDoc.documentElement.getAttribute("maxlng").length > 0
                        )
                    {
                        Map_ShowLoadingMessage();
                        Map_ClearPoints();
                        Map_AddPoint('TopLeft', xmlDoc.documentElement.getAttribute('maxlat'), xmlDoc.documentElement.getAttribute('minlng'), null, '', 'BLANK', '')
                        Map_AddPoint('BottomRight', xmlDoc.documentElement.getAttribute('minlat'), xmlDoc.documentElement.getAttribute('maxlng'), null, '', 'BLANK', '')
                        
                        Map_CenterOnPoints();
                        if (map.GetZoomLevel() > 13) Map_SetZoom(13);
                        //jcw 12/11/2008.  The next line forces the onChangeView event to fire.  In certain situations where the 
                        //"Show on Map" button was clicked but no criteria had been changed, the map would appear to hang.  It wasn't hanging,
                        //but simply reloading without firing onChangeView, which plots the points.
                        map.Pan(1,0);           
                    }
                    else
                    {
                        Map_LoadInteractivePoints();
                    }
                    
                    if(window.Map_InteractiveMapView_Loaded) Map_InteractiveMapView_Loaded();
                }
            }
        };
        request.send(null);
    }
    else
    {
        Map_LoadInteractivePoints();
    }
}

function Map_CenterOnPoints()
{
    if(map_ArrayPointsCoordinates.length > 1)
        map.SetMapView(map_ArrayPointsCoordinates);
    else if(map_ArrayPointsCoordinates.length == 1)
        map.SetCenterAndZoom(new VELatLong(map_ArrayPointsCoordinates[0].Latitude, map_ArrayPointsCoordinates[0].Longitude), 13);
    
    if(map_IsLocationPicker == false && window.Map_CenteredOnPoints) Map_CenteredOnPoints();
}

function map_findElementTop(obj){var curtop = 0;if(obj.offsetParent){while (obj.offsetParent){curtop += obj.offsetTop;obj = obj.offsetParent;}}else if (obj.y){curtop += obj.y;} return curtop;}   
function map_findElementLeft(obj){var curleft = 0;if(!obj) return curleft;if(obj.offsetParent){while(obj.offsetParent){curleft += obj.offsetLeft;obj = obj.offsetParent;}}else if (obj.x){curleft = obj.x;}return curleft;}

function Map_ShowDebugInfo()
{
    document.getElementById('Map_Debug_Latitude').innerHTML = map.GetCenter().Latitude;
    document.getElementById('Map_Debug_Longitude').innerHTML = map.GetCenter().Longitude;
    document.getElementById('Map_Debug_Zoom').innerHTML = map.GetZoomLevel();
    document.getElementById("Map_Debug_PointCount").innerHTML = map_ArrayPointsCoordinates.length;
    document.getElementById("Map_Debug_Interactive").innerHTML = map_IsInteractive;
    document.getElementById("Map_Debug_LoadPointURL").innerHTML = "<a href='" + map_LoadPointURL + "?" + Map_GetInteractiveMapUrlQueryString() + "' target='_blank'>" + map_LoadPointURL + "</a>";
    document.getElementById("Map_Debug_MinGroupingZoomLevel").innerHTML = map_MinGroupingZoomLevel;
    document.getElementById("Map_Debug_LoadPointGroupingURL").innerHTML = "<a href='" + map_LoadPointGroupingURL + "?" + Map_GetInteractiveMapUrlQueryString() + "' target='_blank'>" + map_LoadPointGroupingURL + "</a>";
    document.getElementById("Map_Debug_LoadPointZoomLevel").innerHTML = map_LoadPointZoomLevel;
    document.getElementById("Map_Debug_LoadMapAreaURL").innerHTML = "<a href='" + map_LoadMapAreaURL + "?" + Map_GetInteractiveMapUrlQueryString() + "' target='_blank'>" + map_LoadMapAreaURL + "</a>"
    document.getElementById("Map_Debug_RequestCountArea").innerHTML = map_RequestCount_Area;
    document.getElementById("Map_Debug_RequestCountGroup").innerHTML = map_RequestCount_Group;
    document.getElementById("Map_Debug_RequestCountPoint").innerHTML = map_RequestCount_Point;
}

function map_getAbsLeft(o){oLeft = o.offsetLeft;while(o.offsetParent!=null){oParent = o.offsetParent;oLeft += oParent.offsetLeft;o = oParent;}return oLeft;}
function map_getAbsTop(o){oTop = o.offsetTop;while(o.offsetParent!=null){oParent = o.offsetParent;oTop += oParent.offsetTop;o = oParent;}return oTop;}
function Map_SetZoom(num){map.SetZoomLevel(num);}

function Map_PlotBulkArray()
{
    if(map_ArrayBulkShapesShadow.length) map.AddShape(map_ArrayBulkShapesShadow);
    map.AddShape(map_ArrayBulkShapes);    
}

function Map_BuildBulkArray(id, latitude, longitude, popupTabs, tooltipHtml, PointType, statsHtml)
{
    //This is just like Map_AddPoint from the old way of plotting pins except this function just builds an array of shapes.
    //To actually put the pins on the map, the function Map_PlotBulkArray must be called.  When a large number of shapes need 
    //to be plotted, this method should be used.  Currently (09/2008) only in use for interactive map.
    var MyPointIconSet = new Map_PointIconSet();
    
    if(MyPointIconSet.SetType) MyPointIconSet.SetType(PointType);
  
    var myPoint = new map_Point;
    var pushPin = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude, longitude));
    
    if(MyPointIconSet.isGrouping)
    {
        var strOnClick = 'map.SetCenterAndZoom(new VELatLong(' + latitude + ', ' + longitude + '), map_MinGroupingZoomLevel + 1);';
        var vOffset = grp_pin_vert_offset;
        var hOffset = grp_pin_horiz_offset;
    }        
    else
    {
        var strOnClick = 'Map_ShowDetails(\'' + id + '\');';
        var vOffset = dtl_pin_vert_offset;
        var hOffset = dtl_pin_horiz_offset;
    }
    pushPin.SetCustomIcon('<div id="PinPointImage_' + id + '" style="display:block;width:' + MyPointIconSet.pushpinWidth + 'px;height:' + MyPointIconSet.pushpinHeight + 'px;" onmouseover="Map_ShowToolTip(' + hOffset + ',' + vOffset + ',this, \'' + id + '\');" ommouseout="Map_HideToolTip();" onmouseleave="Map_HideToolTip();"><img border="0" style="position:absolute;top:' + vOffset + 'px;left:' + hOffset + 'px;" src="' + MyPointIconSet.iconImage + '" onclick="'+ strOnClick + '"/></div>');    
    map_ArrayBulkShapes.push(pushPin);
    
    if(MyPointIconSet.iconImageShadow.length > 0)    
    {
        var pushPinShadow = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude, longitude));
        pushPinShadow.SetCustomIcon('<img border="0" style="position:absolute;top:' + vOffset + 'px;left:' + hOffset + 'px;filter:alpha(opacity=50);-moz-opacity:0.50;" src="' + MyPointIconSet.iconImageShadow + '" />');        
        pushPinShadow.SetZIndex(0);
        map_ArrayBulkShapesShadow.push(pushPinShadow);
    }
    else 
    {
        myPoint.pushPinShadow = null;
    }
    
    myPoint.latitude = latitude;
    myPoint.longitude = longitude;
    myPoint.tooltipHtml = tooltipHtml;
    myPoint.tooltipClassName = MyPointIconSet.tooltipClassName;
    myPoint.statsHtml = statsHtml;
    myPoint.popupTabs = popupTabs;
    /*Add the plotted point to the Array of Points plotted*/
    map_ArrayPoints[id] = myPoint;
    /*Add the plotted point to the Array of Point Coordinates plotted. This is used in the Map_CenterOnPoints function*/
    map_ArrayPointsCoordinates.push(new VELatLong(latitude, longitude));
    map_MLSNoArray.push(id);
    return myPoint.pushPin;
}

function Map_AddPoint(id, latitude, longitude, popupTabs, tooltipHtml, PointType, statsHtml)
{
    var MyPointIconSet = new Map_PointIconSet();
    
    if(MyPointIconSet.SetType) MyPointIconSet.SetType(PointType);
    
    var strOnClick = '';
    var myPoint = new map_Point;
    var pushPin = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude, longitude));
    
    if(MyPointIconSet.isGrouping)
    {
        strOnClick = 'map.SetCenterAndZoom(new VELatLong(' + latitude + ', ' + longitude + '), map_MinGroupingZoomLevel + 1);';
        var vOffset = grp_pin_vert_offset;
        var hOffset = grp_pin_horiz_offset;
    }        
    else
    {
        strOnClick = 'Map_ShowDetails(\'' + id + '\');';
        var vOffset = dtl_pin_vert_offset;
        var hOffset = dtl_pin_horiz_offset;
    }
    pushPin.SetCustomIcon('<div id="PinPointImage_' + id + '" style="display:block;width:' + MyPointIconSet.pushpinWidth + 'px;height:' + MyPointIconSet.pushpinHeight + 'px;" onmouseover="Map_ShowToolTip(' + hOffset + ',' + vOffset + ',this, \'' + id + '\');" ommouseout="Map_HideToolTip();" onmouseleave="Map_HideToolTip();"><img border="0" style="position:absolute;top:' + vOffset + 'px;left:' + hOffset + 'px;" src="' + MyPointIconSet.iconImage + '" onclick="'+ strOnClick + '"/></div>');    
    map.AddShape(pushPin);  
    
    if(MyPointIconSet.iconImageShadow.length > 0)    
    {
        var pushPinShadow = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude, longitude));
        pushPinShadow.SetCustomIcon('<img border="0" style="position:absolute;top:' + vOffset + 'px;left:' + hOffset + 'px;filter:alpha(opacity=50);-moz-opacity:0.50;" src="' + MyPointIconSet.iconImageShadow + '" />');        
        pushPinShadow.SetZIndex(0);
        map.AddShape(pushPinShadow); 
    }
    else 
    {
        myPoint.pushPinShadow = null;
    }
    
    myPoint.latitude = latitude;
    myPoint.longitude = longitude;
    myPoint.tooltipHtml = tooltipHtml;
    myPoint.tooltipClassName = MyPointIconSet.tooltipClassName;
    myPoint.statsHtml = statsHtml;
    myPoint.popupTabs = popupTabs;
    /*Add the plotted point to the Array of Points plotted*/
    map_ArrayPoints[id] = myPoint;
    /*Add the plotted point to the Array of Point Coordinates plotted. This is used in the Map_CenterOnPoints function*/
    map_ArrayPointsCoordinates.push(new VELatLong(latitude, longitude));
    return myPoint.pushPin;
}

var Map_LoadBubbleWithHTML_XmlHttpRequest = null;
function Map_LoadBubbleWithHTML(url)
{
    var myIFrame = document.getElementById('Map_Detail_IFrame');
    Map_LoadBubbleWithHTML_XmlHttpRequest = GetXmlHttp();
    if(Map_LoadBubbleWithHTML_XmlHttpRequest != null)
    {
        Map_LoadBubbleWithHTML_XmlHttpRequest.open("GET", url, true);
        Map_LoadBubbleWithHTML_XmlHttpRequest.onreadystatechange = function(aEvt)
        {
            if(Map_LoadBubbleWithHTML_XmlHttpRequest.readyState == 4)
            {
                //myIFrame.innerHTML = XMLHTTPRequest_req.responseText;
                //The below code is a work around for a bug in setting a div's innerHTML property in IE
                var old = document.getElementById('Map_Detail_IFrame_Content');
                if(old) myIFrame.removeChild(old);
                old = document.getElementById('Map_Detail_IFrame_Content');
                if(old) myIFrame.removeChild(old);
                myIFrame.innerHTML = '';
                
                
                var myDiv = document.createElement("div");
                myDiv.id = 'Map_Detail_IFrame_Content';
                myDiv.className = "MapDetail";
                myDiv.innerHTML = Map_LoadBubbleWithHTML_XmlHttpRequest.responseText;
                myIFrame.appendChild(myDiv);
                
                myIFrame.className = 'MapDetail';
                document.getElementById('Map_Detail_IFrame').style.display = '';
                document.getElementById('Map_Detail_LoadingMessage').style.display = 'none';
                /* ** Run Scripts in Page since "OnLoad" scripts aren't fired - http://microformats.org/wiki/rest/ahah ** */
                var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
                var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
                var bMoz = (navigator.appName == 'Netscape');
                function execJS(node)
                {
                    var st = node.getElementsByTagName('SCRIPT');
                    var strExec;
                    for(var i=0;i<st.length; i++)
                    {
                        if (bSaf){strExec = st[i].innerHTML;}
                        else if (bOpera){strExec = st[i].text;}
                        else if (bMoz){strExec = st[i].textContent;}
                        else{strExec = st[i].text;}
                        try
                        {
                            if(strExec.length != 0){eval(strExec);}
                        }
                        catch(e)
                        {
                            if(map_ShowDebugInfo){alert('Map Bubble Error:\nAn Error occured running the JavaScript in the tab content.');}
                        }
                    }
                }
                execJS(myIFrame);}
            };
            Map_LoadBubbleWithHTML_XmlHttpRequest.send(null);
        }
}
function map_Generate_PopupTab_Html(popupTabs)
{
    var popupTabHtml='';
    if(popupTabs.length > 0)
    {
        map_Detail_Tab_Array = new Array();
        for(var i = 0; i < popupTabs.length; i++)
        {
            map_Detail_Tab_Array[i] = popupTabs[i][1];
        }
        popupTabHtml += '<table cellpadding="0" cellspacing="0" border="0"><tr>';
        for(var i = 0; i < popupTabs.length; i++)
        {
            popupTabHtml +='<td><div id="Map_Detail_Tab" onclick="map_Detail_Tab_Change(' + i + ');">';
            
            if(Map_browserIsFirefox())
            {
                popupTabHtml +='<table id="Map_Detail_Tab_Number_' + i + '" class="Map_Detail_TabUnselected" border="0" cellspacing="0" cellpadding="0">'+
                '<tr>'+
                '<td class="Map_Detail_Tab" style="border-right: solid 1px #A5ACB2; border-left: solid 1px #A5ACB2;"><nobr>' + popupTabs[i][0] + '</nobr></td>'+
                '</tr>'+
                '</table>';
            }
            else
            {
                popupTabHtml +='<table id="Map_Detail_Tab_Number_' + i + '" class="Map_Detail_TabUnselected" border="0" cellspacing="0" cellpadding="0"><tr><td align="left" valign="top"><img id="Map_Detail_Tab_Number_' + i + '_LeftCorner" src="/_include/Common/Mapping_VE_v6/images/mapping/Bubble/crnr_unsel_hi_left.gif" style="height:5px;width:5px;"><br><img class="Map_Detail_Border" src="/_include/Common/Mapping_VE_v6/images/spacer.gif"></td><td class="Map_Detail_Tab"><nobr>' + popupTabs[i][0] + '</nobr></td><td align="right" valign="top"><img id="Map_Detail_Tab_Number_' + i + '_RightCorner" src="/_include/Common/Mapping_VE_v6/images/mapping/Bubble/crnr_unsel_hi_right.gif" style="height:5px;width:5px;"><br><img class="Map_Detail_Border" src="/images/spacer.gif"></td></tr></table></div>';
            }
            
            popupTabHtml +='</div></td>';
        }
        popupTabHtml += '</tr></table>';
    }
    return popupTabHtml;
}

var map_CurrentPopup_Tab = null;
function map_Detail_Tab_Change(TabNumber)
{
    map_CurrentPopup_Tab = TabNumber;
    document.getElementById('Map_Detail_LoadingMessage').style.display = '';
    document.getElementById('Map_Detail_IFrame').style.display = 'none';
    for(var i = 0; i <= map_Detail_Tab_Array.length - 1; i++)
    {
        if(Map_browserIsFirefox())
        {
            if(TabNumber == i)
            {
                document.getElementById("Map_Detail_Tab_Number_" + i).className = "Map_Detail_TabSelected";
            }
            else
            {
                document.getElementById("Map_Detail_Tab_Number_" + i).className = "Map_Detail_TabUnselected";
            }
        }
        else
        {
            if(TabNumber == i)
            {
                document.getElementById("Map_Detail_Tab_Number_" + i).className = "Map_Detail_TabSelected";
                document.getElementById("Map_Detail_Tab_Number_" + i + "_RightCorner").src = "/_include/Common/Mapping_VE_v6/images/Bubble/crnr_sel_hi_right.gif";
                document.getElementById("Map_Detail_Tab_Number_" + i + "_LeftCorner").src = "/_include/Common/Mapping_VE_v6/images/Bubble/crnr_sel_hi_left.gif";
            }
            else
            {
                document.getElementById("Map_Detail_Tab_Number_" + i).className = "Map_Detail_TabUnselected";
                document.getElementById("Map_Detail_Tab_Number_" + i + "_RightCorner").src = "/_include/Common/Mapping_VE_v6/images/Bubble/crnr_unsel_hi_right.gif";
                document.getElementById("Map_Detail_Tab_Number_" + i + "_LeftCorner").src = "/_include/Common/Mapping_VE_v6/images/Bubble/crnr_unsel_hi_left.gif";
            }
        }
    }
    Map_LoadBubbleWithHTML(map_Detail_Tab_Array[TabNumber]);
    document.getElementById('Map_Debug_CurrentBubbleURL').innerHTML = "<a href='" + map_Detail_Tab_Array[TabNumber] + "' target='_blank'>" + map_Detail_Tab_Array[TabNumber] + "</a>";
}

function Map_ShowBubble()
{    
    //This function is basically a hack.  It was put in place because the SetCenter() method may cause panning.  
    //It didn't do this in prior VE versions.  After the pan event ends, only then can we get accurate pin coordinates, 
    //so this function is called from that event handler.
    document.getElementById('Map_Detail').style.display = '';
    
    //position the bubble based on its height and just above the pin
    var posx = map_findElementLeft(document.getElementById('PinPointImage_' + map_LastPointClickedID));
    posx = posx - (document.getElementById('Map_Detail').offsetWidth / 2) + dtl_pin_horiz_offset + 10;
    var posy = map_findElementTop(document.getElementById('PinPointImage_' + map_LastPointClickedID));
    posy = posy - document.getElementById('Map_Detail').offsetHeight + dtl_pin_vert_offset + 1;
    document.getElementById('Map_Detail').style.top = posy + 'px';
    document.getElementById('Map_Detail').style.left = posx + 'px';
    
    if(Map_browserIsIE6Below()){map_HideFormElm();}    
}

function Map_ShowDetails(id){
    
    Map_HideDetails();
    
    if(!map_ArrayPoints[id])
	{
		Map_ShowMessage('Requested ' + map_PointName + ' (' + id + ') Not Found.');
	}
	else
	{
	    var lat = map_ArrayPoints[id].latitude;
		var lng = map_ArrayPoints[id].longitude;
		var htmlcode = map_Generate_PopupTab_Html(map_ArrayPoints[id].popupTabs);
		        
		if(htmlcode.length != 0)
		{
            document.getElementById('Map_Detail').style.display = '';                        
    	 	map_ShowingDetails = true;
	        map_ClickOnDetail = true;
    		map_LastPointClickedID = id;
		    if (map_CenterPointOnClick)
		    {
		        var offset = 0.0000900625;
		        var zoomLevel = map.GetZoomLevel();
		        if(map_IsBirdseyeMode)
		        {
		            for (var x=zoomLevel; x<2; x++){offset = offset * 2;}
		        }
		        else
		        {
		            for (var x=zoomLevel; x<20; x++){offset = offset * 2;}
		        }
		        lat = lat / 1;
		        lat = lat + offset;
		        //VE6 almost always pans when centering.  This caused many headaches and javascript errors when trying to position the detail 
		        //bubble.  The solution is to jump the map to a geocode far away (like 0,0) and then jump back.  This prevents panning allows
		        //fast re-positioning - the way the original e-Nav did it.  JCW 9/28/08.
		        if(!map_IsInteractive && !map_IsBirdseyeMode) Map_SetCenter(0, 0);            
		        Map_SetCenter(lat, lng);
		        document.getElementById('Map_Detail_Content_Tab').innerHTML = htmlcode;
		        map_Detail_Tab_Change(0);   
	        }
		}
	}
}

function map_fix_offsetLeft(){if(Map_browserIsIE() && document.compatMode == "BackCompat"){return document.getElementById('Map_Key').offsetLeft;} else{return map_getAbsLeft(document.getElementById('Map_Container'));}}
function map_fix_offsetTop(){var value = 0;if(Map_browserIsIE() && document.compatMode == "BackCompat") value = document.getElementById('Map_Key').offsetTop; else value = map_getAbsTop(document.getElementById('Map_Container'));return value;}

function Map_HideStandardElements()
{
    document.getElementById('Map_Stats').style.display = 'none';
    document.getElementById('Map_Key').style.display = 'none';
    document.getElementById('Map_TypeDashboard').style.display = 'none';
    document.getElementById('Map_ZoomControl').style.display = 'none';
}

function Map_PositionElements() 
{   
    //position the various controls bound to the map relative to the container.  This keeps everything tidy and runs when the window is
    //loaded or resized. 
    
    //Firefox 3 seems to be horizontally challenged.  At times, the horizontal positioning of controls relative to the left map boundary
    //was off.  To work around this, some of the style.left settings are handled later in this function, by Map_SetSideControls()
    var container = document.getElementById('Map_Container');
    var verticalpos = container.offsetTop;
    var leftboundary = container.offsetLeft;
    
    var elem;
    elem = document.getElementById('Map_Stats');
    elem.style.display = 'none';
    if(map_ShowStats)
    {
        elem.style.display = '';
        elem.style.width = container.offsetWidth + 'px';
        elem.style.top = verticalpos + 'px';
        verticalpos += elem.offsetHeight;
    }
    
    var compass = document.getElementById('Map_Compass')
    compass.style.top = verticalpos + 'px';
        
    elem = document.getElementById('Map_Key');
    elem.style.display = 'none';
    if(map_KeyHTML.length > 0) 
    {
        elem.style.display = '';
        elem.style.width = container.offsetWidth + 'px';
        elem.style.top = verticalpos + 'px';
        verticalpos += elem.offsetHeight;
    }
    
    var dash = document.getElementById('Map_TypeDashboard');
    dash.style.display = '';
    dash.style.width = container.offsetWidth + 'px';
    dash.style.top = verticalpos + 'px';
    
    elem = document.getElementById('Map_DashGroup');
    elem.style.left = leftboundary + compass.offsetWidth + 10 + 'px';
    elem.style.top = verticalpos + 4 + 'px';
    
    elem = document.getElementById('Map_DashAuxGroup');
    elem.style.top = verticalpos + 2 + 'px';
    elem.style.left = leftboundary + container.offsetWidth - elem.offsetWidth - 3 + 'px';
    
    verticalpos += dash.offsetHeight;

    if(!map_IsTiny)
    {
        elem = document.getElementById('Map_Message');
        if(elem)
        {
            elem.style.left = leftboundary + compass.offsetWidth + 10 + 'px';
            elem.style.top = verticalpos + 2 + 'px';
            elem.style.width = (container.offsetLeft + container.offsetWidth - 5) - (leftboundary + compass.offsetWidth + 10) + 'px';
        }
    }
    
    if(!map_IsBirdseyeMode && map_IsInteractive)
    {
        elem = document.getElementById('Map_InteractiveLink');
        if(elem)
        {
            elem.style.left = leftboundary + 5 + 'px';
            elem.style.top = verticalpos + container.offsetHeight + - 90 + 'px';
        }
    }
        
    if(map_IsTiny || map_IsBirdseyeMode)
    {
        document.getElementById('Map_ZoomSlider').style.display = 'none';
        document.getElementById('Map_ZoomSliderSmall').style.display = '';
    }
    else
    {
        document.getElementById('Map_ZoomSliderSmall').style.display = 'none';
        document.getElementById('Map_ZoomSlider').style.display = '';
    }
    document.getElementById('Map_ZoomControl').style.display = '';
    
    Map_SetSideControl();
        
    if(map_AllowBirdseye && map.IsBirdseyeAvailable() && !map_IsBirdseyeMode) 
        document.getElementById('Map_Birdlink').style.display = '';
    else
        document.getElementById('Map_Birdlink').style.display = 'none';

    if(map_ShowDebugInfo)
    {
        elem = document.getElementById('Map_Debug');
        elem.style.left = 5 + leftboundary + 'px';
        elem.style.top = container.offsetTop + container.offsetHeight - 190 + 'px';
    }
}

function Map_ShowHelp()
{
    var mapHelp = document.getElementById('Map_Help');
    mapHelp.style.display = '';
    mapHelp.style.left = document.getElementById('Map_Container').offsetLeft + 'px';
    mapHelp.style.top = document.getElementById('Map_Container').offsetTop + 'px';
    
    if(Map_browserIsFirefox())
    {
        mapHelp.style.width = document.getElementById('Map_Container').offsetWidth - 12 + 'px';
        mapHelp.style.height = document.getElementById('Map_Container').offsetHeight - 14  + 'px';
    }
    else
    {
        mapHelp.style.width = document.getElementById('Map_Container').offsetWidth + 'px';
        mapHelp.style.height = document.getElementById('Map_Container').offsetHeight + 'px';
    }
}

function Map_GetInteractiveMapUrl(curzoom)
{
    /*Figure out which URL to use to get the XML representation of the points*/
    var strMapURL = '';
    if(curzoom > map_MinGroupingZoomLevel || map_LoadPointGroupingURL.length == 0)
    {
        strMapURL = map_LoadPointURL;
        map_RequestCount_Point++;
    }
    else
    {
        strMapURL = map_LoadPointGroupingURL;
        map_RequestCount_Group++;
    }

    /*Add QueryString Variables*/
    if(strMapURL.indexOf('?') == -1){strMapURL += '?';}
    
    /* Get QueryString Criteria */
    strMapURL += Map_GetInteractiveMapUrlQueryString();
    return strMapURL;
}

function Map_GetInteractiveMapUrlQueryString()
{
    /*Add Lat/Lng to the QueryString*/
    var mapWindow = document.getElementById('Map_Container');
    var tlPix = new VEPixel(0,0);                                               //top left
    var brPix = new VEPixel(mapWindow.offsetWidth, mapWindow.offsetHeight);     //bottom right
    var strQS = Map_GetBoundaryLatLong(tlPix, brPix);
    /*Add Custom QueryString Variables*/
    var strMapCustomQueryString = '';
    if(window.Map_CustomQueryString) strMapCustomQueryString = Map_CustomQueryString();
    if(strMapCustomQueryString.length > 0) strQS += '&' + strMapCustomQueryString;
    return strQS;
}

function Map_LoadInteractivePoints()
{     
    /*Only load points if the map is "Interactive". Also, only load points when the Map_Detail is not being displayed.*/
    var curzoom = map.GetZoomLevel();
    if(map_IsInteractive && curzoom < map_LoadPointZoomLevel)
    {
        Map_HideLoadingMessage();
        Map_ClearPoints();
        if(map.GetMapStyle() != VEMapStyle.Birdseye && map.GetMapStyle() != VEMapStyle.BirdseyeHybrid)
            Map_ShowMessage('Please zoom in closer to view ' + map_PointName + ' in the area you are searching.');
    }
    else if((map_IsInteractive) && (map_ShowingDetails == false))
    {
        if(curzoom >= map_LoadPointZoomLevel) Map_HideMessage();
        Map_ShowLoadingMessage();
        Map_ClearPoints();
        
        /*Load the XML representation of the points*/
        map_Interactive_AJAXObject = GetXmlHttp();
        
        map_Interactive_AJAXObject.open('GET', Map_GetInteractiveMapUrl(curzoom), true);
        map_Interactive_AJAXObject.onreadystatechange = function(){
            if(map_IsInteractive && curzoom >= map_LoadPointZoomLevel)
            {
                if(map_Interactive_AJAXObject.readyState == 4)
                {
                    Map_SetDebugStatus('Interactive Map - Results Returned');
                    if(map_Interactive_AJAXObject.status != "200")
                    {
                        Map_SetDebugStatus('Interactive Point - Error occurred loading points');
                        if(map_ShowDebugInfo)
                        {
                            Map_ShowMessage('An Error (' + map_Interactive_AJAXObject.status + ') Occurred Loading Points on the map.');
                            alert(map_Interactive_AJAXObject.responseText);
                        }
                        else
                        {
                            Map_ShowMessage('No ' + map_PointName + ' could be found that match the criteria entered. Try zooming out to find nearby ' + map_PointName + '.');
                        }
                    }
                    else
                    {
                        if(Map_browserIsIE())   //Internet Explorer
                        {
                            xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
                            xmlDoc.loadXML(map_Interactive_AJAXObject.responseText);
                            if(xmlDoc.parseError.errorCode != 0)
                            {
                                if(map_ShowDebugInfo)
                                {
                                    Map_ShowMessage("An error (" + xmlDoc.parseError.errorCode + ") occurred finding the requested points.");
                                    alert(map_Interactive_AJAXObject.responseText);
                                }
                                else
                                {
                                    Map_ShowMessage('No ' + map_PointName + ' could be found in the area you are searching that match the criteria entered.');
                                }
                                Map_HideLoadingMessage();
                                return;
                            }
                        }
                        else                    //Firefox, Safari, etc.
                        {
                            try
                            {
                                xmlDoc = map_Interactive_AJAXObject.responseXML;
                            }
                            catch(e)
                            {
                                Map_ShowMessage("An error occurred finding the requested points.");
                                Map_HideLoadingMessage();return;
                            }
                        }

                        var points = xmlDoc.documentElement.getElementsByTagName('POINT');
                        
                        Map_SetDebugStatus('Interactive Map - Plotting ' + points.length + ' Points');
                        if (points.length == 0)
                        {
                            map_MLSNoArray = new Array();
                            var strNoPointMessage = "";
                            var noPointMessage = xmlDoc.documentElement.getElementsByTagName("NOPOINTMESSAGE");
                            if (noPointMessage.length != 0)
                                strNoPointMessage = noPointMessage[0].getAttribute("message");
                                
                            if (strNoPointMessage.length != 0)
                                Map_ShowMessage(strNoPointMessage);
                        }
                        else
                        {
                            for(var i = 0; i < points.length; i++)
                            {
                                var arrPopupTabs = new Array();
                                var popupTabs = points[i].getElementsByTagName("popupTab");
                                for(var t = 0; t < popupTabs.length; t++){arrPopupTabs[t] = [popupTabs[t].getAttribute('TabName'), popupTabs[t].getAttribute('TabPage')];}
                                //Map_AddPoint(points[i].getAttribute("id"),points[i].getAttribute("lat"),points[i].getAttribute("lng"),arrPopupTabs,points[i].getAttribute("tooltip"),points[i].getAttribute("PointType"),points[i].getAttribute("stats"));
                                Map_BuildBulkArray(points[i].getAttribute("id"),points[i].getAttribute("lat"),points[i].getAttribute("lng"),arrPopupTabs,points[i].getAttribute("tooltip"),points[i].getAttribute("PointType"),points[i].getAttribute("stats"));
                            }
                            
                            Map_PlotBulkArray();
                            Map_SetDebugStatus('Interactive Point - All Points Plotted');
                        }
                        Map_HideLoadingMessage();
                        
                        if(window.Map_InteractivePoints_Loaded) Map_InteractivePoints_Loaded();
                    }
                    if(window.Map_ShowDebugInfo) Map_ShowDebugInfo(null);
                    Map_HideLoadingMessage();
                }
            }
        };
        Map_SetDebugStatus('Interactive Map - Querying Server');
        map_Interactive_AJAXObject.send(null);
    }
}

function map_HideFormElm(){
    for (var j = 0; j<document.forms.length; j++) {
        for (var i = 0; i<document.forms[j].elements.length; i++) {
    	    if (document.forms[j].elements[i].tagName == 'SELECT') {
		        document.forms[j].elements[i].style.visibility = 'hidden'
            }
        }
    }
}
function map_ShowFormElm(){
    for (var j = 0; j<document.forms.length; j++) {
 	  for (var i = 0; i<document.forms[j].elements.length; i++) {
    	if (document.forms[j].elements[i].tagName == 'SELECT') {
 			document.forms[j].elements[i].style.visibility = 'visible'
	      }
	    }
	}
}

var map_LoadPointsFromXML_Request = null;
function Map_LoadPointsFromXML(strUrl)
{
    if (strUrl == null) strUrl = '';
    if (strUrl.length == 0)
    {
        alert('Error Map_LoadPointsFromXML: The URL to load points from must be specified.');
    }
    else
    {
        map_LoadPointsFromXML_Request = GetXmlHttp();
        map_LoadPointsFromXML_Request.open("GET", strUrl, true);
        map_LoadPointsFromXML_Request.onreadystatechange = function(){
            if(map_LoadPointsFromXML_Request.readyState == 4)   
            {
                if(map_LoadPointsFromXML_Request.status != "200")
                {
                    Map_SetDebugStatus('Map_LoadPointsFromXML - Error occurred loading points');
                    if(map_ShowDebugInfo)
                    {
                        Map_ShowMessage('An Error (' + map_LoadPointsFromXML_Request.status + ') Occurred Loading Points on the map.');
                        alert(map_LoadPointsFromXML_Request.responseText);
                    }
                }
                else
                {
                    if(Map_browserIsIE())/*Internet Explorer*/
                    {
                        xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
                        xmlDoc.loadXML(map_LoadPointsFromXML_Request.responseText);
                        if(xmlDoc.parseError.errorCode != 0)
                        {
                            if(map_ShowDebugInfo)
                            {
                                Map_ShowMessage("An error (" + xmlDoc.parseError.errorCode + ") occurred finding the requested points.");
                                alert(map_Interactive_AJAXObject.responseText);
                            }
                            else
                            {
                                Map_ShowMessage('No ' + map_PointName + ' could be found in the area you are searching that match the criteria entered.');
                            }
                            Map_HideLoadingMessage();
                            return;
                        }
                    }
                    else    /*Firefox, Safari, etc.*/
                    {
                        try
                        {
                            xmlDoc = map_LoadPointsFromXML_Request.responseXML;
                        }
                        catch(e)
                        {
                            Map_ShowMessage('An error occurred finding the requested points.');
                            Map_HideLoadingMessage();
                            return;
                        }
                    }

                    var points = xmlDoc.documentElement.getElementsByTagName("POINT");

                    Map_SetDebugStatus('Map_LoadPointsFromXML - Plotting ' + points.length + ' Points');
                    if (points.length == 0)
                    {
                        var strNoPointMessage = '';
                        var noPointMessage = xmlDoc.documentElement.getElementsByTagName("NOPOINTMESSAGE");
                        if (noPointMessage.length != 0) strNoPointMessage = noPointMessage[0].getAttribute('message');
                        if (strNoPointMessage.length != 0) Map_ShowMessage(strNoPointMessage);
                    }
                    else
                    {
                        for(var i = 0; i < points.length; i++)
                        {
                            var arrPopupTabs = new Array();
                            var popupTabs = points[i].getElementsByTagName('popupTab');
                            for(var t = 0; t < popupTabs.length; t++){arrPopupTabs[t] = [popupTabs[t].getAttribute('TabName'), popupTabs[t].getAttribute('TabPage')];}
                            Map_AddPoint(points[i].getAttribute('id'),points[i].getAttribute('lat'),points[i].getAttribute('lng'),arrPopupTabs,points[i].getAttribute('tooltip'),points[i].getAttribute('PointType'),points[i].getAttribute('stats'));
                        }
                        Map_SetDebugStatus('Map_LoadPointsFromXML - All Points Plotted');
                    }
                    Map_HideLoadingMessage();
                }
                if(window.Map_ShowDebugInfo){Map_ShowDebugInfo(null);}
                Map_HideLoadingMessage();
            }
        };
        map_LoadPointsFromXML_Request.send(null);
    }
}