/* 	  if ( !isDate( e ) ) return false; */
function verify( aForm ) {
	for ( var i = 0; i < aForm.length; i++ ) {
		var e = aForm.elements[i];
		//alert(e.name + ", " + e.type + ", " + e.required + ", " + e.value + ", " + e.message)
		if ( e.type == "text" && e.required ) {	
			if ( e.value == "" ) {
				alert(e.message); 
				e.focus( );
				return false;
			}
		}
		if ( e.date ) {
			//if ( !isDate( e ) ) return false;
			if ( !validateDate( e, "" ) ) return false;
		}
	}
}

function timeStamp() {
	// Create a unique timeStamp --->
	var now = new Date()	// make a unique id for an href to force browser to reload it
							// (otherwise, browser may try to reload this page from cache)
	return "tstamp=" + now.getTime()
}

function reloadOpener ( ) {
	window.opener.location.reload(true);
}

/* || e.type == "textarea" )) && !e.optional ) */
function closePopUp( aForm, aAction ) {
	aForm.action = aAction; 
	aForm.target = 'mainWindow'; 
	aForm.submit( );
	window.close( ); 
}

function closePop ( ) {
	window.opener.location.reload(true);
	window.close();
}

function closePop2 (qreload) {
	if (qreload) window.opener.location.reload(true);
	window.close();
}

function closePopUpSetDisplay( aForm, aAction, display  ) {

	//alert(window.opener.location)
	window.opener.location.reload(true)
	window.opener.focus()
	window.close();

	//aForm.display.value = display;
	//aForm.action = aAction; 
	//aForm.target = 'mainWindow'; 
	//aForm.targetID.value = '';
	//aForm.submit( );
	//window.close( ); 
}

function check( aCheckBox )
{
	with ( document.mainForm ) {
		aCheckBox.checked = true;	
	}	
}

function pop( url ) {
	//alert(url);
	if (url.indexOf("?") == -1)
		url = url + "?" + timeStamp()
	else
		url = url + "&" + timeStamp()
		
	var newWind = window.open( url, 'remote','width=800,height=400,scrollbars');
	if (newWind.opener == null ) newWind.opener = window;    
	if (newWind) newWind.focus()
	//return newWind;
}

function pop2( url, width, height, windowTitle ) {
	if (url.indexOf("?") == -1)
		url = url + "?" + timeStamp()
	else
		url = url + "&" + timeStamp()

   var newWind = window.open( url, 'remote', 'height='+height+',width='+width+  'toolbar=no,location=no,dependent=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=50,top=50');
	if (!newWind) {
		alert('ERROR: Unable to open ' + windowTitle + ' window.')
		return;
	}
	if (newWind.opener == null ) newWind.opener = window;    
	if (newWind) newWind.focus()
	//return newWind
}

function pop3( url, width, height, windowTitle, reloadWin ) {	
			// reloadWin = 1 means to reload this popup window, otherwise = 0
	if (url.indexOf("?") == -1)
		url = url + "?" + timeStamp()
	else
		url = url + "&" + timeStamp()

   var newWind = window.open( url ,'remote', 'height='+height+',width='+width+  'toolbar=no,location=no,dependent=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=50,top=50');
	if (!newWind) {
		alert('ERROR: Unable to open ' + windowTitle + ' window.')
		return;
	}
	if (newWind.opener == null ) newWind.opener = window;    
	if (newWind) {
		//newWind.location.href=url
		newWind.focus()
		if (reloadWin) newWind.location.reload(1)
	}
   //return newWind
}

function popUp( aForm ) {

   var newWind = window.open('','remote','width=600,height=400');
   if (newWind.opener == null ) {
   	newWind.opener = window; 
   }
   if (newWind) newWind.focus()
  aForm.submit( );
}

// Display help in it's own window (not one of the other popup windows)
function showHelp (nameTag) {
	var pathArray = location.pathname.split('/')
	var lastDirectory = pathArray[pathArray.length-2]
	if (lastDirectory == "admin" || lastDirectory == "imint" || lastDirectory == "masint" || lastDirectory == "sigint")
		helpUrl = "../help/helpFrame.html#" + nameTag
	else 
		helpUrl = "help/helpFrame.html#" + nameTag
	var helpWind = window.open( helpUrl ,'help', 'height=300,width=600,toolbar=no,location=no,dependent=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=50,top=100');
	if (!helpWind) {
		alert('ERROR: Unable to open Help window.')
		return;
	}
	if (helpWind.opener == null ) helpWind.opener = window;    
	if (helpWind) helpWind.focus()
	//return helpWind
}

