// JavaScript Document
// JavaScript Document
	
	function getOuterHTML(object) {
		var element;
		
		if (!object) return null;
		
		element = document.createElement("div");
		
		element.appendChild(object.cloneNode(true));
		
		return element.innerHTML;
	}

	var gAutoPrint = true; // Tells whether to automatically call the print function

	function printSpecial(idToPrint)
	{
		if (document.getElementById != null) {
			var html = '<html>\n<head>\n';
			
			html += '<title>Coupon</title>\n';
			html += '<link rel="stylesheet" type="text/css" href="assets/templates/maintpl/css/design.css" />\n';
			html += '<link rel="stylesheet" type="text/css" href="assets/templates/maintpl/css/inventory.css" />\n';
			html += '<link rel="stylesheet" type="text/css" href="assets/templates/maintpl/css/print-inv.css" />\n'; 			
			/*
			if (document.getElementsByTagName != null) {
				var headTags = document.getElementsByTagName("head");
				if (headTags.length > 0) {
					html += headTags[0].innerHTML;
				}
			}
			*/
	 		
			html += '\n</head>\n<body id="printing"><div id="content-body" style="background: none !important;"><div id="primary-division">\n';
	 
			var printReadyElem = document.getElementById(idToPrint);
			 
			if (printReadyElem != null) {
				html += getOuterHTML(printReadyElem);
			}
			else {
				alert("Could not find the printReady function");
				return;
			}
			
			html += '</div></div>\n</body>\n</html>';
			
	 		var winHeight = printReadyElem.offsetHeight + 30;
			var winWidth = printReadyElem.offsetWidth + 30;
			
			var printWin = window.open("","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + winWidth + ", height=" + winHeight);
			printWin.document.open();
			printWin.document.write(html);
			
			printWin.document.close();
			
			if (gAutoPrint)
				printWin.print();
				
		}
		else {
			alert("The print ready feature is only available if you are using an browser. Please update your browser.");
		}
	}