/**
 * JavaScript Library
 *
 * @author		Peter Chapman
 * @version		1.0.07.12.05
 *
 * These are generic JavaScript Functions
 *
 * Functions: (bracketed parameters are optional)
 *  - popupWindow(URL, Width, Height) - Displays a pop-up window
 *  - updateDate(Widget ID) - Date Selection Widget Logic
 *  - printCurrentPage(ID, CSS File) - Prints the contents of the specified element id, using the specified stylesheet
 */
function popupWindow(url, width, height) {
	var popup=window.open(url,"_blank","scrollbars=yes,width="+width+",height="+height+",top="+(screen.height/2 - height/2)+",left="+(screen.width/2 - width/2));
	if (popup) popup.focus();
}
function printCurrentPage(div, css) {
	var width	= 800;
	var height	= 650;
	var pp = window.open("", "_print_page", "scrollbars=yes,width=" + width + ",height=" + height + ",top=" + (screen.height/2 - height/2) + ",left=" + (screen.width/2 - width/2));
	pp.document.writeln("<html><head>");
	pp.document.writeln("<link rel='stylesheet' type='text/css' href='" + css + "'>");
	pp.document.writeln("<style type='text/css'> .noprint { display:none; } body { background-color: #ffffff; } </style>");
	pp.document.writeln("</head><body>");
	pp.document.writeln(document.getElementById(div).innerHTML);
	pp.document.writeln("</body></html>");
	pp.document.close();
	pp.print();
	pp.close();
}
function updateDate(widget) {
if(document.getElementById(widget + "_year").value % 4 == 0 && (document.getElementById(widget + "_year").value % 100 != 0 || (document.getElementById(widget + "_year").value % 400 == 0)) && document.getElementById(widget + "_month").value == '02' && document.getElementById(widget + "_day").value >= '29') document.getElementById(widget + "_day").value = '29'; else if (document.getElementById(widget + "_month").value == '02' && document.getElementById(widget + "_day").value > '28') document.getElementById(widget + "_day").value = '28'; else if((document.getElementById(widget + "_month").value == '04' || document.getElementById(widget + "_month").value == '06' || document.getElementById(widget + "_month").value == '09' || document.getElementById(widget + "_month").value == '11') && document.getElementById(widget + "_day").value > '30') document.getElementById(widget + "_day").value = '30'; document.getElementById(widget).value = document.getElementById(widget + "_year").value + '-' + document.getElementById(widget + "_month").value + '-' + document.getElementById(widget + "_day").value;
}