var aktsts=1;

function stsStart()
{
    if (document.location.search != "" && (document.location.search).match (/fs=[0-9]+\.?[0-9]*/i))
	{
	    this.aktsts = ("" + (document.location.search).match (/fs=[0-9]+\.?[0-9]*/i)).replace (/fs=/i, '');
	    
	    if (!isNaN(aktsts))
	    {
	        if(aktsts<1)
	            aktsts=1;
	        if(aktsts>5)
	            aktsts=5;
	    }
	    else
	        aktsts=1;
	    StylesheetAnzeigen();
	}
    else
	    aktsts = 1;
}

function StyleSheetAdd(add) 
{
    if(add==1)
    	aktsts++;
    else
    	aktsts--;
    		
    if(isNaN(aktsts))
        aktsts=1;
        
    if(aktsts<1)
        aktsts=1;
    if(aktsts>5)
        aktsts=5;
    StylesheetAnzeigen();
}

function StylesheetAnzeigen()
{

    title="sts"+aktsts;   
    var i, a, main;
    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;
        }
    }
    addFontSizeToLinks();
}

function getDomainURL (URL)
{
	if (URL.match (/^((http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))).*/))
		return URL.match (/^((http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))).*/)[1];
	else
		return "";
}

function addFontSizeToLinks ()
{
	for (i = 0; i < document.links.length; i++)
	{
		if(document.links[i].href.substring(document.links[i].href.length-1,document.links[i].href.length)!="/")
		{
			if (!(document.links[i].href).match (/^mailto:/)
			    && !(document.links[i].href).match (/^(http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))[\/]+$/)
			    && (document.links[i].href).indexOf (getDomainURL (self.location.href)) != -1)
			{
				
				if ((document.links[i].href).match (/fs=[0-9]+\.?[0-9]{0,2}/i))
					document.links[i].href = (document.links[i].href).replace (/fs=[0-9]+\.?[0-9]{0,2}/i, ("fs=" + aktsts));
				else
					if ((document.links[i].href).indexOf ('?') != -1)
						document.links[i].href = document.links[i].href + "&fs=" + aktsts;
					else
						document.links[i].href = document.links[i].href + "?fs=" + aktsts;
				
				document.links[i].href=document.links[i].href.replace("#?fs=","?fs=");
				document.links[i].href=document.links[i].href.replace("#&fs=","&fs=");
				
			}
		}
	}
}
