function setActiveStyleSheet(title) {
  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;
	 }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

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;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 0);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

/* Stack up window.onload event using this function from Simon Willison - http://www.sitepoint.com/blog-post-view.php?id=171578 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function fsz() {
document.getElementById('fsz').style.display='inline';
document.getElementById('print').style.display='inline';
}

if (navigator.userAgent.indexOf("Gecko")!=-1) {
document.write('<style type="text/css">#navlist li{padding-right:25px;float:none;display:inline;}</style>');
addLoadEvent(function() {
      ppp();
      fsz();
      miniTab.init();
      scroller();
}); }

if (navigator.userAgent.indexOf("IE")!=-1) {
function externalLinks() {
	/*
		http://www.sitepoint.com/article/standards-compliant-world
		New-Window Links in a Standards-Compliant World
		By Kevin Yank @ SitePoint.com, March 4th 2003
	*/
	 if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("href") &&
		   anchor.getAttribute("rel") == "external")
		 anchor.target = "_blank";
	 }
}
addLoadEvent(function() {
      ppp();
      fsz();
      miniTab.init();
      externalLinks();
      scroller();
}); }

if (navigator.userAgent.indexOf("Opera")!=-1) {
addLoadEvent(function() {
      ppp();
      fsz();
      //miniTab.init(); opera wil niet - anderen ook niet?
      scroller();
}); }
