﻿// JScript File 
function mapTips() 
{
javascript:showLoading();
    //document.getElementById('attributes_status_div').innerHTML = "&nbsp;<img alt='Working Indicator' src='images/callbackActivityIndicator.gif' align='middle' />&nbsp;Zooming to Selected Feature...";
        FireCallBack("DefinitionQuery","AttributeResults","DefinitionQuery=toggle");
}

function redrawMap() 
{
javascript:showLoading();
    FireCallBack("RedrawMap","AttributeResults","Redraw=map");
}

function showDistricts() 
{
javascript:showLoading();
    FireCallBack("defExpression","AttributeResults","DefinitionExpress=off");
}

function showSiteDetails(objectID)
{
    //FireCallBack("ClearPanel","AttributeResults","Clear=Parcel");
    javascript:showLoading2();
    FireCallBack("Batch","AttributeResults","Expand=0;1;1=showSiteDetails=showSiteDetails;" + objectID); 
}

function GenerateExcel()
    {
         var style1 = document.getElementById('excel').style;
            style1.display = style1.display? "":"block";
            
         var style2 = document.getElementById('export').style;
            style2.display = style2.display? "":"block";
    }


//fires a callback to the server initiating server processing or whatever for AJAX
function FireCallBack(ServerFunction,ServerMode,ServerVars)
{
    var message = "ControlID=Map1&ControlType=Map&EventArg=" + ServerFunction + "=" + ServerVars; 
    var context = map.controlName;
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);
}        

//toggles css div's display property from none to block.  whichlayer is the div and dowhat is 0 unless you want to clear values from text boxes like with geocode address by city.
function toggleLayer(whichLayer, whichImage, doWhat)
   {          
        if (document.getElementById)
        {
            // this is the way the standards work
            var style2 = document.getElementById(whichLayer).style;
            style2.display = style2.display? "":"block";
            var x = document.getElementById('Search_Panel_' + whichImage).src;
            b = x.toString();

            if(whichLayer == "divAddress")
                document.getElementById("Search_Panel_cityZipList").value = "";

            var image = b.substring(b.length-11,b.length);

            if(image == "expand1.gif")
            {
                document.getElementById('Search_Panel_' + whichImage).src="images/expand2.gif";
            }
            else if(image == "expand2.gif")
            {
                document.getElementById('Search_Panel_' + whichImage).src="images/expand1.gif";
            }       

            if(doWhat > 0)
            {   
                document.getElementById("Search_Panel_zip").value = "";
                document.getElementById("Search_Panel_cityZipList").value = "";
            }
        }
    else
        alert("Browser Incompatibility, please email SGourley@Utah.gov with browser version");
}

function hideLoading()
{
    var style2 = document.getElementById('loading').style;
    style2.display = "";
}

function showLoading()
{
    var style2 = document.getElementById('loading').style;
    style2.display = "block";
}

function hideLoading2()
{
    var style2 = document.getElementById('loading2').style;
    style2.display = "";
}

function showLoading2()
{
    var style2 = document.getElementById('loading2').style;
    style2.display = "block";
}

function showBusyIndicator(sender) 
{
    showLayer("BusyIndicator");

    if (sender!=null) 
    {
        window.status = "Pending Tiles: " + sender.pendingTiles.length;
    } 
}

function showPendingTiles(sender) 
{
    if (sender!=null) 
    {
         window.status = "Pending Tiles: " + sender.pendingTiles.length;
    } 
}

function hideBusyIndicator(sender) 
{
    hideLayer("BusyIndicator");
    if (sender!=null) 
    {
        window.status = "";
    }
}

function changeRadio()
   {
        var elem = document.getElementById("Search_Panel_RadioButtonList1_0").checked = 1;
        var elem = document.getElementById("Search_Panel_RadioButtonList1_1").checked = 0;
   }
   
   function changeRadio2()
   {
        var elem = document.getElementById("Search_Panel_RadioButtonList1_0").checked = 0;
        var elem = document.getElementById("Search_Panel_RadioButtonList1_1").checked = 1;
   }
// add busy indicator functions to the map
map = Maps["Map1"];
map.pendingTiles.add_onRequestsPending(showBusyIndicator);
map.pendingTiles.add_onRequestsRemove(showPendingTiles);
map.pendingTiles.add_onRequestsCompleted(hideBusyIndicator);  

