
// set the active stylesheet (for alternative print mode)
function setActiveStyleSheet(title) {
   var i, a, main;
   var elements = document.getElementsByTagName("link");
   // cycle all <link> tags and filter the ones which are stylesheets and which have a "title" attribute
   for(i=0; i<elements.length; i++) {
     if (elements[i].getAttribute("rel"))
       if (elements[i].getAttribute("rel").indexOf("stylesheet")!=-1)
         if (elements[i].getAttribute("title")) {
            elements[i].disabled = true;
            if(elements[i].getAttribute("title") == title) { elements[i].disabled = false; }
         } 
   }
}
// restore page title if it's not in the content area originally (for print mode)
function restorePageTitle() {
    var elements = document.getElementsByTagName("h1");
    if (elements.length>0) {
         var content = document.getElementById("content").innerHTML;
         document.getElementById("content").innerHTML = "<h1>" + elements[0].innerHTML + "</h1>" + content;
    } 
}
// return the value of a specified query string param
function getQueryString() {
  var result = {}, queryString = location.search.substring(1),
      re = /([^&=]+)=([^&]*)/g, m;
  while (m = re.exec(queryString)) {
    result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
  }
  return result;
}
// check if print mode needs to be activated and activate if yes
var myParam = getQueryString()["print"];
$(document).ready(function() {
    if (myParam=="yes") {
         restorePageTitle();
         setActiveStyleSheet("print");
    } 
});


	
