function fontsizeup() {
  active = getActiveStyleSheet();
  if(active == 'A-') { 
      setActiveStyleSheet('A+');      
  }
}
function fontsizedown() {
  active = getActiveStyleSheet();
  if(active == 'A+') {
    setActiveStyleSheet('A-');
  }
}
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() {
  return ('A-');
}
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){
    if (document.cookie.length>0){
        c_start=document.cookie.indexOf(name + "=");
        if (c_start!=-1){
    c_start=c_start + name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
window.onload = function(e) { 
  var cookie = readCookie("style");
  if(cookie.startsWith('A')) {
    title = cookie.substring(0,2);
  }else{
    title = getPreferredStyleSheet();
  }
  setActiveStyleSheet(title);
}
window.onunload = function(e) { 
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
String.prototype.startsWith = function(str) {return (this.match("^"+str)==str)}
var cookie = readCookie("style");
if(cookie.startsWith('A')) {
    title = cookie.substring(0,2);
}else{
    title = getPreferredStyleSheet();
}
if (title == 'null') {
  title = getPreferredStyleSheet();
}
setActiveStyleSheet(title);
