﻿
// Javascript file for Web Mapping Application
var m_measureToolbarId = "";
var reloadTimer = "";
var win;
var noPIDwin;


// handler for window resize
function AdjustMapSizeHandler(e) {
    window.clearTimeout(reloadTimer);
	reloadTimer = window.setTimeout("IndyPropertyViewer.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
        IndyPropertyViewer.showDialog('DlgGenericContainer',parentControl,dlgWidth,dlgHeight);
     }   
}
//-----------------------------------------
// Load a page in a new window
//-----------------------------------------
function openNewWindow(url,dimensions)
{
    if (url != "")
    {     
        if (dimensions) dimensions = ","+dimensions;        
        
        var newWin = window.open(url,"Identify","toolbar=no,menubar=yes, resizable=1"+dimensions);
        
        newWin.focus();                  
    }
}

////-----------------------------------------
////Opens persistant window when a parcel is selected with the Identify Tool
////-----------------------------------------
//function openSameWindow(url, parcelFound)
//{

//    
//    if(url != "")
//    {
//   
//      if(parcelFound == "True")
//      {
//            //Need to check for NoResults Dialog, not window <-- NEEDS IMPLEMENTED
////            if(noPIDwin != null)
////            {
//              IndyPropertyViewer.hideDialog("NotFound");
////            }
//            var features = "menubar=yes, toolbar=no, titlebar=no, resizable=yes,scrollbars=yes, height=640, width=865, alwaysRaised=yes";  
//            win = window.open(url, "SameParcelWindow", features);
//            win.focus();
//      } 
//      else
//      //Need to open new EXT dialog, not new window
//      {
//            if(win != null)
//            {
//            win.close();
//            }
//              IndyPropertyViewer.showDialog('DlgNotFoundContainer', 'Toolbar1MapIdentify');
////            var notFoundfeatures = "menubar=no, resizable=yes,scrollbars=no, height=85, width=550, left=425, top=375";  
////            noPIDwin = window.open("NoParcel.aspx", "SameNoParcelWindow", notFoundfeatures);
////            noPIDwin.focus();
//      }       
//   }
//}



//-----------------------------------------
// 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 map = document.getElementById("mapDiv");
//        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;
//      }       
//       //-----------------------------------------------------
//      //move the Identify Result's starting position 
//      //-----------------------------------------------------
//      var results = document.getElementById("Identify_Panel");
//      if (results!=null)
//      {
//        results.style.position = "absolute";
//        moveLayer(results.id, box.left+200, box.top+26);
//        Ext.get("Identify_Panel").dom.style.zIndex = 10000;
//      }      
//      //=================================
//      // Resize the Map
//      //=================================
//      firstLoad = false;
//      IndyPropertyViewer.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()F
//-----------------------------------------------------------------
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) {
    var elem = document.getElementById(elemName);
    if (elem!=null) { 
            toggleFloatingPanelVisibility(elemName);            
    } else 
        alert(elemName + " is not available");     
}
//-----------------------------------------------------------------
// <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) 2/13/2007
// </history>
//-----------------------------------------------------------------
function SetMapSize(mapWidth, mapHeight) {
    // Retrieve the Map object and container
    pMapObject = document.getElementById("mapDiv");
    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 ((myMap.width!=mWidth) || (myMap.height!=mHeight))
    {
        //ShowLoading();
        myMap.resize(mWidth, mHeight, true);
    }
}
     // <summary>
        // Setup Loading Image. Function is called in the page onLoad event
        // </summary>
        // <history>
        // Juliana Castillo – Woolpert, Inc. (Created) 2/15/2007
        // </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) 2/15/2007
        // </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, location=yes");
    }
}
//-----------------------------------------------------------------
// <summary>
// Processes the callback results
// </summary>
// <history>
// Aralola Akinmade (Created) 07/25/2007
// </history>
//-----------------------------------------------------------------
function processResults(response, context)
{
   //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);
	
}
//-----------------------------------------------------------------
// <summary>
// Further processes any additional information returned with the response
// </summary>
// <history>
// Aralola Akinmade (Created) 07/25/2007
// </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;
                
                //another action to update the map
                case "MapUpdate":
                     processResults(optionsArray[1], map.controlName);
                break;
                
                //another action to update results/information
                case "ResultsUpdate":
                    //UpdateResultsSummary(optionsArray[1]);
                break ;
                
                default:
                break;   
            } 
       }     
      return responseString;
            
}
//-----------------------------------------------------------------tw
// <summary>
// Processes the callback errors
// </summary>
// <history>
// Aralola Akinmade (Created) 07/25/2007
// </history>
//-----------------------------------------------------------------
function postBackError(response, context)
{

}
//==============================================================================================================================
//                                                      MAP EXPORT FUNCTIONS
//==============================================================================================================================
// <summary>
// Starts proces of exporting map image
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 04/03/2007
// </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) 04/03/2007
// </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) 04/03/2007
// </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 - 07/30/2007
// </history>
//-----------------------------------------------------------------
function showResults()
{
    
    //hide loading
    window.setTimeout("HideLoading()", 4000);
    
    //Ext.get("ResultsFrame").dom.src="blank.htm?Page=Results.aspx";
       Ext.get("ResultsFrame").dom.src="blank.htm?Page=Results.aspx"; 
        
    //show the results        
    IndyPropertyViewer.showDialog('DlgResultsContainer', 'Toolbar1ShowResults');
}


function showSearchByIDLoad()
{
var SearchLoading = findElement("DivIDSearchLoading", "div");
SearchLoading.style.visibility = "visible";
}




function showSearchByAddressLoad()
{
var SearchLoadimg = findElement("DivAddressSearchLoading","div");
SearchLoadimg.style.visibility = "visible";
}


function hideSearchByAddressLoad()
{
var SearchLoading = findElement("DivAddressSearchLoading", "div");
SearchLoading.style.visibility = "hidden";
}

function hideSearchByIDLoad()
{
var HideLoading = findElement("DivIDSearchLoading", "div");
HideLoading.style.visibility = "hidden";
}


function hideSearchByIDDialog()
{
  IndyPropertyViewer.hideDialog("SearchParcelByID");
}

function hideSearchByAddressDialog()
{
//Hide Select Candidates element
var candidatesElement = dojo.byId("candidatesRow");
candidatesElement.style.visibility = "hidden";
var instructions = dojo.byId("searchByAddressInstruct");
instructions.innerHTML = 'Enter the Street Number and Street Name to search. <br /><br />';
IndyPropertyViewer.hideDialog("SearchParcelByAddress");
}

//function hideStartupHelpDialog()
//{
//    IndyPropertyViewer.hideDialog("StartupHelp");
//}

/*
===============================================================
Returns the form element that contains the specified string
in its ID and tag
===============================================================
*/
function findElement(str, tagName)
{
	var allElements = document.getElementsByTagName(tagName);
	var obj;
	for (var i=0;i<allElements.length;i++)
	{
		if (allElements[i].id.indexOf(str)>-1)
		{
			obj = allElements[i];
			break;
		}		
	}
	return obj;
}

//-----------------------------------------------------------------
// <summary>
// Zooms to the feature
// </summary>
// <history>
// Aralola Akinmade - Woolpert, Inc - 07/30/2007
// </history>
//-----------------------------------------------------------------
function zoomToFeature(fid, layerName)
{   
    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);            
    
}

//// <summary>
//// Assesses which zoom function to be used
//// </summary>
//// <history>
//// Joel Overpeck. – Woolpert, Inc., 3-18-08
//// </history>
function EvaluateZoomType(Layer, OID, Address, X, Y){

 var map = parent.map
   //map = parent.Maps[mapID];

parent.IndyPropertyViewer.hideDialog("Results");
var message = "ControlType=Map&Eventarg=EvaluateZoomType&LayerName=" + Layer + "&ObjectID=" + OID + "&Address=" + Address + "&XCoord=" + X +"&YCoord=" + Y;
var context = map.controlName;
parent.ShowLoading();
parent.WebForm_DoCallback('__Page',message,parent.processCallbackResult,context,parent.postBackError,true);
}

//-----------------------------------------------------------------
// <summary>
// Shows the EXT-JS progress bar
// </summary>
// <history>
// Aralola Akinmade - Woolpert, Inc - 07/30/2007
// </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);
       }
}


// <summary>
//    Opens the Parcel Database window with a passed in Parcel ID
// </summary>
// <history>
//Joel Overpeck - Woolpert, Inc. 4-16-08
// </history>
function openParcelDatabaseSite(ParcelID, parcelFound)
{
    var ParcelDB_URL = "http://cms.indygov.org/MyAssessedValue/Result.aspx?Parcel=" + ParcelID;
    openSameWindow(ParcelDB_URL, parcelFound);
}



//==============================================================================================================================
//                                                  SELECTION TOOL FUNTIONS
//==============================================================================================================================
// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Joe LaCombe - Woolpert, Inc 3/1/2007
// Juliana C. – Woolpert, Inc. 3/26/2007
// 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() 
{

    //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);          
}




//==============================================================================================================================
//                                                  PRINTING TOOL FUNTIONS
//==============================================================================================================================

//----------------------------------
// Print Map
//----------------------------------
function PrintMap()
{
    //TODO: Get Type of Printout
    var printRadio = document.getElementsByName("rbPrintLayout");

    if (printRadio != null)
    {
        printType = getCheckedValue(printRadio);
    }
    
    if(printType != "")
    {
        IndyPropertyViewer.hideDialog('Print');
    
        //show loading graphic
        ShowLoading();

        //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);          
    }
}

// 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)
{

    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;

    IndyPropertyViewer.showDialog('DlgPropertyInformationContainer','DlgResultsContainer');
}

//==============================================================================================================================
//                                                      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) 3/23/2007
// </history>
function ZoomToFullExtent(){
    var message = "ControlType=Map&Eventarg=ZoomToFullExtent";
    var context = map.controlName;
    ShowLoading();
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
}

//==============================================================================================================================
//                                                  ZOOM TO SCALE TOOL FUNTIONS
//==============================================================================================================================

// <summary>
// Get zoom to scale and validate it
// Call ZoomToScale function
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 3/23/2007
// </history>
function GetZoomScale(controlName){
    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);    
    }
}

// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 3/23/2007
// </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>
// Joel Overpeck. – Woolpert, Inc., 3-18-08
// </history>
function ZoomToAllSelectedParcels(selectedParcels){
    IndyPropertyViewer.hideDialog('Results');
     var message = "ControlType=Map&Eventarg=ZoomToAllSelectedParcels&selectedOIDs=" + selectedParcels;
    var context = map.controlName; 
   ShowLoading();
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);        
}

//==============================================================================================================================
//                                                  PARCEL SEARCH TOOL FUNTIONS
//==============================================================================================================================

// <summary>
// Get zoom to scale and validate it
// Call ZoomToScale function
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 3/23/2007
// </history>
function GetParcelSearchValue(controlName, searchType){
    
    if (document.getElementById(controlName)){
         var searchValue = document.getElementById(controlName).value;
        
        //check if value is valid
        if (ValidateValue(searchValue,"required","")){
        //SHOW LOAD GRAPHIC            
            SearchParcel(searchValue, searchType);
            IndyPropertyViewer.hideDialog('SearchParcelByID');            
            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);    
    }
}


// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 3/23/2007
// </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) 3/23/2007
// </history>
function GetParcelAddressSearchValues(streetNumberControl, streetNameControl){
    
    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.");
            hideSearchByAddressLoad();
        }
    }else{
        alert ("Unable to retrieve value from: " + streetNumberControl + " or " + streetNameControl);    
        hideSearchByAddressLoad();
    }
}

// <summary>
// Starts proces of zooming to custom scale
// </summary>
// <history>
// Dominik M. – Woolpert, Inc. (Created) 3/23/2007
// </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) 
{
    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);          
}   

//==============================================================================================================================
//                                                  RADIO BUTTON EVENT    
//==============================================================================================================================
// <summary>
// Radio Button Click Event
// </summary>
// <history>
// Joel Overpeck - 02-14-08
// </history>
//----------------------------------
// Radio Button Event Click
//----------------------------------   

   function GetMapName(MapName)
  {
 // var MapName = map;
 // alert(MapName);
   var message = "ControlType=Map&Eventarg=ChangeMapResource&ResourceName=" + MapName;
   var context = map.controlName;

   WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);          
  }
  
  
//  function PrintMap()
//{
//    //TODO: Get Type of Printout
//    var printRadio = document.getElementsByName("rbPrintLayout");

//    if (printRadio != null)
//    {
//        printType = getCheckedValue(printRadio);
//    }
//    
//    if(printType != "")
//    {
//        IndyPropertyViewer.hideDialog('Print');
//    
//        //show loading graphic
//        ShowLoading();

//        //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);          
//    }
//}





