function Stylemanager() {
  this.cookie = cookieManager.getCookie("style");
  this.setActiveStyleSheet(this.cookie ? this.cookie : "");
  this.phpText = this.showStyleSelector();
}

Stylemanager.prototype.showStyleSelector = function() {
  var i, a, main;
  var thtml = "\n<ul id=\"styleswitcher\">";
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 &&
    a.getAttribute("title")){
      thtml += "\n  <li><a href=\"#\" " +
               "onclick=\"styleManager.setActiveStyleSheet('" +
               a.getAttribute("title") + "')\">";
      thtml += a.getAttribute("title");
      thtml += "</a></li> ";
    }
  }
  thtml += "\n  <li><a href=\"#\" onclick=\"styleManager.setActiveStyleSheet('');" +
           "\">Standard</a></li>\n</ul>";
  return thtml;
}

Stylemanager.prototype.setActiveStyleSheet = function(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1) {
      a.disabled = true;
if(title == "" && a.getAttribute("title") == null) {
  a.disabled = false;
  cookieManager.setCookie("style", "", 365);
}
      if(a.getAttribute("title") == title) {
  a.disabled = false;
  cookieManager.setCookie("style", title, 365);
      }
    }
  }
}

Stylemanager.prototype.getActiveStyleSheet = function() {
  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;
}

/*Stylemanager.prototype.getPreferredStyleSheet = function() {
  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;
}*/


var styleManager = new Stylemanager();