// printPage
// Darby Hewitt -- April 13, 2007
// writes a printer-friendly document in a new window based on
// content in current page
//
// Requires div ids for content and section title
//--------------------------------------------------------------------
// Updated 7/18/07 by Darby Hewitt
// Now works with organization pages, too
//--------------------------------------------------------------------

function printPage(contentTextId, sectionTitleId, copyright){
  
  //if copyright was omitted, define it now
  if(!copyright && copyright !== '0')
    copyright = '1';
    
  imageLocation = 'http://www.acu.edu/common/images/printlogo.jpg';
  styleLocation = 'http://www.acu.edu/common/css/printstyle.css';
  url = this.location.href;
  title = this.document.title;
  
  //remove ' - Abilene Christian University' from title if it's there; this is the in-page title
  doctitle = title.replace(/ - Abilene Christian University/, "");
  
  content = this.document.getElementById(contentTextId);
  secTitle = this.document.getElementById(sectionTitleId);
  
  content = content.innerHTML;
    
  //open a new, blank window with these parameters
  newWin = window.open('','', 'menubar=1, scrollbars=1, width=700, height=1000, resizable=yes');
  
  //write this to the new window
  newWin.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    +'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
    +'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
    +'<head><title>'+title+'</title>'
    +'<link rel="stylesheet" type="text/css" href="' + styleLocation + '" />'
    +'</head><body><div class="wrapper">');
  
  if(copyright == '1'){
    newWin.document.writeln('<div class="header"><div id="headerLeft">'
      +'<img src="' + imageLocation + '" />'
      +'</div><div id="headerRight">'
      +'<h1>'+doctitle+'</h1>'
      +'</div></div>');
  }
  else{
    newWin.document.writeln('<div class="header" style="height: 35px;">'
      +'<span style="font-size:25px; font-weight:500;">'+doctitle+'</span></div>');
  }
  
  newWin.document.writeln('<div class="outer"><div class="inner"><div class="centerBG"><div class="center">'
    +'<div class="sectionTitle">'+secTitle.innerHTML+'</div>'
    +'<div class="text">'+content+'</div>'
    +'<br /><br />'
    +'(Printer friendly version of '+url+')</div></div></div></div>'
    +'<div class="clear"></div>'
    +'<div id="footerText" class="darkLinks centeredText">');
  
  if(copyright == '1'){
    newWin.document.writeln('<p><a href="/copyright.html">Copyright</a> &copy; 1995-2007 Abilene Christian University. All rights reserved.</p>');
  }
  else{
    newWin.document.writeln('<p>The opinions expressed on this page may not reflect those of Abilene Christian University.</p>');
  }
  
  newWin.document.writeln('</div></div> <!-- /wrapper --></body></html>');
  
  //stop writing to this window
  newWin.document.close();
}
