﻿
// Javascript file for Web Mapping Application

var reloadTimer;
var webMapAppLeftPanelWidth = 262;
var webMapAppToggleWidth = 10;
var webMapAppTopBannerHeight = 80;
var newLoad = false;
var webMapAppCloseCallback = "";
var webMapAppCopyrightCallback = "";
var webMapAppMoveFunction = null;
var webMapAppMapDisplay = null;
var webMapAppPanelDisplay = null;
var webMapAppPanelDisplayCell = null;
var webMapAppPanelDisplayTableCell = null;
var webMapAppPanelScrollDiv = null;
var webMapAppToggleDisplay = null;
var webMapAppSpacerDiv = null;
var webMapAppPanelBottomSlider = null;
var webMapAppScaleBar = null;
var webMapAppNavBar = null;
var webMapAppCopyrightText = null;
var webMapAppWindowWidth = 500;
var webMapAppLeftOffsetX = 0;
var webMapAppRightOffsetX = 0
var webMapAppDefaultMinDockWidth = 125;
var webMapAppMinDockWidth = webMapAppDefaultMinDockWidth;
var webMapAppMapLeft = 262;
var webMapAppHasScroll = false;
var webMapAppLastHasScroll = false;
var m_measureToolbarId = "";
var webMapAppCurrentParcelSearch = "";
var theme = "";

// function to set initial sizes of page elements
function setPageElementSizes() {
        // set body style 
        if (document.documentElement) {
            document.documentElement.style.overflow = "hidden";
            document.documentElement.style.height = "100%"; 
        } else {
            document.body.style.overflow = "hidden";
            document.body.style.height = "100%";
        }  
        // get necessary elements
        webMapAppMapDisplay = document.getElementById("Map_Panel");
        webMapAppPanelDisplay = document.getElementById("LeftPanelCellDiv");
        webMapAppPanelDisplayCell = document.getElementById("LeftPanelCell");
        webMapAppPanelScrollDiv = document.getElementById("LeftPanelScrollDiv");
        webMapAppToggleDisplay = document.getElementById("ToggleCell");
        webMapAppPanelSlider = document.getElementById("PanelSlider");
        webMapAppPanelDisplayTableCell = document.getElementById("LeftPanelTableCell");
        webMapAppPanelBottomSlider = document.getElementById("PanelSliderBottom");
        webMapAppScaleBar = document.getElementById("ScaleBar1");
        webMapAppNavBar = document.getElementById("Navigation1");
        webMapAppCopyrightText = document.getElementById("CopyrightTextHolder");
        var headerDisplay = document.getElementById("PageHeader");
        var linkDisplay = document.getElementById("LinkBar");
        // set scroll on Dock
        webMapAppPanelScrollDiv.style.overflowY = "auto";
        if (isIE) {
            webMapAppPanelDisplay.style.overflow = "hidden";
        } 
        // get the set widths and heights
        webMapAppLeftPanelWidth = webMapAppPanelDisplay.clientWidth;
        webMapAppToggleWidth = parseInt(webMapAppToggleDisplay.style.width);
        webMapAppTopBannerHeight = headerDisplay.clientHeight + linkDisplay.clientHeight + 40;
        // get browser window dimensions
        var sWidth = getWinWidth();
        var sHeight = getWinHeight();
        // set map display dimensions
        var mWidth = sWidth - webMapAppLeftPanelWidth - webMapAppToggleWidth;
        var mHeight = sHeight - webMapAppTopBannerHeight;
        webMapAppMapLeft = webMapAppLeftPanelWidth + webMapAppToggleWidth;
        webMapAppMapDisplay.style.width =  mWidth + "px";
        webMapAppMapDisplay.style.height = mHeight  + "px";
        if (webMapAppScaleBar!=null) {
            var sbWidth = webMapAppScaleBar.clientWidth;
            var sbHeight = webMapAppScaleBar.clientHeight;
            webMapAppScaleBar.style.left = (sWidth - sbWidth - 10) + "px";
            webMapAppScaleBar.style.top = (sHeight - sbHeight - 10) + "px";
            webMapAppScaleBar.style.width = "auto";
            webMapAppScaleBar.style.height = "auto";
        } 
        if (webMapAppNavBar!=null) {
            var sbWidth = webMapAppNavBar.clientWidth;
            var sbHeight = webMapAppNavBar.clientHeight;
            webMapAppNavBar.style.left =  (sWidth-100) + "px"; //(sWidth - sbWidth - 10) + "px";
            webMapAppNavBar.style.top = 25 + "px"; //(sHeight - sbHeight - 10) + "px";
            webMapAppNavBar.style.width = "auto";
            webMapAppNavBar.style.height = "auto";
        } 
        if (webMapAppCopyrightText!=null) {
            webMapAppCopyrightText.onmousedown = webMapAppGetCopyrightText;
            var crtHeight = webMapAppCopyrightText.clientHeight;
            webMapAppCopyrightText.style.left = (webMapAppMapLeft + 10) + "px";
            webMapAppCopyrightText.style.top = (sHeight - crtHeight - 10) + "px";
        }
        // set heights of left panel and toggle bar
        webMapAppToggleDisplay.style.height = mHeight  + "px";
        webMapAppPanelScrollDiv.style.height = mHeight  + "px";
        esriMaxFloatingPanelDragRight = sWidth - 15;
        esriMaxFloatingPanelDragBottom = sHeight - 15;

}

function updateScaleBarLocation()
{
     var sWidth = getWinWidth();
     var sHeight = getWinHeight();
     webMapAppScaleBar = document.getElementById("ScaleBar1");
     if (webMapAppScaleBar!=null) {
        var sbWidth = webMapAppScaleBar.clientWidth;
        var sbHeight = webMapAppScaleBar.clientHeight;
        webMapAppScaleBar.style.left = (sWidth - sbWidth - 10) + "px";
        webMapAppScaleBar.style.top = (sHeight - sbHeight - 10) + "px";
        webMapAppScaleBar.style.width = "auto";
        webMapAppScaleBar.style.height = "auto";
     }
    //alert("change scalebar dude"); 
}

// function to toggle Dock visibility
function togglePanelDock() {
    if (webMapAppPanelDisplay.style.display=="none") {
        expandPanelDock();
    } else {
        collapsePanelDock();
    }     
}

function expandPanelDock() {
    var image = document.images["CollapseImage"];
    webMapAppPanelDisplay.style.display = "block";
    image.src = "images/collapse_left.gif";
    image.alt = "Collapse";
    webMapAppPanelSlider.style.cursor = "e-resize";
    webMapAppPanelBottomSlider.style.cursor = "e-resize"; 
    webMapAppMapLeft = webMapAppLeftPanelWidth + webMapAppToggleWidth;
    webMapAppMapDisplay.style.left =  webMapAppMapLeft + "px";
    AdjustMapSize(); 
}

function collapsePanelDock() {
    var image = document.images["CollapseImage"];
    dockWidthString = webMapAppPanelDisplayCell.clientWidth + "px";
    webMapAppPanelDisplay.style.display = "none";
    //webMapAppPanelDisplayCell.style.width = "1px";
    image.src = "images/expand_right.gif";
    image.alt = "Expand";
    webMapAppPanelSlider.style.cursor = "default"; 
    webMapAppPanelBottomSlider.style.cursor = "default"; 
    webMapAppMapLeft = webMapAppToggleWidth; 
    webMapAppMapDisplay.style.left =  webMapAppMapLeft + "px";  
    AdjustMapSize();  
   
}  

// function for adjusting element sizes when brower is resized
function AdjustMapSize() {
   // set element widths 
    webMapAppPanelDisplay.style.width =  webMapAppLeftPanelWidth + "px";
    webMapAppToggleDisplay.style.width = webMapAppToggleWidth + "px";
   // get browser window dimensions 
    var sWidth = getWinWidth();
    var sHeight = getWinHeight();
    // calc dimensions needed for map
    var mWidth = sWidth - webMapAppPanelDisplayCell.clientWidth;
    var mHeight = sHeight - webMapAppTopBannerHeight;
    if (mWidth<5) mWidth = 5;
    if (mHeight<5) mHeight = 5;  
    webMapAppMapDisplay.style.width =  mWidth + "px";
    webMapAppMapDisplay.style.left =  webMapAppPanelDisplayCell.clientWidth + "px"; 
   // set heights on elements 
    webMapAppMapDisplay.style.height = mHeight  + "px";
    webMapAppToggleDisplay.style.height = mHeight  + "px";
    webMapAppPanelScrollDiv.style.height = mHeight  + "px";
    if (webMapAppScaleBar!=null) {
        var sbWidth = webMapAppScaleBar.clientWidth;
        var sbHeight = webMapAppScaleBar.clientHeight;
        webMapAppScaleBar.style.left = (sWidth - sbWidth - 10) + "px";
        webMapAppScaleBar.style.top = (sHeight - sbHeight - 10) + "px";
    } 
    if (webMapAppNavBar!=null) {
        var sbWidth = webMapAppScaleBar.clientWidth;
        var sbHeight = webMapAppScaleBar.clientHeight;
        webMapAppNavBar.style.left =  (sWidth-100) + "px"; // (sWidth - sbWidth - 10) + "px";
        webMapAppNavBar.style.top =  25 + "px"; //(sHeight - sbHeight - 10) + "px";
    }
   // resize the map 
    window.setTimeout("resizeTheMap(" + mWidth + ", " + mHeight + ", false);", 500);
   // update map properties 
     
    var box = calcElementPosition("Map_Panel"); 
    map.containerLeft = box.left;
	map.containerTop = box.top;
    if (webMapAppCopyrightText!=null) {
        var crtHeight = webMapAppCopyrightText.clientHeight;
        webMapAppCopyrightText.style.left = (box.left + 10) + "px";
        webMapAppCopyrightText.style.top = (sHeight - crtHeight - 10) + "px";
    }
    return false;
}

// function for resizing map in Web Map App
function resizeTheMap(width, height, resizeExtent) {
    if (resizeExtent==null) resizeExtent = true;
    map.resize(width, height, resizeExtent);
    var div = document.getElementById("LeftPanelCellDiv"); 
    // update overview, if doc panel is expanded 
    if (ov!=null && div.style.display!="none") { 
        var argument = "ControlType=OverviewMap&EventArg=OverviewZoom";
        var context = ov.controlName; 
        eval(ov.callBackFunctionString);
    }
    return false; 
}

// handler for window resize
function AdjustMapSizeHandler(e) {
    window.clearTimeout(reloadTimer);
	reloadTimer = window.setTimeout("AdjustMapSize();",1000);
}

// function run at startup
function startUp() {
        // set up identify mode for javascript
        map.ctrlMode = "MapIdentify";
        map.ctrlAction = "Point";
        map.ctrlCursor = "pointer";
        map.ctrlFunction = "MapIdClick(e)";
        if (newLoad) {
            // execute only on intial load.... not callbacks
            map.divObject.style.cursor = "wait";
            // move magnifier and measure toolbar to top left corner of map display 
            var box = calcElementPosition("Map_Panel"); 
            //var mag = document.getElementById("Magnifier1");
//            if (mag!=null && typeof(esriMagnifiers)!="undefined" && esriMagnifiers!=null) { 
//                    floatingPanel = esriMagnifiers["Magnifier1"].floatingPanel; 
//                    if (floatingPanel!=null) moveTo(box.left, box.top);
//            }
            var tb = document.getElementById(m_measureToolbarId);
			if (tb!=null) {
			    tb.style.left = box.left + "px";
			    tb.style.top = box.top + "px";
			}
			var fp = document.getElementById("CopyrightText_Panel");
			if (fp!=null) {
			    floatingPanel = fp;
			    moveTo(box.left, box.top);
			}

            // Set the default query tab for the parcel search form		
			tabOnClick("ParcelSearchOwnerAddressTab");
			webMapAppCurrentParcelSearch = "ParcelSearchOwnerAddressTab";
 
        } 
        // set window resize event handler
       window.onresize = AdjustMapSizeHandler;
       for (var fp in FloatingPanels) {
            FloatingPanels[fp].onDockFunction = scrollDockToPanel;
       } 
       //alert("Start Up");  
}  

// function to request closing of session items.... only called if at least one resource is local non-pooled
function CloseOut() {
	var argument = "ControlID=Map1&ControlType=Map&EventArg=CloseOutApplication";
	var context = map.controlName;
	eval(webMapAppCloseCallback);
}

// response function to close out browser ... request sent to server by CloseOut()
function CloseOutResponse(response, context) {
    window.close(); 
    // if user selects Cancel in close dialog, send to close page 
    document.location = response; 
}


function startWebMapAppDockDrag(e) {
    webMapAppMoveFunction = document.onmousemove;
    document.onmouseup = stopWebMapAppDocDrag;  
    if (webMapAppPanelDisplay.style.display!="none") {
        webMapAppWindowWidth = getWinWidth();
        getXY(e); 
        webMapAppLeftOffsetX = mouseX - webMapAppPanelDisplay.clientWidth;
        var box = calcElementPosition("Map_Panel");
        webMapAppRightOffsetX = box.left - mouseX; 
        document.onmousemove = moveWebMapAppDockDrag;
        var ovPanel = document.getElementById("OverviewMap_Panel_BodyRow");
        var ovDisplay =  document.getElementById("OVDiv_OverviewMap_Panel_OverviewMap1");
        // because the panel cell will be as wide as the overview map image, keep the element width larger than the image. 
        if (FloatingPanels["OverviewMap_Panel"]!=null &&FloatingPanels["OverviewMap_Panel"].docked)
            webMapAppMinDockWidth = parseInt(ovDisplay.style.width) + 20;
        else    
            webMapAppMinDockWidth = webMapAppDefaultMinDockWidth; 
    }
    return false;  
}

function moveWebMapAppDockDrag(e) {
    getXY(e);
    webMapAppLeftPanelWidth =  mouseX - webMapAppLeftOffsetX;
    if (webMapAppLeftPanelWidth < webMapAppMinDockWidth) webMapAppLeftPanelWidth = webMapAppMinDockWidth; 
    var mapLeftString =  (webMapAppLeftPanelWidth + webMapAppToggleDisplay.clientWidth) + "px";
    //if (webMapAppPanelDisplayTableCell.clientWidth - webMapAppToggleDisplay.clientWidth > webMapAppLeftPanelWidth) webMapAppLeftPanelWidth = webMapAppPanelDisplayTableCell.clientWidth - webMapAppToggleDisplay.clientWidth;
    var widthString =  webMapAppLeftPanelWidth + "px";
    webMapAppPanelDisplay.style.width = widthString;
    //var width =  webMapAppWindowWidth - webMapAppMapDisplay.clientWidth;
    var width =  webMapAppWindowWidth - webMapAppPanelDisplayCell.clientWidth; 
    webMapAppMapDisplay.style.width = width + "px";
    webMapAppMapDisplay.style.left = mapLeftString;
    return false;
}

function stopWebMapAppDocDrag(e) {
    document.onmousemove = webMapAppMoveFunction;
    document.onmouseup = null;   
    webMapAppCheckPanelWidths();
    AdjustMapSize();  
    return false;
}

function OpenWindow(url) {
    window.open(url);
}

function webMapAppCheckPanelScroll() {
    if (webMapAppPanelScrollDiv.scrollHeight>webMapAppPanelScrollDiv.clientHeight) {
        webMapAppHasScroll = true;
    }  else {
        webMapAppHasScroll = false;
    }  
    //webMapAppCheckPanelWidths(); 
    if (webMapAppHasScroll!=webMapAppLastHasScroll)
        AdjustMapSize();
    webMapAppLastHasScroll = webMapAppHasScroll;    
    return false; 
}

function webMapAppCheckPanelWidths() {
    var maxWidth = 0;
    var node; 
    for (var i=0; i< webMapAppPanelDisplay.childNodes.length; i++) {
        if (webMapAppPanelDisplay.childNodes[i].tagName=="TABLE") {
            node = webMapAppPanelDisplay.childNodes[i];
            if (node.clientWidth>maxWidth) maxWidth = node.clientWidth; 
        }
    }  
     webMapAppPanelDisplay.style.width = maxWidth + "px";
    return false;
}

function webMapAppGetCopyrightText() {
	var argument = "ControlID=Map1&ControlType=Map&EventArg=GetCopyrightText";
	var context = map.controlName;
	eval(webMapAppCopyrightCallback);
	showFloatingPanel('CopyrightText_Panel');
}

function scrollDockToPanel(panelElement) {
    if (panelElement==null) return;
    var yPos = panelElement.offsetTop;
    webMapAppPanelScrollDiv.scrollTop = yPos;  
}


//FireCallBack - Fires callback against map control.
//
//Arguments -
//  Control Name: The control to update
//  Server Function: The name of the 'function' in RaiseCallbackEvent to run
//  Server Mode: The 'mode' of the function to run (ie subset choice, use same as Server Function if no mode)
//  ServerArgs: Any argument data needed on server side.  Data must be in format:
//            var=val&var2=val2&var3=val3 and so on.
// Author: DJones - 2/3/07        
function FireCallBack(controlName, ServerFunction, ServerMode, ServerArgs){

    if(ServerMode == "") {
        ServerMode = "novalue";
    }
    if(ServerArgs != "")
    {
        ServerArgs = "&" + ServerArgs;
    }
    var Arguments = "ControlID=" + controlName + "&ControlType=Map&EventArg=" + ServerFunction + "&Map1_mode=" + ServerMode + ServerArgs;

    var Context = controlName;

    eval(WebForm_DoCallback('__Page',Arguments,processCallbackResult,Context,null,true));
}

//---Floating Panel Functions---//

//Shows the floating panel
function ShowFP(PanelID)
{
    var maxzindex = document.getElementById("maxzindex").value;
    maxzindex++;
    document.getElementById("maxzindex").value = maxzindex;
    document.getElementById(PanelID).style.zIndex = maxzindex;
    if (PanelID == "ParcelDetailSearchFP")
    {   
       if (webMapAppCurrentParcelSearch == "")
       {
          webMapAppCurrentParcelSearch = "ParcelSearchOwnerAddressTab";
       }
       
       tabOnClick(webMapAppCurrentParcelSearch);
    }
    if (PanelID == "SelectToolFP")
    {
    
    }
    
    showFloatingPanel(PanelID,false);
}
//Hides the floating panel
function HideFP(PanelID)
{
    hideFloatingPanel(PanelID,false);
}
//Updates the floating panel's z-order to make it appear on top of other panels
function UpdatePanelZ(PanelID)
{
    var maxzindex = document.getElementById("maxzindex").value;
    maxzindex++;
    document.getElementById("maxzindex").value = maxzindex;
    document.getElementById(PanelID).style.zIndex = maxzindex;
}
//Fires callback to clear user added graphics
function ClearGraphicSelection()
{
   FireCallBack("Map1","ClearSelection","Selection","");
}


//---previous extent functions---//
// Fires callback to force map to zoom to previous extent
function PreviousExtent()
{
    FireCallBack("Map1","PreviousExtent","Extent","");
}


//---html attribute table functions---//
// Fires callback to display the selected features in an html attribute table
function ShowHTMLTable(LayerName,ShowZoom,ShowHighlight,AutoZoomExtent,DivID)
{
    FireCallBack("Map1","ShowAttributes","Selection","layer=" + LayerName + "&showzoom=" + ShowZoom + "&showhighlight=" + ShowHighlight + "&autozoom=" + AutoZoomExtent + "&divid=" + DivID ); 
}
// Fires callback to highlight a selected feature.  In addition, selected features row is highlighted in attribute table
function HighLightGraphicFeature(LayerName,ObjectID,RowID)
{
    //highlight feature on map
    FireCallBack("Map1","HighLightFeature","Selection","layer=" + LayerName + "&objectid=" + ObjectID);
    //highlight row
    Row = document.getElementById(RowID);
    if (Row.className == "midGreen")
    {
         var table = document.getElementById("selectedattributetable");
         for (j=1;j<table.rows.length;j++) 
         { 
            if(table.rows[j].id == Row.id)
            {
                if (j % 2 == 0)
                {
                    TDClass = "lightBrown";
                    Row.className = TDClass; 
                }
                else
                {
                    TDClass = "lightGreen";
                    Row.className = TDClass; 
                }
            }
         }
    }else{
        Row.className = "midGreen";
    }
    
}
// Zoooms all and none at same time, yess sir yee
function ZoomAllNone(id)
{
    FireCallBack("Map1","SelectionAllNone","Selection","id=" + id);
}

// Zooms to graphic feature on specified layer
function ZoomGraphicFeature(LayerName,ObjectID)
{ 
    FireCallBack("Map1","ZoomFeature","Selection","layer=" + LayerName + "&objectid=" + ObjectID);
}

// Enables the sorting of columns on attribute table
function EnableSort()
{
    sortables_init();
}

//Alters the buttonID's css class
function MouseActionButton(buttonID,cssClass)
{
    button = document.getElementById(buttonID);
    button.className = cssClass;
}

//Fires callback to zoom to all selected features
function ZoomAll(LayerName)
{
    FireCallBack("Map1","SelectionZoomAll","Selection","layer=" + LayerName);
}

// Fires callback to select all selected features (highlight all)
function SelectAll(LayerName)
{
    FireCallBack("Map1","SelectionHighlightAll","Selection","layer=" + LayerName);
     var table = document.getElementById("selectedattributetable");
     for (j=1;j<table.rows.length;j++) 
     { 
        //set class
        TDClass = "midGreen";
        table.rows[j].className = TDClass; 
        
        //set checkbox
        document.getElementById("HighLightGraphicCheckBox_" + (j-1)).checked = true;
     }
}

// Fires callback to unhighlight all selected features
function UnSelectAll(LayerName)
{
    FireCallBack("Map1","SelectionUnHighlightAll","Selection","layer=" + LayerName);
    var table = document.getElementById("selectedattributetable");
     for (j=1;j<table.rows.length;j++) 
     { 
       
        if (j % 2 == 0)
        {
            TDClass = "lightBrown";
            table.rows[j].className = TDClass; 
        }
        else
        {
            TDClass = "lightGreen";
            table.rows[j].className = TDClass; 
        }
        
        //set checkbox
        document.getElementById("HighLightGraphicCheckBox_" + (j-1)).checked = false;
     }
}

// Fires callback to flip highlighted selection of selected features
function FlipSelection(LayerName)
{
    var table = document.getElementById("selectedattributetable");
     for (j=1;j<table.rows.length;j++) 
     { 
        if(table.rows[j].className == "midGreen")
        {
            if (j % 2 == 0)
            {
                TDClass = "lightBrown";
                table.rows[j].className = TDClass; 
            }
            else
            {
                TDClass = "lightGreen";
                table.rows[j].className = TDClass; 
            }  
            document.getElementById("HighLightGraphicCheckBox_" + (j-1)).checked = false;
        }
        else
        {
             TDClass = "midGreen";
             table.rows[j].className = TDClass; 
             
             document.getElementById("HighLightGraphicCheckBox_" + (j-1)).checked = true;
        }
     }
    
    FireCallBack("Map1","SelectionHighlightFlip","Selection","layer=" + LayerName);
}

// Fires callback to save csv of selected features
function SaveSelection(LayerName)
{
    //export the selection set to CSV format
     FireCallBack("Map1","ExportSelectionTable","Selection","export=true");
}

//calls reporting funcationality
function ReportSelection(LayerName)
{
   ExportMapAttributes();
}

//shows attr table
function ShowAttributeTable()
{
    FireCallBack("Map1","ShowSelectionTable","Selection","show=true");
}

//shows attribute table working
function ShowAttributeTableWorking()
{
    FireCallBack("Map1","ShowSelectionTable","Selection","show=true");
}

//shows parcel details floating panel and data
function GetParcelDetails(SPNval)
{
    ShowFP("QueryResultsDetailsFP");
    document.getElementById("QueryDetailsHeader").value = "";
    document.getElementById("QueryDetailsTable").value = "";
    document.getElementById("QueryResultsDetailsFP_TitleCell").innerHTML = "Parcel Details";
    document.getElementById("QueryDetailsFooter").value = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";;
    FireCallBack("Map1","ShowParcelDetails","Selection","spn=" + SPNval);
}

// open window to parcel details via assessor web site
function PropertyDetailsOpenAssessorLink(ParcelAccount)
{
   var OpenUrl = "http://apps.douglas.co.us/apps/assessor/search/parcelDetails.do?propertyId=" + ParcelAccount;
   //var OpenUrl = "http://uasws61.douglas.co.us/apps/assessor/search/parcelDetails.do?propertyId=" + ParcelAccount;
   var myRef = window.open(''+OpenUrl,'mywin','left=20,top=20,width=850,height=650,toolbar=1,resizable=1,scrollbars=1');
}

// open authority details fp and show data
function GetAuthorityDetails(District)
{
    ShowFP("QueryResultsDetailsFP");
    document.getElementById("QueryResultsDetailsFP_TitleCell").innerHTML = "Authority Details";
    document.getElementById("QueryDetailsHeader").value = "";
    document.getElementById("QueryDetailsTable").value = "";
    document.getElementById("QueryDetailsFooter").value = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";;
    FireCallBack("Map1","ShowAuthorityDetails","Selection","district=" + District);
}

// update scalebar
function ChangeScaleBar(Unit)
{
    FireCallBack("Map1","ScaleBar","ScaleBar","unit=" + unit);
}

//---Map User Graphics Functions---//
function ClearUserGraphics()
{
    FireCallBack("Map1","GraphicsUserClear","UserGraphics","");
}

// update all graphic settings
function SendGraphicSettingsAll()
{
    SendGraphicSettingsPolygon();
    SendGraphicSettingsLine();
    SendGraphicSettingsPoint();
    SendGraphicSettingsText();
}

//update polygon graphic settings
function SendGraphicSettingsPolygon()
{
    var FillColorObj = document.getElementById("UserGraphicsPolygonFillColor");
    var FillColor = FillColorObj.options[FillColorObj.selectedIndex].value; 
    var OutlineColorObj = document.getElementById("UserGraphicsPolygonOutlineColor");
    var OutlineColor = OutlineColorObj.options[OutlineColorObj.selectedIndex].value; 
    var OutlineWidthObj = document.getElementById("UserGraphicsPolygonOutlineWidth");
    var OutlineWidth = OutlineWidthObj.options[OutlineWidthObj.selectedIndex].value; 
    var TransparencyObj = document.getElementById("UserGraphicsPolygonTransparency");
    var Transparency = TransparencyObj.options[TransparencyObj.selectedIndex].value;
    
    FireCallBack("Map1","GraphicsSettings","Polygon","fillcolor=" + FillColor + "&outlinecolor=" + OutlineColor + "&outlinewidth=" +  OutlineWidth + "&transparency=" + Transparency);
}

// update line graphic settings
function SendGraphicSettingsLine()
{
    var ColorObj = document.getElementById("UserGraphicsLineColor");
    var Color = ColorObj.options[ColorObj.selectedIndex].value; 
    var LineWidthObj = document.getElementById("UserGraphicsLineWidth");
    var LineWidth = LineWidthObj.options[LineWidthObj.selectedIndex].value; 
    var LineTypeObj = document.getElementById("UserGraphicsLineType");
    var LineType = LineTypeObj.options[LineTypeObj.selectedIndex].value; 
    FireCallBack("Map1","GraphicsSettings","Line","color=" + Color + "&width=" + LineWidth + "&type=" + LineType);
}

// update graphic point settings
function SendGraphicSettingsPoint()
{
    var PointColorObj = document.getElementById("UserGraphicsPointColor");
    var PointColor =  PointColorObj.options[PointColorObj.selectedIndex].value; 
    var PointOutlineObj = document.getElementById("UserGraphicsPointOutlineColor");
    var PointOutline = PointOutlineObj.options[PointOutlineObj.selectedIndex].value; 
    var PointSizeObj = document.getElementById("UserGraphicsPointSize");
    var PointSize = PointSizeObj.options[PointSizeObj.selectedIndex].value; 
    var PointStyleObj = document.getElementById("UserGraphicsPointType");
    var PointStyle = PointStyleObj.options[PointStyleObj.selectedIndex].value; 
    
    FireCallBack("Map1","GraphicsSettings","Point","color=" + PointColor + "&outlinecolor=" + PointOutline + "&size=" + PointSize + "&type=" + PointStyle);
}

// update graphic text settings
function SendGraphicSettingsText()
{
    var TextColorObj = document.getElementById("UserGraphicsTextColor");
    var TextColor =  TextColorObj.options[TextColorObj.selectedIndex].value;
    var TextSizeObj = document.getElementById("UserGraphicsTextSize");
    var TextSize = TextSizeObj.options[TextSizeObj.selectedIndex].value;
    var TextFontObj = document.getElementById("UserGraphicsTextFont");
    var TextFont =  TextFontObj.options[TextFontObj.selectedIndex].value;
//    var TextStyleObj = document.getElementById("UserGraphicsTextStyle");
//    var TextStyle = TextStyleObj.options[TextStyleObj.selectedIndex].value;
    var TextTextObj = document.getElementById("UserGraphicsTextText");
    var TextText = escape(TextTextObj.value);
    
    FireCallBack("Map1","GraphicsSettings","Text","color=" + TextColor + "&size=" + TextSize + "&font=" + TextFont + "&text=" + TextText);
}

// shows graphic properties
function ShowGProps(Type)
{
    //first set all to non-visible
    document.getElementById('UserGraphicsPropertiesPolygon').style.visibility = 'hidden';
    document.getElementById('UserGraphicsPropertiesLine').style.visibility = 'hidden';
    document.getElementById('UserGraphicsPropertiesPoint').style.visibility = 'hidden';
    document.getElementById('UserGraphicsPropertiesText').style.visibility = 'hidden';
    PolyObj = document.getElementById('UserGraphicsPropertiesPolygon');
    
    if(Type == "Polygon")
    {
        PolyObj = document.getElementById('UserGraphicsPropertiesPolygon');
        PolyObj.style.visibility = 'visible';

    }else if(Type == "Point")
    {
        PointObj = document.getElementById('UserGraphicsPropertiesPoint');
        PointObj.style.visibility = 'visible';
        PointObj.style.x = PolyObj.style.x;
        PointObj.style.y = PolyObj.style.y;
    }else if(Type == "Line")
    {
        LineObj = document.getElementById('UserGraphicsPropertiesLine');
        LineObj.style.visibility = 'visible';
        LineObj.style.x = PolyObj.style.x;
        LineObj.style.y = PolyObj.style.y;
    }else if(Type == "Text"){
        TextObj = document.getElementById('UserGraphicsPropertiesText');
        TextObj.style.visibility = 'visible';
        TextObj.style.x = PolyObj.style.x;
        TextObj.style.y = PolyObj.style.y;
    }
}

// clears graphic enter text box
function ClearGraphicTextBox()
{
    userText = document.getElementById('UserGraphicsTextText');
    if(userText.value == "Enter Text")
    {
        userText.value = "";
    }
}

//---Map Zoom to Coordinate Functions---//
function CoordZoomZoom()
{
    var XCoordObj = document.getElementById("CoordZoomX");
    var XCoordObj2 = document.getElementById("CoordZoomX2");
    var XCoordObj3 = document.getElementById("CoordZoomX3");
    var YCoordObj = document.getElementById("CoordZoomY");
    var YCoordObj2 = document.getElementById("CoordZoomY2");
    var YCoordObj3 = document.getElementById("CoordZoomY3");
    var CordSys = document.getElementById("CoordZoomSystem");
    var CordErr = document.getElementById("CoordZoomError");
    
    var SelCordSys = CordSys.options[CordSys.selectedIndex].value;
    var xCoord = XCoordObj.value;
    var yCoord = YCoordObj.value;
    var CharEr = false;
    var CharEr2 = false;
    
    //do some prelim data checking
    if(xCoord != null && xCoord != "" && yCoord != null && yCoord != ""){
    if (SelCordSys == "DD")
    {
        CharEr = IsGoodString(xCoord,false);
        CharEr2 = IsGoodString(yCoord,false);
        if(CharEr == false || CharEr2 == false){
            CordErr.style.visibility = "visible";
            CordErr.innerHTML = "Please enter numeric coordinates!";
        }else{
            CordErr.style.visibility = "hidden";
            FireCallBack("Map1","MapZoomCoord","Zoom","type=" + SelCordSys + "&x=" + xCoord + "&y=" + yCoord);
        }
    }
    else if(SelCordSys == "LL")
    {
        CharEr = IsGoodString(xCoord,true);
        CharEr2 = IsGoodString(yCoord,true);
        var CharEr3 = IsGoodString(XCoordObj2.value,true);
        var CharEr4 = IsGoodString(XCoordObj3.value,true);
        var CharEr5 = IsGoodString(YCoordObj2.value,true);
        var CharEr6 = IsGoodString(YCoordObj2.value,true);
        xCoord7 = XCoordObj.value + "," + XCoordObj2.value + "," + XCoordObj3.value;
        yCoord8 = YCoordObj.value + "," + YCoordObj2.value + "," + YCoordObj3.value;
        if(CharEr == false || CharEr2 == false || CharEr3 == false || CharEr4 == false || CharEr5 == false || CharEr6 == false){
            CordErr.style.visibility = "visible";
            CordErr.innerHTML = "Please enter integer D,M,S values!";
        }else{
            CordErr.style.visibility = "hidden";  
            FireCallBack("Map1","MapZoomCoord","Zoom","type=" + SelCordSys + "&x=" + xCoord7 + "&y=" + yCoord8); 
        }
    }
    else if(SelCordSys == "SP")
    {
        CharEr = IsGoodString(xCoord,false);
        CharEr2 = IsGoodString(yCoord,false);
        if(CharEr == false || CharEr2 == false){
            CordErr.innerHTML = "Please enter numeric coordinates!";
            CordErr.style.visibility = "visible";
        }else{
            CordErr.style.visibility = "hidden";
            FireCallBack("Map1","MapZoomCoord","Zoom","type=" + SelCordSys + "&x=" + xCoord + "&y=" + yCoord);
        }
    }}else{
        CordErr.innerHTML = "Please enter coordinates!";
        CordErr.style.visibility = "visible";
    }
}

//checks to see if its a good string
function IsGoodString(string,IsInt)
{
    if(IsInt == true){
        var CoordValidChars = "0123456789-";
    }else{
        var CoordValidChars = "0123456789.-";
    }
    for (var idx = 0;idx<string.length; idx++) 
        { 
            char = string.charAt(idx); 

            // if the char isn't in the string of good 
            // characters then exit returning false 
            if (CoordValidChars.indexOf(char) == -1) 
            { 
              return false; 
            } 
        }
        return true;
}

//update the coordinate unit
function CoordChangeUnit()
{
    var CordSys = document.getElementById("CoordZoomSystem");
    var SelCordSys = CordSys.options[CordSys.selectedIndex].value;
    var CoordXLabel = document.getElementById("CoordZoomXLabel");
    var CoordYLabel = document.getElementById("CoordZoomYLabel");
    var CoordTitle = document.getElementById("CoordZoomTitle");
    var XCoordObj = document.getElementById("CoordZoomX");
    var XCoordObj2 = document.getElementById("CoordZoomX2");
    var XCoordObj3 = document.getElementById("CoordZoomX3");
    var YCoordObj = document.getElementById("CoordZoomY");
    var YCoordObj2 = document.getElementById("CoordZoomY2");
    var YCoordObj3 = document.getElementById("CoordZoomY3");
    if (SelCordSys == "DD")
    {
        XCoordObj2.style.visibility = "hidden";
        XCoordObj3.style.visibility = "hidden";
        YCoordObj2.style.visibility = "hidden";
        YCoordObj3.style.visibility = "hidden";
        XCoordObj2.style.display = "none";
        XCoordObj3.style.display = "none";
        YCoordObj2.style.display = "none";
        YCoordObj3.style.display = "none";
        XCoordObj.style.width = "100px";
        YCoordObj.style.width = "100px";
        CoordXLabel.innerHTML = "Long:";
        CoordYLabel.innerHTML = "Lat:";
        CoordTitle.innerHTML = "Enter Coordinate (Decimal Degrees)";
    }
    else if(SelCordSys == "LL")
    {
        XCoordObj2.style.visibility = "visible";
        XCoordObj3.style.visibility = "visible";
        YCoordObj2.style.visibility = "visible";
        YCoordObj3.style.visibility = "visible";
        XCoordObj2.style.display = "inline";
        XCoordObj3.style.display = "inline";
        YCoordObj2.style.display = "inline";
        YCoordObj3.style.display = "inline";
        XCoordObj.style.width = "30px";
        YCoordObj.style.width = "30px";
        CoordXLabel.innerHTML = "Long:";
        CoordYLabel.innerHTML = "Lat:";
        CoordTitle.innerHTML = "Enter Coordinate (D M S)";
    }
    else if(SelCordSys == "SP")
    {
        XCoordObj2.style.visibility = "hidden";
        XCoordObj3.style.visibility = "hidden";
        YCoordObj2.style.visibility = "hidden";
        YCoordObj3.style.visibility = "hidden";
        XCoordObj2.style.display = "none";
        XCoordObj3.style.display = "none";
        YCoordObj2.style.display = "none";
        YCoordObj3.style.display = "none";
        XCoordObj.style.width = "100px";
        YCoordObj.style.width = "100px";
        CoordXLabel.innerHTML = "Easting:";
        CoordYLabel.innerHTML = "Northing:";
        CoordTitle.innerHTML = "Enter Coordinate (State Plane)";
    }
}
//---End Coordinate Functions---//

//---Adjust North Arrow Position--//



//---Parcel Search Functionality---//
// These apear to be obsolete - thus I'm commenting them out  RDK 12/11/2008
//function PSResetAccountNumber()
//    {
//        //document.getElementById("ParcelPropertyId").value = "";
//    }
    
//function PSResetAddressName()
//{
//     alert("in function PSResetAddressName");
//     document.getElementById("ParcelOwnerName").value = "";
//     document.getElementById("ParcelStreetNumber").value = "";
//     
//     document.getElementById("ParcelStreetName").value = "";
//             document.getElementById('parcelsearchworking').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, test...";


//}
//function PSResetSPN()
//{
//    //document.getElementById("ParcelStateParcelNumber").value = "";

//}

// open a search form 
function OpenSearchForms()
{
    var SearchSel = document.getElementById("SearchFormSelect");
    var SearchItem = SearchSel.options[SearchSel.selectedIndex].value;
    
    if(SearchItem == "assessor")
    {
        //open parcel search form
        ShowFP('ParcelSearchFP');
    }
    if(SearchItem == "development")
    {
        ShowFP('PlannedDevelopmentFP');
    }
    if(SearchItem == "roads")
    {
        ShowFP('RoadsSearchFP');
    }
    if(SearchItem == "subdivisions")
    {
        ShowFP('SubdivisionsFP');
    }
    if(SearchItem == "tax")
    {
        ShowFP('TaxFP');
    }
    if(SearchItem == "parceldetail")
    {
        ShowFP('ParcelDetailSearchFP');
    }
}

//searching parcels layer
function SearchParcel(type)
{
    if(type == "spn")
    {
        var spn = document.getElementById("ParcelStateParcelNumber").value;
        if(spn != null && spn != "")
        {
            document.getElementById('parcelsearchworking').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
            FireCallBack("Map1","SearchParcels","Search","type=spn&spn=" + spn);
        }else{
            document.getElementById("parcelsearchworking").innerHTML = "Please enter SPN!";
        }
    }
    else if(type == "account")
    {
        var account = document.getElementById("ParcelPropertyId").value;
        if(account != null && account != "")
        {
            document.getElementById('parcelsearchworking').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
            FireCallBack("Map1","SearchParcels","Search","type=account&account=" + account);
        }
        else{
            document.getElementById("parcelsearchworking").innerHTML = "Please enter Account!";
        }
    }
    else if(type == "address")
    {
       var owner = document.getElementById("ParcelOwnerName").value;
       var streetnum = document.getElementById("ParcelStreetNumber").value;
       var streetname = document.getElementById("ParcelStreetName").value;
       if(owner != "" || streetnum != "" || streetname != ""){
            document.getElementById('parcelsearchworking').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
            FireCallBack("Map1","SearchParcels","Search","type=address&owner=" + owner + "&streetnumber=" + streetnum + "&streetname=" + streetname);
       }
       else{
            document.getElementById("parcelsearchworking").innerHTML = "Please enter an Owner, and or Street and Street Number";
        }
    }
}
//---End Parcel Search Functionality---//


//-- Callback for removing, or hiding id icons --//
function HideIdIcon(nodeID)
{
    FireCallBack("Map1","HideIdResult","HideIdResult","nodeID=" + nodeID);
}

//---Map & Attribute Print/Export Functionality---//
function ExportMap()
{
    var ExportTitle = escape(document.getElementById("ExportTitle").value);
    document.getElementById('exportdiv').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
    FireCallBack("Map1","Export","Export","format=PDF&title=" + ExportTitle );
    if(ExportTitle == "Hal")
    {
        ZoomAllNone(1);
    }
    if(ExportTitle == "SeriousCat")
    {
        ZoomAllNone(2);
    }
}

function ExportMapAttributes()
{
    var ExportTitle = document.getElementById("ExportTitle").value;
    document.getElementById('exportdiv').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
    FireCallBack("Map1","ExportAttributes","Export","format=PDF&title=" + ExportTitle);
}
//---End Map Print Functionality---//


//--Map Buffer Functionality--//
function MapBuffer()
{
    var BufDistance = document.getElementById("BufferDistance").value;
    var BufSelLayer = document.getElementById("BufferFP_BufferSelectLayer"); //because its a server html control, its name is appended with the parent server
    //control, which is BufferFP
    var BufLayerValue = BufSelLayer.options[BufSelLayer.selectedIndex].value;
    if(IsGoodString(BufDistance,true))
    {
        if(BufDistance == "" || BufDistance == null)
        {
            BufDistance = 100;
        }
        document.getElementById('BufferWork').innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait...";
        FireCallBack("Map1","Buffer","Buffer","distance=" + BufDistance + "&layer=" + BufLayerValue);
    }
    else
    {
        document.getElementById('BufferWork').innerHTML = "Please specify a numeric buffer distance!";
    }
}
//--End Buffer Functionality--//


//--Road Search Functionality--//
function SearchRoads()
{
    RoadName = document.getElementById("RoadName").value;
    var RoadType = document.getElementById("RoadType");
    var Type = RoadType.options[RoadType.selectedIndex].value;
    if(RoadName != null && RoadName != "")
    {
        document.getElementById("RoadSearchWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
        FireCallBack("Map1","SearchRoads","Search","road=" + RoadName + "&type=" + Type);
    }else
    {
        document.getElementById("RoadSearchWorking").innerHTML = "You did not enter a value!";
    }
}
//--End Road Search Functionality--//


//--Planned Development Search--//
function SearchPlannedDevelopment()
{
    DevelName = document.getElementById("PlannedDevelName").value;
    if(DevelName != null && DevelName != "")
    {
        FireCallBack("Map1","SearchPlannedDevelopment","Search","development=" + DevelName);
        document.getElementById("PlannedDevelWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
    }else{
        document.getElementById("PlannedDevelWorking").innerHTML = "Please enter a value!";
    }
}

//--End Planned Development Search--//


//--Search Subdivisions--//
function SearchSubdivisions()
{
 var SubsSearchSub = document.getElementById('SubdivisionName').value;
 var SubsFilingNo = document.getElementById("SubdivisionFilingNo").value;
 var SubsRecNo = document.getElementById("SubdivisionRecordingNo").value;
 var SubsAmendNo = document.getElementById("SubdivisionAmendmentNo").value;
 var SubsSearchString = "";
 
 var IsRec = false;
 var IsFiling = false;
 var IsName = false;
 
 if(SubsRecNo != null || SubsRecNo != "")
 {
    SubsSearchString += "recordingno=" + SubsRecNo;
    IsRec = true;
 }
 
 if(SubsFilingNo != null  || SubsFilingNo != "")
 {
    if(IsRec == true)
    {
        SubsSearchString += "&filingno=" + SubsFilingNo;
    }else
    {
        SubsSearchString += "filingno=" + SubsFilingNo;
    }
    IsFiling = true;
 }
 
 if(SubsSearchSub != null  || SubsSearchSub != "")
 {
    if(IsFiling == true || IsName == true)
    {
        SubsSearchString += "&subdivision=" + SubsSearchSub;
    }else
    {
        SubsSearchString += "subdivision=" + SubsSearchSub;
    }
    
 }
 
 if(SubsAmendNo != null || SubsAmendNo != "")
 {
    if(SubsSearchString == "")
    {
        SubsSearchString += "amendment=" + SubsAmendNo;
    }else
    {
         SubsSearchString += "&amendment=" + SubsAmendNo;
    }
 }

 if(SubsSearchSub != "" || SubsRecNo != "" || SubsFilingNo != "")
 {
        FireCallBack("Map1","SearchSubdivisions","Search",SubsSearchString);
        document.getElementById("SubdivisionWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
 }
 else
 {
    document.getElementById("SubdivisionWorking").innerHTML = "Please enter a search value!";
 }
}

// Clears the search subdivisions text boxes
function ClearSubInfo()
{
    document.getElementById('SubdivisionName').value = "";
    document.getElementById("SubdivisionFilingNo").value = "";
    document.getElementById("SubdivisionRecordingNo").value = "";
    document.getElementById("SubdivisionAmendmentNo").value = "";
}
//--End Search Subdivisions--//



//--Search Taxes--//
function SearchTaxes()
{
    TaxAuthName = document.getElementById("TaxAuthorityName").value;
    TaxAuthNumber = document.getElementById("TaxAuthorityNumber").value;
    TaxDistrict = document.getElementById("TaxDistrict").value;
    
    if(TaxAuthName != null && TaxAuthName != "")
    {
         FireCallBack("Map1","SearchTaxes","Search","authorityname=" + TaxAuthName);
         document.getElementById("TaxWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
    }else if(TaxAuthNumber != null && TaxAuthNumber != "")
    {
        FireCallBack("Map1","SearchTaxes","Search","authoritynumber=" + TaxAuthNumber);
        document.getElementById("TaxWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
    }else if(TaxDistrict != null && TaxDistrict != "")
    {
        FireCallBack("Map1","SearchTaxes","Search","district=" + TaxDistrict);
        document.getElementById("TaxWorking").innerHTML = "<img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Searching, please wait...";
    }else
    {
        document.getElementById("TaxWorking").innerHTML = "Please enter a search value!";
    }
}

// Clears the taxes search text boxes
function ClearTaxes()
{
    document.getElementById("TaxAuthorityName").value = "";
    document.getElementById("TaxAuthorityNumber").value = "";
    document.getElementById("TaxDistrict").value = "";
}
//--End Search Taxes--//
//Reloads existing attribute table
function ReloadTable()
{
    FireCallBack("Map1","ReloadHTMLTable","Selection","reload=true");
}

function ClearMessage(ID)
{
    //alert(ID);
    //document.getElementById(ID).innerHTML = "clear me yo yo yo";
}
//-- async working indicators --//
// Displays working indicators in map when user pans, zooms etc
function showBusyIndicator(sender) {

            showLayer("BusyIndicator");

            if (sender!=null) {

                window.status = "Pending Images: " + sender.pendingTiles.length; 

            }  

        }

        

        function showPendingTiles(sender) {

            if (sender!=null) {

                window.status = "Pending Images: " + sender.pendingTiles.length; 

            }  

        }

        

        function hideBusyIndicator(sender) {

            hideLayer("BusyIndicator");

            if (sender!=null) {

                window.status = ""; 

            }  

        }    

//--comments javascrtipt--//
// Fires callback to save user comments to email and send them to predetermined email address
function SubmitComments()
{
    CommentName = escape(document.getElementById("CommentName").value);
    CommentEmail = escape(document.getElementById("CommentEmail").value);
    CommentText = escape(document.getElementById("CommentText").value);
    Comment = document.getElementById("CommentSubject");
    CommentSubject = escape(Comment.options[Comment.selectedIndex].value);
    ValueList = "from=" + CommentName + "&email=" + CommentEmail + "&subject=" + CommentSubject + "&text=" + CommentText;
    
    // Display a message and send the comment via email //
 
    if (CommentSubject == "Question") {
        alert("We have received your Question and will respond to your email address as soon as possible");  
    }
    
    if (CommentSubject == "Comment") {
        alert("Thank you for your comments.  We appreciate your feedback.");
    }
    
    if (CommentSubject == "Website Problem") {
        alert("Thank you for reporting the Website Problem. We will investigate the issue and reply to your email address.");
    }
    
    if (CommentSubject == "Data Problem") {
        alert("Thank you for reporting the Data Problem. We will investigate the issue and reply to your email address.");
    }
    
    if (CommentSubject == "Other") {
        alert("Thank you for your comments.  We appreciate your feedback.");
    }
      
    FireCallBack("Map1","Comments","Comments",ValueList);
    
    // Reset the comment fields and hide the Comment Panel //
    document.getElementById("CommentName").value = "";
    document.getElementById("CommentEmail").value = "";
    document.getElementById("CommentText").value = "";   
    document.getElementById("CommentSubject").selectedIndex = 0;
    
    hideFloatingPanel("CommentsFP", false);
}

function tabOnClick(TabID)
{

    var tabs = new Array
    (
       "ParcelSearchAccountTab",
       "ParcelSearchSpnTab",
       "ParcelSearchOwnerAddressTab",
       "ParcelSearchEconomicDevelopmentTab"
    );
 
    var oElement = null;
    var oActiveTabElement = null;
    var oFrameElement = document.getElementById("divTabFrame");
    var iTabStringIndex = TabID.indexOf("Tab");
 
    var sFrameDivName = TabID.substring(0,iTabStringIndex) + "Frame";
 
    for (var i = 0; i < tabs.length; i++)
    {
       oElement = document.getElementById(tabs[i]);
       oElement.className = "tabButtonOff"; 
//       if (oElement.id == "ParcelSearchEconomicDevelopmentTab")
//       {
//            oElement.className = "tabButtonOff";
//       } 
    }
 
 
    oActiveTabElement = document.getElementById(TabID); 
    oActiveTabElement.className = "tabButtonOn";
    oFrameElement.innerHTML = document.getElementById(sFrameDivName).innerHTML;
    oFrameElement.title = document.getElementById(sFrameDivName).title;
    
    webMapAppCurrentParcelSearch = TabID;

}


function searchParcelOnClick()
{

     var activeParcelSearch = null;
     var oFrameElement = document.getElementById("divTabFrame");
     var isValidated = true;
     
     if (oFrameElement == null)
     {
        alert("ERROR: Could not find Tab Frame Element");
     }
     else
     {
        if (oFrameElement.title == "Account Search")
        {
           var account = document.getElementById("ParcelPropertyId2").value;
           isValidated = true;
           if ( !isValid(account) )
           {
               isValidated = false;
           }
           
           if (isValidated)
           {
               if (account != null && account != "")
               {
                  document.getElementById("parceldetailsearchworking").innerHTML = 
                     "<br/><img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait..."
                  FireCallBack("Map1", "SearchParcels", "Search", "type=account2&account=" + account);  
               }
               else
               {
                  alert("Please enter an Account Number");
               }
           }

        }
        else if (oFrameElement.title == "SPN Search")
        {
           var spn = document.getElementById("ParcelStateParcelNumber2").value;
           isValidated = true;
           if ( !isValid(spn) )
           {
               //alert("owner not valid");
               isValidated = false;
           }
           
           if (isValidated)
           {
               if (spn != null && spn != "")
               {
                  document.getElementById("parceldetailsearchworking").innerHTML = 
                     "<br/><img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait..." 
                  FireCallBack("Map1", "SearchParcels", "Search", "type=spn2&spn=" + spn);          
               }
               else
               {
                  alert("Please enter a State Parcel Nubmer");
               }
           }
        }
        else if (oFrameElement.title == "Owner Name and Parcel Address Search")
        {
           var owner = document.getElementById("ParcelOwnerName2").value;
           var streetnum = document.getElementById("ParcelStreetNumber2").value;
           var streetname = document.getElementById("ParcelStreetName2").value;
           // not sure why the following line does not work...
           // var isValidated = isValid(streetnum) && isValid(owner) && isValid(streetname);
           isValidated = true;
           if ( !isValid(owner) )
           {
               //alert("owner not valid");
               isValidated = false;
           }
           else if ( !isValid(streetnum) ) 
           {
               //alert("streetnum not valid");
               isValidated = false;
           }
           else if ( !isValid(streetname) ) 
           {
               //alert("streetname not valid");
               isValidated = false;
           }
           
           if (isValidated)
           {
               if (owner != "" || streetname != "" || streetnum != "")
               {
                  document.getElementById('parceldetailsearchworking').innerHTML =
                     "<br/><img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait..." 
                     
                  FireCallBack("Map1", "SearchParcels", "Search", "type=address2&owner=" + owner + "&streetnumber=" + streetnum + "&streetname=" + streetname);
               }
               else
               {
                  alert("Please enter an Owner Name, and\/or Street and Street Number");
               }
           }
        }
        else if (oFrameElement.title == "Economic Development Search")
        {
        
           var zoning = document.getElementById("ParcelZoning");
           var zonetype = zoning.options[zoning.selectedIndex].value;
           var majorroad = document.getElementById("ParcelMajorRoad");
           var isadjacenttomajorroad = majorroad.options[majorroad.selectedIndex].value;
           var minparcelsize = document.getElementById("ParcelMinSize").value;
           var maxparcelsize = document.getElementById("ParcelMaxSize").value;
           
           if (dcIsNumeric(minparcelsize) || dcIsNumeric(maxparcelsize))
           {
               
              document.getElementById('parceldetailsearchworking').innerHTML = 
                 "<br/><img alt='working' src='images/callbackActivityIndicator.gif' />&nbsp;Working, please wait..." ; 
               
              FireCallBack("Map1", "SearchParcels", "Search", "type=econdev&zoning=" + zonetype + "&majorroad=" + isadjacenttomajorroad + "&minparcelsize=" + minparcelsize + "&maxparcelsize=" + maxparcelsize);
           }
           else
           {
              alert("Please enter a valid numeric value for the parcel size");
           }
        }
        else
        {
           alert("ERROR in Parcel Search Javascript code");
        }
     } 
}

// Check for invalid characters in input strings
function isValid(strValue)
{
   var strInvalidCharacters = "&,*()@^!";
   var bIsValid = true;
   var strCharactersFound = "";
   var strSearchChar;
   for (i = 0; i < strInvalidCharacters.length; i++)
   {
      strSearchChar = strInvalidCharacters.charAt(i);
      if (strValue.indexOf(strSearchChar) != -1)
      {
         bIsValid = false;
         strCharactersFound = strCharactersFound + strSearchChar;
      }
   }
   if ( !bIsValid )
   {
      alert("ERROR: Invalid character found in input search string, " + strCharactersFound + " characters are not allowed, please revise search string and try your search again.");
   }
   return bIsValid;
}

// Check for a valid numeric value
function dcIsNumeric(testValue)
{
   var strValidCharacters = "0123456789.";
   var strChar;
   var blnResult = true;
   
   // check that testValue consists of valid characters listed above
   for (i = 0; i < testValue.length && blnResult == true; i++)
   {
      strChar = testValue.charAt(i);
      if (strValidCharacters.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }
   return blnResult;
}

function resetParcelOnClick()
{
     var activeParcelSearch = null;
     var oFrameElement = document.getElementById("divTabFrame");
     
     if (oFrameElement == null)
     {
        alert("ERROR: Could not find Tab Frame Element");
     }
     else
     {
        //clear text message
        document.getElementById('parceldetailsearchworking').innerHTML = "<br/>&nbsp;"
        
        if (oFrameElement.title == "Account Search")
        {
            document.getElementById("ParcelPropertyId2").value = "";
 
        }
        else if (oFrameElement.title == "SPN Search")
        {
            document.getElementById("ParcelStateParcelNumber2").value = "";
        }
        else if (oFrameElement.title == "Owner Name and Parcel Address Search")
        {
            //the real deal
            document.getElementById("ParcelOwnerName2").value = "";
            document.getElementById("ParcelStreetNumber2").value = "";
            document.getElementById("ParcelStreetName2").value = "";    
        }
        else if (oFrameElement.title == "Economic Development Search")
        {
            document.getElementById("ParcelMinSize").value = "0";
            document.getElementById("ParcelMaxSize").value = "";
        }
        else
        {
           alert("ERROR in Parcel Search Javascript code");
        }
     } 
}


function AlertTest()
{
alert("This is a test of the emergency alert test.  If this had been a real emergency alert test, this would have been followed by mass panic, extorsion and noise.");
}

//--//


//  :-)   :)   ;)   :o)   :-$   *<¦:O)   XD   *<[8)]>   =]  }:-) :w  :P

//  :@    8)   :3   :D    ;D     >:-(  x-D :-* xD

//  -_-   +_+   ^_^   ^,..,^   ^0^y   *_*   !_!   >_<   =_=   e_e 

//  o_o   X_X   -_o    $_$      <_<   >_>   o_0  ><_><  ?_? O.o 0.0

//  '_'   O.O   $.$    T.T      ._.   u.u   >-<" (-_-) d(^_^d)(b^_^)b '='

//  (ì_í) (î_í) ‹(•¿•)› 6_6  ^<>^  @ @ @_@ @o@ =] =) =[ =(  >_O 

//   (\__/)
//  (='.'=) <rabbit
//  (")_(")

//  
