var doctype='<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/loose.dtd">';

var content_top='<html><head><title>Printer Friendly Info</title><style type="text/css"></style></head><body style="margin:0 2px; background-color: white;"><table width="100%" border="0" cellpadding="1" cellspacing="0" style="margin-bottom:10px;"><tr><td><form style="margin:0;"><input type="button" value="Print" onClick="javascript:window.print()">&nbsp;<input type="button" onClick="javascript:window.close()" value="Close Window"></form><td><b><font size="+1">DuraBelt Inc.</font><b><td><b>800-770-2358</b><td align="center"><a href="http://www.durabelt.com">www.durabelt.com</a><td align="right"><em>info@durabelt.com</em></table><div align="center" id="print">';

var content_bottom = '<br><font size="-1">Copyright &copy; 2006 DuraBelt Inc., All Rights Reserved.</font></div></body></html>';

function createprintable(w, h) {
	w = w || 790;
	h = h || 650;

	popup = window.open('', 'thewindow',
		'scrollbars,resizable,width='+w+',height='+h+',left=100,top=0');

	popup.document.writeln(doctype);
	popup.document.writeln(content_top);

	// COPY STYLE SHEET
	if (document.styleSheets) {
		var popStyle = popup.document.styleSheets[0];
		var i;

		if (document.styleSheets[0].cssRules) { // mozilla
			for (i=0; i<document.styleSheets.length; i++) {
				for (var ii=0; ii<document.styleSheets[i].cssRules.length; ii++) {
					popStyle.insertRule(document.styleSheets[i].cssRules[ii].cssText, 0);
				}
			}
		}
		else { // IE
			for (i=0; i<document.styleSheets.length; i++) {
				popStyle.cssText += document.styleSheets[i].cssText;
			}
		}
	}

	popup.document.writeln(document.getElementById('print').innerHTML);

	if (document.getElementById('print1'))
		popup.document.writeln("<br>" + document.getElementById('print1').innerHTML);
	if (document.getElementById('print2'))
		popup.document.writeln("<br>" + document.getElementById('print2').innerHTML);
	if (document.getElementById('print3'))
		popup.document.writeln("<br>" + document.getElementById('print3').innerHTML);

	popup.document.writeln(content_bottom);
	popup.document.close();

	// delete the Convert units to form as we cant copy the javascript easily
	var d = node_walk(popup.document.body);
	if (d.tagName == 'DIV') { // if found, tagname will be DIV, else itll still be BODY
		d.innerHTML = "&nbsp;";
	}

}

// recursively searches the dom for a string, returning the containing DIV
function node_walk(node)
{
	var d = node.getElementsByTagName('DIV');
	for (var i in d) {
		if (d[i].innerHTML && d[i].innerHTML.indexOf('Convert units') != -1) {
			return node_walk(d[i]);
		}
	}
	return node;
}


function create_printable_picture(url) {
	popup = window.open('', 'thewindow',
		'scrollbars,resizable,width=800,height=650,left=100,top=0');

	popup.document.writeln(content_top);
	popup.document.writeln("<img src=\"" + url + "\">");
	popup.document.writeln(content_bottom);
	popup.document.close();
}


