function printCSSCheck()
{
	if (document.styleSheets)
	{
		var displayMedium = "screen";
		if (String(document.location).match(/mode=print/))
		{
			displayMedium = "print";
		}

		// DEBUG PRINT LINE
		// document.write(displayMedium+"<br />");

		for (i=0; i<document.styleSheets.length; ++i)
		{
			cssFileName = String(String(document.styleSheets[i].href).match(/[^/]+css/));

			if (displayMedium=="print" && !cssFileName.match(/print/))
			{
				document.styleSheets[i].disabled = true;
			}
			else if (displayMedium=="screen" && cssFileName.match(/printprev/))
			{
				document.styleSheets[i].disabled = true;

				// Next line is a Safari fix, and NOT a robust one, at that
				if (document.styleSheets[0].cssRules)
					document.styleSheets[i].cssRules[0].style.display = 'auto';
			}

			// DEBUG PRINT LINE
			// document.write(cssFileName + " " + document.styleSheets[i].disabled + "<br />");
		}
	}
}

function customPrint()
{
	// If this is not a currently previewed page:
	if (!String(document.location).match(/mode=print/))
	{
		// Determine the querystring to add
		var hasQueryString = String(document.location).match(/\?/);
		if (hasQueryString)
		{
			appendString = "&mode=print";
		}
		else
		{
			appendString = "?mode=print";
		}

		// Open the page in a new window with the print value added to the querystring
		window.open(document.location+appendString,"printWindow","");
	}
	// If we are already in preview mode
	else
	{
		// Print the page
		window.print();
	}
}

function printOnload()
{
	if (String(document.location).match(/mode=print/))
	{
		window.print();
	}
}