// JavaScript Document
 
var ID_CELLTOPRINT="maintable-DetailsCell";		//id of cell containing text to print
var ID_PRINTFRIENDLYTABLE="printfriendlytable";	//id of Table containing the PrintFriendy Version option
var ID_PRINTTABLE="printtable";					//id of Table containing the Print option

function printfriendly(){
	//Main Routine controlling the Print Friendly Pop-Up
	var detailcell;
	var win;
	var stylesheet1="http://www.guernseydonkey.net/Stylesheets/style.css";
	var element;
	var stylesheetHTML="";
	var scriptHTML="";
	var winprops ="width=740,height=500,left=140,top=140,scrollbars=yes,resizable=yes";

	
	//Get Reference to the Cell to display (for it's HTML)
	detailcell=document.getElementById(ID_CELLTOPRINT);
	
	//Prepare Stylesheet HTML (also adjust any styles not required)
	stylesheetHTML="<link href=" + "\"" + "../../Stylesheets/style.css" + "\"" + " rel=" + "\"" + "stylesheet" + "\"" + " type=" + "\"" + "text/css" + "\"" +">" + "\r\n";
	stylesheetHTML=stylesheetHTML + "<style type=" + "\"" + "text/css" + "\"" + "> body {background-image: url();} </style>"

	//Prepare Script HTML
	scriptHTML="<script language=" + "\"" + "javascript"+ "\"" + " src=" + "\"" + "../../Scripts/printfriendly.js" + "\"" + "><" + "/script>" + "\r\n"; 
	//scriptHTML=scriptHTML + "<script language=" + "\"" + "javascript"+ "\"" + " type=" + "\"" + "text/javascript" + "\"" + ">" + "\r\n";
	//scriptHTML=scriptHTML + "window.onload = PopUpPageLoad();" + "\r\n";
	//scriptHTML=scriptHTML + "<" + "/script>";
	
	//Create a new Window & Document
	win=window.open("","Print",winprops);
	
	//Write the HTML
	win.document.writeln("<html>");
	win.document.writeln("<head>");
	win.document.writeln(stylesheetHTML);
	win.document.writeln(scriptHTML);
	win.document.writeln("</head>");
	//win.document.writeln("<body>");
	win.document.writeln("<body onLoad = " + "\"" + "PopUpPageLoad();" + "\"" + ">");
	win.document.writeln(detailcell.innerHTML);
	win.document.writeln("</body>");
	win.document.writeln("</html>");
	
	//Close Document Writting
	win.document.close();
	
}

function PopUpPageLoad(){
	//Routine to call when the Pop-Up Loads
	//(Specified in the HTML written to Pop-Ip above)
	
	var element;
	
	//Hide the Print Friendly Table
	element=document.getElementById(ID_PRINTFRIENDLYTABLE);
	element.style.visibility="hidden";
	
	//Show the Print Table
	element=document.getElementById(ID_PRINTTABLE);
	element.style.visibility="visible";
	
}
