﻿// JScript File 

//fires a callback to the server initiating server processing or whatever for AJAX
function FireCallBack(ServerFunction,ServerVars)
{
    var message = "ControlID=Map1&ControlType=Map&EventArg=" + ServerFunction + "&Map1_mode=attributeResults&" + 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, doWhat)
{          
    if (document.getElementById)// this is the way the standards work
    {
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";

        if(whichLayer == "divAddress")
            document.getElementById("Search_Panel_cityZipList").value = "";

        if(doWhat > 0)
        {   
            document.getElementById("Search_Panel_TextBox3").value = "";
            document.getElementById("Search_Panel_cityZipList").value = "";
        }
    }
    else
        alert("Browser Incompatibility, please email SGourley@Utah.gov with browser version");
}

function viewItem(objectid)
{
    FireCallBack("Zoom","AttributeResults","=viewitem;" + objectid);
}

function hideLoading()
{
    var style2 = document.getElementById('loading').style;
    style2.display = "";
}

function showLoading()
{
    var style2 = document.getElementById('loading').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 = "";
    }
}

//test popups
 var test = window.open('','','width=1,height=1,left=-10,top=-10,scrollbars=no');
 if(test)
 {
    var popUpsBlocked = false
    test.close()
 }
 else
    var popUpsBlocked = true

 if(popUpsBlocked)
  alert('We have detected that you are using popup blocking software.\nTo use some features of this site, such as printable maps and informational tables,\n you must enable popups for http://mapserv.utah.gov or temporarily turn off popup blocking software.');

// 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);  

//added 11/2/07
function removeEnter()
{
 if (window.event.keyCode == 13)
{
    event.returnValue=false;
    event.cancel = true;
}
}