
// This javascript determines whether the current URL contains a 
// parameter with name "version" and value "print". 
//
// If it does, the section where the stylesheets are contains only
// one, namely the "print.css" stylesheet. This happens only if the
// "print" button is pushed on a page.
//
// If no such parameter is found in the URL, the usual css files 
// are written onto the page, which are to be found in the "assets/css"
// subdirectory
//
//
// Written by Johannes (jhorstma@cochrane.de) on 10.1.2006


var query = window.location.search.substring(1);
var parms = query.split('&');

document.write('<link href="../assets/css/textstyles.css" rel="stylesheet" type="text/css" media="all"/>');

for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf("=");
   if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);

      if (key == "version" && val == "print") {

	// Invalidate all the stylesheets given on the page
	// by setting their source to "none"
	var cssElements = document.getElementsByTagName("link");
	for (var i=0; i<cssElements.length; i++) {
		cssElements[i].href="none";
	}

        document.write('<link href="../assets/css/print.css" rel="stylesheet" type="text/css" media="all"/>');
	isPrint = 1;
      }
   }
}
