/* 	Popup functions
 *	~~~~~~~~~~~~~~~
 *
 *		open a new window as the current window is closing.
 *		call the popUpWindow() function in the OnUnload event of
 *		the html body tag 
 * 			e.g. OnUnload = 'http://www.rivers.com.au',0,0,800,600'
 *
 *		include this file in the head of the document
 *			e.g. <script language="javascipt" src="/includes/popup.js"></script>
 */		
 
	//keep a tab on the pop-up window
	var popUpWin=0;
	
	//initialise defaults
	var defURLStr = "http://www.rivers.com.au";
	var defLeft = 0;
	var defTop = 0;
	var defWidth = 800;
	var defHeight = 600;
	var defNumItems = 0;

	function popUpWindow(URLStr, left, top, width, height, numItems) {
		/*	Check the event to see if window is closing
		 *	if closing - popup new window ( see popUpWindow() )
		 *	if not (refreshing, etc) do nothing
		 */
		if(!numItems > 0) {
			var e = window.event
			if (e != null) {
				//check that window is closing
				if (e.clientY < 0 && e.clientX < 0) {
					//close popup window if already open
					if(popUpWin)
						if(!popUpWin.closed) popUpWin.close();
			
					//open window with no decorations (menubar, addressbar, etc)
					popUpWin = open(URLStr, 'popUpWin', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,copyhistory=1,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
				}
			}
		}
	}
