/* 
 * wrapper for remembering the window.open syntax
 */
function pp_windowOpen(theURL,winName,features) { 
	newWindow = window.open(theURL,winName,features);
	newWindow.focus();
	return false;
}


/** 
 * wrapper around window.open used for opening a browser window with a
 * certain size - this opens a fully featured resizable browser window, with
 * menu, toolbars, status pane, and scrollbars
 */
function pp_popupWindow(url, winName, aWidth, aHeight, X, Y) 
{
	// if Height and Width are passed, but no X and Y coordinates passed, 
	// center the window on the screen
	if ( aHeight != null && aWidth != null && X == null && Y == null ) {
		X = Math.round((window.screen.availWidth - aWidth) / 2);
		Y = Math.round((window.screen.availHeight - aHeight) / 2);
	}

	var features= "height="+aHeight +", width="+aWidth +
			", screenX="+X +", screenY="+Y +", left="+X +", top="+Y
			+", location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes";

	return pp_windowOpen(url,winName,features);

}


/** 
 * wrapper around window.open used for opening a resizable popup window without
 * toolbars
 */
function pp_popupView(url, winName, aWidth, aHeight, X, Y) 
{
	// if Height and Width are passed, but no X and Y coordinates passed, 
	// center the window on the screen
	if ( aHeight != null && aWidth != null && X == null && Y == null ) {
		X = Math.round((window.screen.availWidth - aWidth) / 2);
		Y = Math.round((window.screen.availHeight - aHeight) / 2);
	}

	var features= "height="+aHeight +", width="+aWidth +
			", screenX="+X +", screenY="+Y +", left="+X +", top="+Y
			+", location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no";

	return pp_windowOpen(url, winName, features);
}

/** 
 * wrapper around window.open used for opening a non-resizable popup message window 
 */
function pp_popupMessage(url, winName, aWidth, aHeight, X, Y) 
{
	// if Height and Width are passed, but no X and Y coordinates passed, 
	// center the window on the screen
	if ( aHeight != null && aWidth != null && X == null && Y == null ) {
		X = Math.round((window.screen.availWidth - aWidth) / 2);
		Y = Math.round((window.screen.availHeight - aHeight) / 2);
	}

	var features= "height="+aHeight +", width="+aWidth +
			", screenX="+X +", screenY="+Y +", left="+X +", top="+Y
			+", location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no";

	return pp_windowOpen(url, winName, features);
}


// debugging functions 
function imageGetter() {	 
	var msgWindow=window.open();
	for (var i = 0; i < document.images.length; i++) {
		msgWindow.document.write("images[" + i + "] name = '" 
					+ document.images[i].name 
					+ "' - src = " + document.images[i].src + "<BR>"); 
	}
}

function valueGetter(aForm) {	 
	if (aForm.elements.length > 0) {
		var msgWindow=window.open();
		for (var i = 0; i < aForm.elements.length; i++) {
			msgWindow.document.write(
					"element[" + i + "] is " + 
					aForm.elements[i].name + " = " + 
					aForm.elements[i].value + "<br>"); 
		}
	}
}

/* gets the current year, regardless of the idiosyncrasies of the browser */
function getCurrentYear() {
	date=new Date(); 

	if (navigator.userAgent.indexOf("Gecko") != -1) {
		document.write(date.getYear() + 1900);
	}
	else {
		document.write(date.getYear());
	}
}
