﻿// JScript File

    function ShowTopPanel(strNewID,ViewID)
    {
        if (document.getElementById('pnlTopID').value==strNewID)
        {
            document.getElementById('pnlTop').innerHTML = '';
            document.getElementById('pnlTop').style.display = 'none';
            document.getElementById('pnlTopID').value='';
        }
        else
        {
            var req = GetRequestObj('ShowPanel');
            req.onreadystatechange = pnlTopComplete;
            strSoap = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
            strSoap = strSoap + "<soap:Body>"
            strSoap = strSoap + "<ShowPanel xmlns='http://tempuri.org/'><NewID>" + strNewID + "</NewID><PnlView>" + ViewID + "</PnlView></ShowPanel>"
            strSoap = strSoap + "<ShowPanelResponse xmlns='http://tempuri.org/'><ShowPanelResult>string</ShowPanelResult></ShowPanelResponse>"
            strSoap = strSoap + "</soap:Body></soap:Envelope>"
            req.send(strSoap);
            document.getElementById('pnlTopID').value = strNewID;
        }
    }
    function pnlTopComplete()
    {
        var strHTML;
        strHTML = ProcessResponse(req);
        if (strHTML.length > 0)
        {
            document.getElementById('pnlTop').innerHTML = strHTML;
            document.getElementById('pnlTop').style.display = 'block';
        }
    }

    function ShowMidPanel(strNewID,ViewID)
    {
        document.getElementById('pnlMid2').innerHTML = '';
        document.getElementById('pnlMid2').style.display = 'none';
        document.getElementById('pnlMidID2').value='';
        if (document.getElementById('pnlMidID').value==strNewID)
        {
            document.getElementById('pnlMid').innerHTML = '';
            document.getElementById('pnlMid').style.display = 'none';
            document.getElementById('pnlMidID').value='';
        }
        else
        {
            var req = GetRequestObj('ShowPanel');
            req.onreadystatechange = pnlMidComplete;
            strSoap = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
            strSoap = strSoap + "<soap:Body>"
            strSoap = strSoap + "<ShowPanel xmlns='http://tempuri.org/'><NewID>" + strNewID + "</NewID><PnlView>" + ViewID + "</PnlView></ShowPanel>"
            //strSoap = strSoap + "<ShowPanelResponse xmlns='http://tempuri.org/'><ShowPanelResult>string</ShowPanelResult></ShowPanelResponse>"
            strSoap = strSoap + "</soap:Body></soap:Envelope>"
            req.send(strSoap);
            document.getElementById('pnlMidID').value = strNewID;
        }
    }
    function pnlMidComplete()
    {
        var strHTML;
        strHTML = ProcessResponse(req);
        if (strHTML.length > 0)
        {
            document.getElementById('pnlMid').innerHTML = strHTML;
            document.getElementById('pnlMid').style.display = 'block';
        }
    }
    function ProcessResponse(req)
    {
        var strHTML = '';
        if (req.readyState == 4) 
        {
            if (req.status == 200) 
            {
                if (window.ActiveXObject)
                {
                    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                    xmlDoc.loadXML(req.responseText);
                    strHTML = xmlDoc.text;
                }
                else
                {
                    var x = 0;
                    while(x < req.responseXML.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes.length)
                    {
                        strHTML += req.responseXML.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[x].nodeValue;
                        x++;
                    }
                } 
            }
            else 
            {
                alert("An error occured processing your request:\n" + req.statusText);
            }
        }
        return strHTML
    }            
    function ShowMid2Panel(strNewID,ViewID)
    {
        if (document.getElementById('pnlMidID2').value==strNewID)
        {
            document.getElementById('pnlMid2').innerHTML = '';
            document.getElementById('pnlMid2').style.display = 'none';
            document.getElementById('pnlMidID2').value='';
        }
        else
        {
            var req = GetRequestObj('ShowPanel');
            var strSoap = ''
            req.onreadystatechange = pnlMid2Complete;
            strSoap = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
            strSoap = strSoap + "<soap:Body>"
            strSoap = strSoap + "<ShowPanel xmlns='http://tempuri.org/'><NewID>" + strNewID + "</NewID><PnlView>" + ViewID + "</PnlView></ShowPanel>"
            //strSoap = strSoap + "<ShowPanelResponse xmlns='http://tempuri.org/'><ShowPanelResult>string</ShowPanelResult></ShowPanelResponse>"
            strSoap = strSoap + "</soap:Body></soap:Envelope>"
            req.send(strSoap);
            document.getElementById('pnlMidID2').value = strNewID;
        }
    }
    function pnlMid2Complete()
    {
        var strHTML;
        strHTML = ProcessResponse(req);
        if (strHTML.length > 0)
        {
            document.getElementById('pnlMid2').innerHTML = strHTML;
            document.getElementById('pnlMid2').style.display = 'block';
        }
    }
        
    function GetRequestObj(oMethod)
    {
        // branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) 
        {
            req = new XMLHttpRequest();
        // branch for IE/Windows ActiveX version
        }
        else if (window.ActiveXObject) 
        {
            req = new ActiveXObject("MSXML2.XMLHTTP");
        }
        url= 'http://www.polkcountyiowa.gov/AjaxService/PageService.asmx';
        req.open("POST", url, true);
        req.setRequestHeader("Content-Type", "text/xml");
        req.setRequestHeader("SOAPAction", "http://tempuri.org/" + oMethod);
        return req;              
    }
        
    function expand()
    {
        var osrc = '';
        if (document.getElementById('pnlTop').style.display == 'block')
        {
            document.getElementById('pnlTop').innerHTML = '';
            document.getElementById('pnlTop').style.display = 'none';
            document.getElementById('pnlTopID').value='';
            osrc = 'SharedImages/ArrowD.gif';
        }
        else
        {
            var links = document.getElementById('topLinks').getElementsByTagName('a');
            links[links.length-1].click();
            osrc = 'SharedImages/ArrowU.gif';
        }
        var img = document.getElementById('topArrow').getElementsByTagName('img');
        img[0].src = osrc;
    }

    function NodeClick(oNode)
    {
        var UL = oNode.parentNode.getElementsByTagName('ul');
        var oStyle = UL[0].style;
        if(oStyle.display == 'none' || oStyle.display == '')
        {
            oStyle.display = 'block';
            oNode.parentNode.className = 'NodeOpen';
        }      
        else
        {
            oStyle.display = 'none';
            oNode.parentNode.className = 'NodeClosed';
        }  
    }
    var NewsID = '';
    
    function showArticle(oID,bShowSummary,SummaryLength)
    {
        NewsID = oID;
        var req = GetRequestObj('ShowNewsArticle');
        req.onreadystatechange = showArticleComplete;
        strSoap = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
        strSoap = strSoap + "<soap:Body>"
        strSoap = strSoap + "<ShowNewsArticle xmlns='http://tempuri.org/'><NewID>" + oID + "</NewID><intShowSummary>" + bShowSummary + "</intShowSummary><intSummaryLength>" + SummaryLength + "</intSummaryLength></ShowNewsArticle>"
        strSoap = strSoap + "<ShowNewsArticleResponse xmlns='http://tempuri.org/'><ShowNewsArticleResult>string</ShowNewsArticleResult></ShowNewsArticleResponse>"
        strSoap = strSoap + "</soap:Body></soap:Envelope>"
        req.send(strSoap);
    }
    function showArticleComplete()
    {
        var strHTML;
        var oDiv;
        strHTML = ProcessResponse(req);
        if (strHTML.length > 0)
        {
            if (strHTML == '_')
            {
                strHTML = ''
            }
            oDiv = document.getElementById(NewsID);
            oDiv.innerHTML = strHTML;
        }
    }

    function showArticleSummary(oID,bShowSummary,SummaryLength)
    {
        NewsID = oID;
        var req = GetRequestObj('ShowNewsSummary');
        req.onreadystatechange = showArticleComplete;
        strSoap = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
        strSoap = strSoap + "<soap:Body>"
        strSoap = strSoap + "<ShowNewsSummary xmlns='http://tempuri.org/'><NewID>" + oID + "</NewID><intShowSummary>" + bShowSummary + "</intShowSummary><intSummaryLength>" + SummaryLength + "</intSummaryLength></ShowNewsSummary>"
        strSoap = strSoap + "<ShowNewsSummaryResponse xmlns='http://tempuri.org/'><ShowNewsSummaryResult>string</ShowNewsSummaryResult></ShowNewsSummaryResponse>"
        strSoap = strSoap + "</soap:Body></soap:Envelope>"
        req.send(strSoap);
    }

