﻿<!--
    /*
        =====================
        AJAX set css function
        =====================
        if javascript disabled:
        Degrades to simple jsp set session (see above) via call to ?altcss=requireCssTitle
        else:
        uses an ajax call to set jsp session (thus avoiding javascript cookies)
        flips the currently active stylesheet (because the jsp session isnt re-requested as the page isnt reloaded)
        and sets the textSize buttons class accordingly.
    */
    function setActiveStyleSheet(title)
    {
        //This function is called by the ajaxSetCss function
        var i, a, main, j, s;
        
        //first set all the textSize buttons to off:
        for(j=0; (s = document.getElementById("setTextSize").getElementsByTagName("a")[j]); j++) {s.className="";}
        
        //set the active stylesheet to match the passed title:
        for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
        {
            if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
            {
                a.disabled = true;
                if(a.getAttribute("title") == title)
                {
                    a.disabled = false;
                    document.getElementById(title).className="on";
                }
            }
        }
    }
    
    function ajaxSetCss(altcss)
    {
        var xmlHttp, sessionSettingUrl;
        try
        {
            // Firefox, Opera 8.0+, Safari
            xmlHttp=new XMLHttpRequest();
        }
        catch (e)
        {
            // Internet Explorer
            try
            {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
                try
                {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e)
                {
                    return true; //failed! return true to continue with href request
                }
            }
        }
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                setActiveStyleSheet(altcss);
            }
        }
        sessionSettingUrl="/Default.aspx?altcss="+altcss+"&rn="+Math.random();
        xmlHttp.open("GET",sessionSettingUrl,true);
        xmlHttp.send(null);
        return false; //success! return false to stop href request
    }
-->