﻿
// Javascript file for Web Mapping Application
var m_measureToolbarId = "";
var reloadTimer = "";

// Global Printing Document Window 
var winPrintDocument = null;

// handler for window resize
function AdjustMapSizeHandler(e) {
    window.clearTimeout(reloadTimer);
	reloadTimer = window.setTimeout("SandGIS.resizeMap();",1000);
}
//----------------------------------------------
// Open Generic Dialog
//----------------------------------------------
function openDialogWindow(dialogName, dialogURL, parentControl, dlgWidth, dlgHeight)
{       
    //set the dialog header
    if (Ext.get('GenericHeader'))
    { 
         Ext.get('GenericHeader').dom.innerHTML = dialogName;
    
        //set the dialog url    
        Ext.get('GenericFrame').dom.src = dialogURL;

        //show the generic dialog
        SandGIS.showDialog('DlgGenericContainer',parentControl,dlgWidth,dlgHeight);
     }   
}

//----------------------------------------------
// Clear Generic Dialog
//----------------------------------------------
function clearDialogWindow(dialogName)
{       
    //set the dialog header
    if (Ext.get('GenericHeader'))
    { 
         Ext.get('GenericHeader').dom.innerHTML = dialogName;
    
        //set the dialog url    
        Ext.get('GenericFrame').dom.src = 'blank.htm';
     }   
}

//-----------------------------------------
// Load a page in a new window
//-----------------------------------------
function openNewWindow(url,dimensions)
{
    if (url != "")
    {     
        if (dimensions) dimensions = ","+dimensions;        
        var newWin = window.open(url,"","toolbar=no,menubar=yes"+dimensions);
        newWin.focus();                  
    }
}

//-------------------------------------------------------------
// Load the Printing Document in a new window
// Always opens the same window to Display Printing Documents
//-------------------------------------------------------------
function openPrintingDocument(url,dimensions)
{
    if (url != "")
    {     
        if (dimensions) dimensions = ","+dimensions;    
        winPrintDocument = window.open(url,"PrintDoc","toolbar=no,menubar=yes"+dimensions);
    }
}

//-----------------------------------------
// Replaces the outer html of the object
//-----------------------------------------
function ReplaceOuterHTML(objName, htmlString)
{
    var theObject = document.getElementById(objName);
    
     if (theObject)
     {
        theObject.outerHTML = htmlString;
     }
}
//----------------------------------------------
// function run at startup
//----------------------------------------------
function startUp() {
        var box;
        // set up identify mode for javascript
        map.ctrlMode = "MapIdentify";
        map.ctrlAction = "Point";
        map.ctrlCursor = "pointer";
        map.ctrlFunction = "MapIdClick(e)";
        map.mapUnits = "Feet";
        
        if (newLoad) {
            // execute only on intial load.... not callbacks
            map.divObject.style.cursor = "wait";
            
            // move measure toolbar to top left corner of map display 
            box = calcElementPosition("Map_Panel"); 
            var tb = document.getElementById(m_measureToolbarId);
			if (tb!=null) {
			    tb.style.left = box.left + "px";
			    tb.style.top = box.top + 28 + "px";
			}
							
        } 
        // set window resize event handler
        window.onresize = AdjustMapSizeHandler;      
       
      //-----------------------------------------------------
      //move the Overview Map's starting position 
      //-----------------------------------------------------
      box = calcElementPosition("Map_Panel");
      var ovMap = document.getElementById("OverviewMap_Panel");
      if (ovMap!=null)
      {
        ovMap.style.position = "absolute";
        moveLayer(ovMap.id, box.left, box.top+50);
      }       
       //-----------------------------------------------------
      //move the Navigation Compass's starting position 
      //-----------------------------------------------------
      var compass = document.getElementById("Compass_Panel");
      if (compass!=null)
      {
        compass.style.position = "absolute";
        moveLayer(compass.id, box.left, box.top+26);
        Ext.get("Compass_Panel").dom.style.zIndex = 10000;
      }       
      //=================================
      // Resize the Map
      //=================================
      firstLoad = false;
      SandGIS.resizeMap(); 
      newLoad = false;
}  
//-----------------------------------------------------------------
// 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; 
}

//------------------------------------------
// Toggles the specified element
//------------------------------------------
function toggleElement(elemName) {
    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();
           
    	var elem = document.getElementById(elemName);
   	if (elem!=null) { 
            	toggleFloatingPanelVisibility(elemName);            
    	} else 
        	alert(elemName + " is not available");     

    } 
    else
        showLapseAlert();


}
//-----------------------------------------------------------------
// <summary>
// Set a new map size for the Map control
// </summary>
// <param name="mapWidth">Map width in pixels</param>
// <param name="mapHeight">Map height in pixels</param>
// <remarks>
// Sets the new map width and height of the Map container and calls the 
// ADF map resize function to resize the Map control
// <example>
// The following example demonstrates how to use this method:
// <code>
// var cWidth = 600;
// var cHeight = 400;
// setMapSize(cWidth, cHeight);
// </code>
// </example>
// </remarks>
// <history>
// Juliana Castillo – Woolpert, Inc. (Created) 
// </history>
//-----------------------------------------------------------------
function SetMapSize(mapWidth, mapHeight) {
    // Retrieve the Map object and container
    pMapObject = document.getElementById("Map1");
    pMapObjectPanel = document.getElementById("Map_Panel");

    if ((mapWidth < 0) || (mapHeight < 0))
    {
        mapWidth = 100;
        mapHeight = 100;
    }
    //Resize Map Panel
    pMapObjectPanel.style.width = mapWidth.toString() + "px";
    pMapObjectPanel.style.height = mapHeight.toString() + "px";

//    var mWidth = mapWidth - 40;
//    var mHeight = mapHeight - 60;
    var mWidth = mapWidth;
    var mHeight = mapHeight;

    if ((mWidth < 0) || (mHeight < 0))
    {
        mWidth = 100;
        mHeight = 100;
    }

    //Resize Map Object
    pMapObject.style.width = mWidth.toString() + "px";
    pMapObject.style.height = mHeight.toString() + "px";

    //Calls the Map resize ADF function
    if ((map.width!=mWidth) || (map.height!=mHeight))
    {
        //ShowLoading();
        map.resize(mWidth, mHeight, true);
    }
}

// <summary>
// Setup Loading Image. Function is called in the page onLoad event
// </summary>
// <history>
// Juliana Castillo – Woolpert, Inc. (Created) 
// </history>
function SetupLoadingImg() {
   map.showLoading = true;
   map.loadingObject = document.getElementById("PnlLoadingMap");
   map.MapMouseUp = MapMouseUpLocal;
}

// <summary>
// Show the Loading Image and redirects to the default ADF MapMouseUp function
// </summary>
// <history>
// Juliana Castillo – Woolpert, Inc. (Created) 
// </history>
function MapMouseUpLocal(e) {
    ShowLoading();
    MapMouseUp(e);
    //woolpert
    window.setTimeout("HideLoading()", 3000);
}

//-----------------------------------------
// Load a page in a new window
//-----------------------------------------
function openNewWindow(url)
{
    if (url != "")
    {     
        var newWin = window.open(url,"","toolbar=yes,menubar=yes");
    }
}
//-----------------------------------------------------------------
// <summary>
// Processes the callback results
// </summary>
// <history>
// Aralola Akinmade (Created) 
// </history>
//-----------------------------------------------------------------
function processResults(response, context)
{

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();
           
        //alert("Processing stuff...." + context + " " + response);
        switch (context)
        {
//            //Export Map
//            case "ExportMap":        
//                    var linkURL = GetResponseString(response);
//                    DisplayMapLink(linkURL);
//                    break;   
                    
            //Print Map - Simple & Advanced
            case "PrintMap":            
                    var linkURL = GetResponseString(response);
                    //DisplayMapLink(linkURL);
                    break;
                 
            default:
                break;
        }
   
        //hide loading
        window.setTimeout("HideLoading()", 3000);
    } 
    else
        showLapseAlert();
}
//-----------------------------------------------------------------
// <summary>
// Further processes any additional information returned with the response
// </summary>
// <history>
// Aralola Akinmade (Created) 
// </history>
//-----------------------------------------------------------------
function GetResponseString(response)
{
    var responseArray = response.split("||||");
    var responseString;
      
    //hide loading
    window.setTimeout("HideLoading()", 3000);
      
        for (var x=0; x<responseArray.length;x++)
        {
           
            var optionsArray = responseArray[x].split("|-|")
            
            //return the value
            responseString = optionsArray[1];
            
            switch (optionsArray[0])
            {
                case "AlertMessage":
                    Ext.MessageBox.alert("",optionsArray[1], null);
                    break;
                
                //opens the link in a new window
                case "ShowURL":                
                    openNewWindow(responseString);
                    break;
                
                //opens the link in a new window
                case "ShowPrintingDocument":                
                    openPrintingDocument(responseString);
                    break;
                
//                //another action to update the map
//                case "MapUpdate":
//                     processResults(optionsArray[1], map.controlName);
//                break;
               
                default:
                break;   
            } 
       }     
      return responseString;
            
}
//-----------------------------------------------------------------
// <summary>
// Processes the callback errors
// </summary>
// <history>
// Aralola Akinmade (Created) 
// </history>
//-----------------------------------------------------------------
function postBackError(response, context)
{

}

////==============================================================================================================================
////                                                      MAP EXPORT FUNCTIONS
////==============================================================================================================================
//// <summary>
//// Starts proces of exporting map image
//// </summary>
//// <history>
//// Dominik M. – Woolpert, Inc. (Created) 
//// </history>
////-----------------------------------------------------------------
//function ExportMap(){
//    
//    //get file type
//    if (Ext.get("ExportMapTypeSelector")){
//        var fileType = document.getElementById("ExportMapTypeSelector").value;
//    }else{
//        //assume jpg
//        Ext.MessageBox.alert("Export Map", "Unable to retrieve image type from: ExportMapTypeSelector.\nMap will be exported to JPG.", null);
//         var fileType = "JPG";
//    }
//    
//    //set div inner html to loading image
//    if (Ext.get("ExportMapLink")){
//        Ext.get("ExportMapLink").dom.innerHTML = "&nbsp;<p><img src='images/callbackActivityIndicator.gif' alt='loading'/> exporting.....</p>";
//    }
//    
//    var message = "ControlType=Map&Eventarg=ExportMap&fileType="+fileType;
//    var context = "ExportMap"; //parent.map.controlName;
//    parent.WebForm_DoCallback('__Page',message,parent.processResults,context,parent.postBackError,true);        

//}
//-----------------------------------------------------------------
// <summary>
// Displays image link
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
//-----------------------------------------------------------------
//function DisplayMapLink(linkURL){    

//    //set div inner html to loading image
//    if (linkURL != ""){
//       if (document.frames["GenericFrame"].Ext)
//       {
//            var mapLink = document.frames["GenericFrame"].Ext.get("pnlMapLink");
//            if (mapLink){
//                mapLink.dom.innerHTML = "&nbsp;<p><a class='ZoomLink' href='" + linkURL + "' target='blank'>Click for map image</a></a>";
//            }
//        }        
//    }else{
//        Ext.MessageBox.alert("Export Map","Unable to retrieve url.", null);
//    }
//}
////-----------------------------------------------------------------
//// <summary>
//// Clears image link
//// </summary>
//// <history>
//// Dominik M. – Woolpert, Inc. (Created) 
//// </history>
////-----------------------------------------------------------------
//function ClearMapLink(){
//    //clear div inner html
//    if (Ext.get("pnlMapLink")){
//        Ext.get("pnlMapLink").dom.innerHTML = "";
//    }
//}


//-----------------------------------------------------------------
// <summary>
// Shows the results window and displays attributes
// It grabs the dataset from the session object
// </summary>
// <history>
// Aralola Akinmade - Woolpert, Inc 
// </history>
//-----------------------------------------------------------------
function showResults()
{
    
    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        //hide loading
        window.setTimeout("HideLoading()", 4000);
        
        Ext.get("ResultsFrame").dom.src="blank.htm?Page=Results.aspx";
            
        //show the results        
        SandGIS.showDialog('DlgResultsContainer', 'Toolbar1ShowResults');

    }
    else
    {
        showLapseAlert();
    }    
}
//-----------------------------------------------------------------
// <summary>
// Zooms to the feature
// </summary>
// <history>
// Aralola Akinmade - Woolpert, Inc 
// </history>
//-----------------------------------------------------------------
function zoomToFeature(fid, layerName)
{   
    
    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        var argument = 'EventArg=ZoomToFeature&LayerName=' + layerName + '&FeatureID=' + fid;
        var context = parent.map.controlName;
       
        //show loading
        parent.ShowLoading();
        
        //do post back
        parent.WebForm_DoCallback('__Page',argument,parent.processCallbackResult,context,parent.postBackError,true);            

    }
    else
    {
        showLapseAlert();
    }    
    
}
//-----------------------------------------------------------------
// <summary>
// Shows the EXT-JS progress bar
// </summary>
// <history>
// Aralola Akinmade - Woolpert, Inc 
// </history>
//-----------------------------------------------------------------
function showProgressBar()
{
        Ext.MessageBox.show({
           title: 'Please wait...',
           msg: 'Loading...',
           width:240,
           progress:true,
           closable:false
       });

       // this hideous block creates the bogus progress
       var f = function(v){
            return function(){
                if(v == 21){
                    Ext.MessageBox.hide();
                }else{
                    Ext.MessageBox.updateProgress(v/20, 'Loading results...');
                }
           };
       };
       for(var i = 1; i < 22; i++){
           setTimeout(f(i), i*1000);
       }
}

//==============================================================================================================================
//                                                  SELECTION TOOL FUNTIONS
//==============================================================================================================================
// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Joe LaCombe - Woolpert, Inc 
// Juliana C. – Woolpert, Inc. 
// Aralola Akinmade - Woolpert, Inc 7/25/2007
// </history>

function invokeSelectTool(toolName)
{   
    switch(toolName)
    {
        case "SelectByPoint":
            SelectByPoint('Map1');
            break;
        case "SelectByBox":
            SelectByBox('Map1');
            break;
        case "SelectByPolygon":
            SelectByPolygon('Map1');
            break;
        case "SelectByLine":
            SelectByLine('Map1');
            break;    
        case "ZoomToCityTownship":
            ZoomToCityTownship('Map1');
            break;    
        case "ClearSelection":
            ClearSelectionGraphics('Map1');
            break;
        default:
            break;
    }
       
}
//----------------------------------
// Get Selected Layer and Type
//----------------------------------
function GetSelectionLayerAndType()
{
   var argument;
   
    //Add Selected Layer & New Selection/Add to Selection
    var ddlSelectLayers = document.getElementById("SelectionLayers");
    var ddlSelectionType = document.getElementById("SelectionType");
   
    if (ddlSelectLayers != null)
    {
        SelectedLayerIndex=ddlSelectLayers.options[ddlSelectLayers.selectedIndex].value;
    }
    if (ddlSelectionType != null)
    {
        selectionType = ddlSelectionType.options[ddlSelectionType.selectedIndex].value;
    }
    argument = "&SelectedLayer=" + SelectedLayerIndex + "&SelectionType=" + selectionType;
    
    return argument;
 
}
//----------------------------------
// Select by Point
//----------------------------------
function SelectByPoint(divid) 
{   
    map = Maps[divid];

    if (map!=null)
    {        
		map.setTool("", false, "Point", "pointer", -1, "hidden", "");
		    
        // Point doesn't have a default PostBack Behaivor
        map.divObject.onmousedown = SelectByPointClick;
    }    
}
//----------------------------------
// Select by Point Click
//----------------------------------   
function SelectByPointClick(e) 
{
    var SelectedLayerIndex = -1;
    var selectionType = "";
    
    getXY(e);
    
    var box = calcElementPosition(map.containerDivId);
    zleft = mouseX - box.left;
    ztop = mouseY - box.top;

    map.xMin=zleft;
    map.yMin=ztop;
    map.getTopLeftTile();

    var context = map.controlName;
    var argument = 'EventArg=SelectByPoint';   
    var x = "&X=" + zleft;
    var y = "&Y=" + ztop;
 
    argument = argument + x + y + GetSelectionLayerAndType();          
    
    ShowLoading();
    
    eval(selectCallbackFunctionString);
}   
//----------------------------------
// Select by Box - Rectangle
//----------------------------------
function SelectByBox(divid) 
{
    map = Maps[divid];

    if (map!=null)
    {
        var mode = "SelectByBox";
		map.setTool(mode, false, "ClickShape", "pointer", 5, "hidden", "", false, selectCallbackFunctionString);		    
    } 
}
//----------------------------------
// Select by Polygon
//----------------------------------
function SelectByPolygon(divid) 
{    
    map = Maps[divid];

    if (map!=null)
    {
        var mode = "SelectByPolygon";
		map.setTool(mode, false, "ClickShape", "pointer", 2, "hidden", "Polygon - Click to start line. Click again to add vectors. Double-click to add last vector and complete polygon.", false, selectCallbackFunctionString);
    } 
}
//----------------------------------
// Select by Line
//----------------------------------
function SelectByLine(divid) 
{    
    map = Maps[divid];

    if (map!=null)
    {
        var mode = "SelectByLine";
		map.setTool(mode, false, "ClickShape", "pointer", 0, "hidden", "Line - Click to start line. Click again to complete line.", false, selectCallbackFunctionString);
    } 
}
//----------------------------------
// Clear Selection Graphics
//----------------------------------
function ClearSelectionGraphics() 
{

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        //hide loading
        window.setTimeout("HideLoading()", 1000);

        var argument = 'EventArg=ClearSelectionGraphics';
        var context = "ClearSelection"; //map.controlName;
       
        //do post back
        WebForm_DoCallback('__Page',argument,processCallbackResult,context,parent.postBackError,true);            
        
        //display a message
        Ext.MessageBox.alert('Clear Selection','Selected features have been cleared.',null);          

    }
    else
    {
        showLapseAlert();
    }
    
}

//==============================================================================================================================
//                                                  PRINTING TOOL FUNTIONS
//==============================================================================================================================

//----------------------------------
// Print Map
//----------------------------------
function PrintMap()
{

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        //Get Type of Printout
        var printRadio = document.getElementsByName("rbPrintLayout");

        if (printRadio != null)
        {
            printType = getCheckedValue(printRadio);
        }
        
        if(printType != "")
        {
            //show loading graphic
            ShowLoading();
            SandGIS.hideDialog('Print');
            //construct our argument to start printing on the server
            var message = "ControlType=Map&Eventarg=PrintMap&LayoutType=" + printType;
            var context = "PrintMap";
            WebForm_DoCallback('__Page',message,processResults,context,postBackError,true);          
        }

    }
    else
    {
        showLapseAlert();
    }
}

//----------------------------------
// Print Map
//----------------------------------
var refreshAuditorCardResults = false;
function GenerateAuditorCards()
{

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        //show loading graphic
        ShowLoading();
        var message = "Eventarg=PrintAuditorCards";
        var context = map.controlName;
        refreshAuditorCardResults = true;
        //do post back
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);            
    }
    else
    {
        showLapseAlert();
    }
}


// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


//==============================================================================================================================
//                                                  DISPLAY PROPERTY INFORMATION TOOL FUNTIONS
//==============================================================================================================================

function ShowPropertyInformation(propertyID)
{

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        Ext.get("PropertyTabFrame").dom.src="blank.htm?Page=PropertyInformation.aspx?pid=" + propertyID;
        Ext.get("SalesHistoryTabFrame").dom.src="blank.htm?Page=PropertySalesHistory.aspx?pid=" + propertyID;
        Ext.get("PhotosTabFrame").dom.src="blank.htm?Page=PropertyPhotos.aspx?pid=" + propertyID;

        SandGIS.showDialog('DlgPropertyInformationContainer','DlgResultsContainer');
    }
    else
    {
        showLapseAlert();
    }
}

//==============================================================================================================================
//                                                      CURRENT MAP EXTENT
//==============================================================================================================================
function SetCurrentMapExtent(strExtent)
{
    var objHiddenMapExtent = document.getElementById('hiddenMapExtent');
    if (objHiddenMapExtent != null)
    {
        objHiddenMapExtent.value = strExtent;
    }
}

//==============================================================================================================================
//                                                      ZOOMING FUNCTIONS
//==============================================================================================================================

// <summary>
// Starts process of zooming to airport full extent
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function ZoomToFullExtent(){
    if (getSessionLapse() < maximumLapseTime) {
        lastResponseReceivedTime=new Date();

        var message = "ControlType=Map&Eventarg=ZoomToFullExtent";
        var context = map.controlName;
        ShowLoading();
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
    }
    else
    {
        showLapseAlert();
    }
}

//==============================================================================================================================
//                                                  ZOOM TO SCALE TOOL FUNTIONS
//==============================================================================================================================

// <summary>
// Get zoom to scale and validate it
// Call ZoomToScale function
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function GetZoomScale(controlName){

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        if (document.getElementById(controlName)){
             var scale = document.getElementById(controlName).value;
            //check if scale is valid number
            if ((ValidateValue(scale,"required","")) && (ValidateValue(scale,"integer",""))){
                ZoomToScale(scale);       
            }else{
                //hide loading image
                HideLoading();

                alert("The scale value is not valid. Please try again.");
            }
        }
        else
        {
            alert ("Unable to retrieve scale from: " + controlName);    
        }

    }
    else
    {
        showLapseAlert();
    }
}

// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function ZoomToScale(scale){
    var message = "ControlType=Map&Eventarg=ZoomToScale&Scale="+scale;
    var context = map.controlName;
    ShowLoading();
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
}

// <summary>
// Zooms to All selected features
// </summary>
// <history>
// Juliana Castillo. – Woolpert, Inc. (Created) 5/03/2007
// </history>
function ZoomToAllSelectedParcels(selectedParcels){

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        SandGIS.hideDialog('Results');
        var message = "ControlType=Map&Eventarg=ZoomToAllSelectedParcels&selectedOIDs=" + selectedParcels;
        var context = map.controlName;
        ShowLoading();
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        

    }
    else
    {
        showLapseAlert();
    }
}

//==============================================================================================================================
//                                                  PARCEL SEARCH TOOL FUNTIONS
//==============================================================================================================================

// <summary>
// Get zoom to scale and validate it
// Call ZoomToScale function
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function GetParcelSearchValue(controlName, searchType){
    
    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        if (document.getElementById(controlName)){
             var searchValue = document.getElementById(controlName).value;
            
            //check if value is valid
            if (ValidateValue(searchValue,"required","")){
                SearchParcel(searchValue, searchType);
                document.getElementById(controlName).value = "";
            }else{
                //hide loading image
                alert("The search value is not valid. Please try again.");
            }
        }else{
            alert ("Unable to retrieve value from: " + controlName);    
        }

    }
    else
    {
        showLapseAlert();
    }
}

// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function SearchParcel(value, stype){

    var message = "ControlType=Map&Eventarg=SearchParcel&SearchValue="+value+"&SearchType="+stype;
    var context = map.controlName;
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
}


// <summary>
// Get zoom to scale and validate it
// Call ZoomToScale function
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function GetParcelAddressSearchValues(streetNumberControl, streetNameControl){

    if (getSessionLapse() < maximumLapseTime) {
        //reset ESRI session counter 
        lastResponseReceivedTime=new Date();

        if ((document.getElementById(streetNumberControl)) && (document.getElementById(streetNameControl))){
             var st_number = document.getElementById(streetNumberControl).value;
             var st_name = document.getElementById(streetNameControl).value;
            
            //check if value is valid
            if (ValidateValue(st_number,"required","") || (ValidateValue(st_name,"required",""))){
                SearchParcelByAddress(st_number,st_name);
                document.getElementById(streetNumberControl).value = "";
                document.getElementById(streetNameControl).value = "";
            }else{
                //hide loading image
                alert("The search values are not valid. Please try again.");
            }
        }else{
            alert ("Unable to retrieve value from: " + streetNumberControl + " or " + streetNameControl);    
        }
    }
    else
    {
        showLapseAlert();
    }    
}

// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 
// </history>
function SearchParcelByAddress(st_number, st_name){

    var message = "ControlType=Map&Eventarg=SearchParcelByAddress&StreetNumber="+st_number+"&StreetName="+st_name;
    var context = map.controlName;
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
}


//==============================================================================================================================
//                                                  ZOOM TO CITY/TOWNSHIP TOOL FUNTIONS
//==============================================================================================================================
// <summary>
// Starts proces of zooming to City/Township
// </summary>
// <history>
// Juliana C. – Woolpert, Inc. 12/03/2007
// </history>

function ZoomToCityTownship(divid) 
{   
    map = Maps[divid];

    if (map!=null)
    {        
		map.setTool("", false, "Point", "pointer", -1, "hidden", "");
		    
        // Point doesn't have a default PostBack Behaivor
        map.divObject.onmousedown = ZoomToCityTownshipByPointClick;
    }    
}


//----------------------------------
// Zoom by Point Click
//----------------------------------   
function ZoomToCityTownshipByPointClick(e) 
{
    if (getSessionLapse() < maximumLapseTime) {
        lastResponseReceivedTime=new Date();

        getXY(e);
        
        var box = calcElementPosition(map.containerDivId);
        zleft = mouseX - box.left;
        ztop = mouseY - box.top;

        map.xMin=zleft;
        map.yMin=ztop;
        map.getTopLeftTile();

        var x = "&X=" + zleft;
        var y = "&Y=" + ztop;
     
        //Show Loading Image
        ShowLoading();
        
        //construct our argument to start printing on the server
        var message = "ControlType=Map&Eventarg=ZoomToCityTownship" + x + y;
        var context = map.controlName;
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);          
    }
    else
    {
        showLapseAlert();
    }
}   


