/*
addPrintLink function by Roger Johansson, www.456bereastreet.com
*/
var addPrintLink = {
	init:function(sTargetEl,sLinkText) {
		if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
		if (!document.getElementById(sTargetEl)) {return;} // Check that the target element actually exists
		if (!window.print) {return;} // Check that the browser supports window.print
		var oTarget = document.getElementById(sTargetEl);
		
		var oListItem = document.createElement('li');
		var oLink = document.createElement('a');
		var oSpan1 = document.createElement('span');
		var oSpan2 = document.createElement('span');
		var oSpan3 = document.createElement('span');
		var oSpan4 = document.createElement('span');
		
		oListItem.className = 'button print'; // Give the link an id to allow styling
		oLink.href = '#'; // Make the link focusable for keyboard users

		oListItem.appendChild(oLink);
		oLink.appendChild(oSpan1);
		oSpan1.appendChild(oSpan2);
		oSpan2.appendChild(oSpan3);
		oSpan3.appendChild(oSpan4);
		oSpan4.appendChild(document.createTextNode(sLinkText));
		
		oLink.onclick = function() {window.print(); return false;} // Return false prevents the browser from following the link and jumping to the top of the page after printing
		oTarget.appendChild(oListItem);
	},
/*
addEvent function included here for portability. Replace with your own addEvent function if you use one.
*/
/* addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent:function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
addPrintLink.addEvent(window, 'load', function(){addPrintLink.init('print_holder','Print results');});
