function urlEncodeCharacter(c) {
	return '%' + c.charCodeAt(0).toString(16);
}

function urlDecodeCharacter(str, c) {
	return String.fromCharCode(parseInt(c, 16));
}

function urlencode(s) {
	return encodeURIComponent( s ).replace( /\%20/g, '+' ).replace( /[!'()*~]/g, urlEncodeCharacter );
}

function urldecode(s) {
	return decodeURIComponent(s.replace( /\+/g, '%20' )).replace( /\%([0-9a-f]{2})/g, urlDecodeCharacter);
}

function friendlyPrint(header, bodyDivID, footerDivID) {
	var url = window.location.href;
	var title = document.title;
	var body = document.getElementById(bodyDivID);
	if (body != undefined) {
		body = body.innerHTML;
	} else {
		body = document.getElementById('contentarea').innerHTML;
	}
	var footer = document.getElementById(footerDivID);
	if (footer != undefined) {
		footer = footer.innerHTML;
	} else {
		footer = "";
	}
	
	winRef = window.open('','','width=1000,height=600,menubar=1,toolbar=0,status=0,scrollbars=1,resizable=1');
	docRef = winRef.document.open("text/html","replace");
	docRef.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+
		"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">"+
		"	<head>"+
		"		<title>" + title + "</title>"+
		"		<link href='/css/printerFriendly.css' rel=stylesheet type='text/css'>"+
		"	</head>"+
		"	<body>"+
		"		<div style='clear: both;'>" + header + "</div>" +
		"		<div style='clear: both;'>" + body + "</div>"+
		"		<div style='clear: both; margin-top: 20px;'>" + footer + "</div>"+
		"	</body>"+
		"</html>");
	docRef.close();
	winRef.focus();
	winRef.print();
}

