﻿// JScript File

		function getElement(whichLayer)
		{
		    var div;
            if (document.getElementById)
            {
                // this is the way the standards work
                div = document.getElementById(whichLayer);
            }
            else if (document.all)
            {
                // this is the way old msie versions work
                div = document.all[whichLayer];
            }
            else if (document.layers)
            {
                // this is the way nn4 works
                div = document.layers[whichLayer];
            }
            
            return div;
        }
        
        function toggleLayer(whichLayer)
        {
            var div = getElement(whichLayer);
            if (div.style.display == 'none' || div.style.display == '')
                div.style.display = 'block'
            else
                div.style.display = 'none';
        }
        
        function showDiv(whichLayer)
        {
            var div = getElement(whichLayer);
            div.style.display = 'block';
        }
        
        function showDiv(whichLayer, anchor, topshift, leftshift) {
            div = getElement(whichLayer);
            div.style.display = 'block';
            div.style.position = 'absolute';

            if (anchor) {
                arrPos = findPos(anchor);

                div.style.left = (arrPos[0] + leftshift) + "px";
                div.style.top = (arrPos[1] + topshift) + "px";
            }
        }
       
        function findPos(obj) {
            var curleft = curtop = 0;
            if (obj.offsetParent) {
                do {
                    curleft += obj.offsetLeft;
                    curtop += obj.offsetTop;
                } while (obj = obj.offsetParent);
            }
            return [curleft, curtop];
        }
       
        function hideDiv(whichLayer)
        {     
            var div = getElement(whichLayer);
            div.style.display = 'none';
        }

        function trim(str, chars) 
        {
            return ltrim(rtrim(str, chars), chars);
        }

        function ltrim(str, chars) 
        {
            chars = chars || "\\s";
            return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
        }

        function rtrim(str, chars) {
            chars = chars || "\\s";
            return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
        }
        
        function geturl(url) {
            var u = url.toLowerCase().replace("/'", "%27");
            if (u.substring(7, 0) == "http://")
                return u;
            else if (u.substring(8, 0) == "https://")
                return u;
            else
                return "http://" + u;
        }
        
        function TrackWPLead(sessionid, wpid) {
            if(document.images){
                (new Image()).src='/TrackWhitePaperLead.aspx?sid='+sessionid+'&wpid='+wpid;
            }
            return true;
        }