function StyleManager() {
  this.fontSize = "";

}
// Changes stylesheet to affect the font size. Stores the change in a cookie. 
StyleManager.prototype.setActiveStyleSheet = function(title) {
  var i, a, main;
  this.setStyleCookie(title);
  this.fontSize = title;
  
  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;
    }
  }
  SI.ClearChildren.clear(); // reset the page if the size has changed. 
  return false;
}

StyleManager.prototype.setStyleCookie = function(title) {
  var styleCookie = new Cookie("stylePrefs");
  styleCookie.fontSize = title;
  styleCookie.store(1095);
}


StyleManager.prototype.setStyles = function() {
  var styleCookie = new Cookie("stylePrefs");
  
  if (styleCookie.fontSize) {
    this.setActiveStyleSheet(styleCookie.fontSize);
  }
}


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();

