// what is switchable via the style switcher ?
// bigFonts
// normFonts


var Stil = "Standard";
var Keks = "Layout";
var Tage = 30;

var fontSizeStyle;
var colorStyle;
var fontSizeStyleCookie = "fontSizeLayout";

function setActiveStyleSheet(title) {

	var i;
	var a;
	var main;

	if (title != Stil) {

		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.getAttribute("title") == "normalFonts")
					a.disabled = false;
			}
			
		}

		Stil = title;

		setCookie(Keks, Stil, Tage);
		if (title.indexOf("bigFonts") > -1)
			setCookie(fontSizeStyleCookie, "bigFonts", Tage);
		if (title.indexOf("normalFonts") > -1)
			setCookie(fontSizeStyleCookie, "normalFonts", Tage);
	}
	
}

function loadStyle() {
  var c = getCookie(Keks);
  
  if (c && c != Stil) {
    setActiveStyleSheet(c);
    Stil = c;
  }
}

window.onload = loadStyle;


// Cookie-Funktionen

function setCookie(name, value, expdays) {   // gültig expdays Tage
  var now = new Date();
  var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
  document.cookie = name + "=" + escape(value) + ";" +
                    "expires=" + exp.toGMTString() + ";" +
                    "path=/";
}

function getCookie(name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
      start += cname.length;
      var stop = dc.indexOf(";", start);
      if (stop == -1) stop = dc.length;
      return unescape(dc.substring(start,stop));
    }
  }
  return null;
}

function delCookie(name) {   // expires ist abgelaufen
  var now = new Date();
  var exp = new Date(now.getTime() - 1);
  document.cookie = name + "=;" +
                    "expires=" + exp.toGMTString() + ";" + 
                    "path=/";
}

function delStyleCookie() {
  delCookie(Keks);
}


