checkStylesheet();




function checkStylesheet()
{
        var textSize = getCookie("text_size");
        var theLink = "";

        if (textSize != "null")
        {
                setStylesheet('Text ' + textSize)
        }

        return true;
}




function cookieExists(cookieName)
{
        if (document.cookie != "")
        {
                var theCookieList = document.cookie.split(";");

                for (i = 0; i < theCookieList.length; i++)
                {
                        var currCookieName = theCookieList[i].split("=")[0];
                        var currCookieValue = theCookieList[i].split("=")[1];

                        if (currCookieName.indexOf(cookieName) != -1)
                        {
                                if (currCookieValue == "null")
                                {
                                        return false;
                                }

                                return true;
                        }
                }
        }
        return false;
}




function getCookie(cookieName)
{
        if (cookieExists(cookieName))
        {
                var theCookieList = document.cookie.split(";");

                for (var i = 0; i < theCookieList.length; i++)
                {
                        if (theCookieList[i].split("=")[0].indexOf(cookieName) != -1)
                        {
                                return theCookieList[i].split("=")[1];
                        }
                }
        }

        return "null";
}




function setCookie(cookieName, cookieValue)
{
        var cookieOptions = "path=/;";

        cookieOptions += "domain=autocentrum-lass.de;";
        cookieOptions += "expires=" + (new Date("December 31, 2020")).toGMTString() + ";";

        document.cookie = cookieName + "=" + cookieValue + ";" + cookieOptions;

        return;
}




function setStylesheet(styleTitle)
{
        var currTag;

        if (document.getElementsByTagName)
        {
                for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
                {
                        if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
                        {
                                currTag.disabled = true;

                                if(currTag.getAttribute("title") == styleTitle)
                                {
                                        currTag.disabled = false;
                                }
                        }
                }
        }
        else
        {
                alert("Mit diesem Browser ist es leider nicht möglich die Schriftgröße zu ändern.");
        }
}
