function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("styles") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
		a.disabled = false;
		cookieManager.setCookie("style", title, 365);
      }
    }
  }
}

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;
}

var cookie = cookieManager.getCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


/* page wide function */
function printPage(){
  (window.print) ? window.print(): alert ("Please use Control + P for printing");
}

var bShow;
function changeView (visibility,color) {
  document.getElementById("change-view-tool").style.visibility=visibility;
  document.getElementById("change-view-link").style.background=color;
  if (bShow == 1) {
    document.getElementById("change-view-tool").style.visibility="hidden";
    document.getElementById("change-view-link").style.background="transparent";
    bShow = 0;
    return;
  }
  bShow = 1;
}