var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
if(cookie == null) title = "normaal";
setActiveStyleSheet(title);

function setActiveStyleSheet(title) {
  var i, a;
  var aFont = document.getElementById(title);
  var l = document.getElementById("leesbaarheid");
  var n = document.getElementById("normaal");
  var p = document.getElementById("print");
    
  if(aFont != null) {
	
	  l.className = l.className.replace(" active","");
	  n.className = n.className.replace(" active","");
	  p.className = p.className.replace(" active","");
	  aFont.className+=" active";
  }
  
  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;
      if(a.getAttribute("title") == title) a.media = "print, screen";
      if(a.getAttribute("title") == title) a.rel = "stylesheet";
    }
  }
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
