﻿// JScript File 

//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);
}   

 function showTaxInfo(objectID) 
        {
            //FireCallBack("ClearPanel","AttributeResults","Clear=Tax");
            
            FireCallBack("Batch","AttributeResults","Expand=0;1;1;1=showTaxInfo=" + objectID); 
            //FireCallBack("FloatingPanel","AttributeResults","Expand=0;1;1;1");
            //FireCallBack("showTaxInfo","AttributeResults","object=" + objectID);
        }

//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)
        {          
            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();
                
                var switchStyle = document.getElementById('divSearchBoth').style;
                var button = document.getElementById('divBoth').style; // both button
                button.display = "";
                switchStyle.display =  "";
                
                if(whichLayer == "divDate")
                {
                    var style3 = document.getElementById('divDateButton').style;
                    style3.display = "block";
                }
                    
                if(whichLayer == "divSpecialDistrict")
                {
                    var style4 = document.getElementById('divTaxButton').style;
                    style4.display = "block";
                }

                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";
                }  
            }

            else if (document.all)
            {
                // this is the way old msie versions work
                var style2 = document.all[whichLayer].style;
                style2.display = style2.display? "":"block";
            }
            else if (document.layers)
            {
                // this is the way nn4 works
                var style2 = document.layers[whichLayer].style;
                style2.display = style2.display? "":"block";
            }
        } 
        
        function toggleLayers(whichLayer, whichLayer1, whichImage, whichImage1, whichButton,whichButton1)
        {       
        // this is the way the standards work   
         //empty control switch style
            if (document.getElementById)
            {
                var switchStyle = document.getElementById('divSearchBoth').style;
                switchStyle.display = switchStyle.display? "" : "block";
                
                var style1 = document.getElementById(whichLayer).style; // date style
                var style2 = document.getElementById(whichLayer1).style; // tax style
                var style3 = document.getElementById(whichButton).style; //date button
                var style4 = document.getElementById(whichButton1).style; // tax button
                var style5 = document.getElementById('divBoth').style; // both button
                
                //if control switch is block swap things to look like this
                if(switchStyle.display == "block")
                {
                    style1.display = "block";
                    style2.display = "block";
                    style3.display = "";
                    style4.display = "";
                    style5.display = "block";
                    document.getElementById('Search_Panel_' + whichImage).src="images/expand1.gif";
                    document.getElementById('Search_Panel_' + whichImage1).src="images/expand1.gif";
                    
                }
                else // block = "" and is hidden and so should the both button 
                {
                    style1.display = "";
                    style2.display = "";
                    style3.display = "block";
                    style4.display = "block";
                    style5.display = "";
                    document.getElementById('Search_Panel_' + whichImage).src="images/expand2.gif";
                    document.getElementById('Search_Panel_' + whichImage1).src="images/expand2.gif";
                } 
            }

            else if (document.all)
            {
                // this is the way old msie versions work
                var style2 = document.all[whichLayer].style;
                style2.display = style2.display? "":"block";
            }
            else if (document.layers)
            {
                // this is the way nn4 works
                var style2 = document.layers[whichLayer].style;
                style2.display = style2.display? "":"block";
            }
            else
            {
                alert("oh no");
                var x = document.getElementById('Search_Panel_' + whichImage).src;
                b = x.toString();
                
                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";
                }
                
                
                style2.display = style2.display? "":"block";
                var x = document.getElementById('Search_Panel_' + whichImage1).src;
                b = x.toString();
                
                var image = b.substring(b.length-11,b.length);

                if(image == "expand1.gif")
                {
                    document.getElementById('Search_Panel_' + whichImage1).src="images/expand2.gif";
                }
                else if(image == "expand2.gif")
                {
                    document.getElementById('Search_Panel_' + whichImage1).src="images/expand1.gif";
                }
             }
        } 
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 = "";
    }
}

// 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);  

