var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';
		html += '<TITLE>\n';
		html += 'Print Preview';
		html += '</TITLE>\n';
		
		

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY style="overflow:auto">\n';
		
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		
	
		html += '\n</div></BO' + 'DY>\n</HT' + 'ML>';


		s_pos = html.indexOf("<HTML")
		//alert(s_pos + ", " + html.charAt(s_pos));

		body_pos = html.indexOf("<BODY")
		//alert(body_pos + ", " + html.charAt(body_pos));

		e_pos = html.length-1		
		//alert(e_pos + ", " + html.charAt(e_pos));

		part1 = html.substring(0 , body_pos)
		//alert("part1=" + part1);

		part2 = html.substring(body_pos, e_pos - s_pos + 1)

		var re = new RegExp ( "style3.css" )
		stringfound = re.exec (part1);
		//alert("stringfound=" + stringfound);

		part1 = part1.replace(stringfound,"print.css")
		//alert("changed part1=" + part1);

		i=0;
		var tmp = "";

		while (i<part2.length) 
		{
			
			str = part2.substr(i,4)

			if (str=="href")
			{
				tmp = tmp + "href=\"javascript:void(0)\" "
				
				while (part2.substr(i,1) != ">") 
				{
					i = i + 1
				}
				tmp = tmp + ">"
	
			
				
			}
			else
			{
				tmp = tmp + part2.substr(i,1)
			}
			
			i = i + 1
		}

		//alert("tmp=" + tmp)
		html = part1 + tmp;

		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}
