// Opens up the print window
function printPage()
{
	var printURL = document.location.pathname;

	// If there are already query parameters
	if(document.location.search)
	{
		printURL += "?" + document.location.search + "&print=true";
	}
	else
	{
		printURL += "?print=true";
	}
	
	window.open(printURL);
}

// If in print mode
if($(document).getUrlParam("print"))
{
	document.write('<link rel="stylesheet" media="print,screen" href="css/print.css" type="text/css">');

	// Wait for all the styles to load before disabling
	$(document).ready(function(){
		$("style").attr("disabled", "true");
		
		// If this is Safari
		if($.browser.safari)
		{
			$("style").remove();
		}
		
		// Delay printing so that the page fully loads
		setTimeout(function() {window.print();}, 50);
	});
}
else
{
	document.write('<link rel="stylesheet" media="print" href="css/print.css" type="text/css">');
}