/*
printPreview function. Reloads the pages with an additional query string value
view=printpreview. This allows the page to switch to the print only 
*/
function printPreview(){
  // reload page with ?view=printpreview
  var href_append;
  var new_loc = location.href;
  
  if(location.search){
    href_append = '&view=printpreview';
  } else {
    href_append = '?view=printpreview';
  }    
  if(location.hash){
    href_append = href_append + location.hash;
    var regex = /\#[a-zA-Z0-9_=]*$/;
    new_loc = new_loc.toString().replace(regex,"");
  }
  document.location.href = new_loc + href_append;

} 
/* 
  page pre-processor, if view is printpreview then switch to the print only
  style-sheet.
*/

if (location.search){ 
  var regex = /view\=printpreview/;
  if (location.search.match(regex)){
    // Print preview of page.
    // Switch stylesheets
    document.styleSheets[0].disabled = true;
    document.styleSheets[1].disabled = false;
  } else {
  document.styleSheets[0].disabled = false;
  document.styleSheets[1].disabled = true;
  }
} else {
  document.styleSheets[0].disabled = false;
  document.styleSheets[1].disabled = true;
}











