var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial( printable_div )
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			html += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
			html += '<title>brownill vickers and platts</title>\n';
			html += '<link rel="stylesheet" type="text/css" href="../css/printSpecial.css" />\n';
		}

		html += '\n</HE' + 'AD>\n<BODY>\n';
		
		var printReadyElem;
		if(!(printReadyElem = document.getElementById( printable_div ))){
			clone = null;
		}
		if(printReadyElem != null){
			var clone;
			clone = printReadyElem.cloneNode(true);
		}

		if (clone != null)
		{
			//remove any unwanted elements (divs)
			var elements = new Array('headingContainer', 'leftNavOuter');
			var divs = clone.getElementsByTagName("div");
			var id;
			for(var j = 0; j < elements.length; j++){
				for (var i = 0; i < divs.length; i++) {
					id = divs[i].getAttribute("id");
					//check if the div is to be removed
					if ( id == elements[j] ) {
						//remove the element
						clone.removeChild(divs[i]);
					}
				}
				
			}
			//add the html
			html += '<div class="printContainer">\n';
			html += clone.innerHTML;
			html += '</div>\n';
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}

		html += '\n</BO' + 'DY>\n</HT' + 'ML>';

		var printWin = window.open("","printSpecial",'toolbar=no, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes, width=700, height=400');
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		
		if (gAutoPrint){
			printWin.print();
			//printWin.close();
		}
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}