// Java Document

// function checkBlankDate(formFieldObj) {
//    if (formFieldObj.value != "")
//	      checkDate(formFieldObj)
// }

function checkDate(formFieldObj,minus,plus) {
	
   var howManyDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
   var temp  = formFieldObj.value;
	var tempPartsArray = temp.split("/");
	var rangeString = "\n range from this year - " + minus + " to this year + " + plus;

	
	if (tempPartsArray.length < 3) {
	   alert("Invalid date format");
		formFieldObj.focus();
		return false;
	}
	
	month = tempPartsArray[0];
	day   = tempPartsArray[1];
	year  = tempPartsArray[2];
	
	if ((month < 1) || (month > 12)) {
	   alert("Invalid date format - incorrect month");
		formFieldObj.focus();
		return false;
	}
	
// check for leap year	
	if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0 )))
	   howManyDays[1] = 29;
	
	if ((day < 1) || (day > howManyDays[month - 1])) {  // Jan = 1 but the array is zero based
	   alert("Invalid date format - incorrect day");
		formFieldObj.focus();
		return false;
   }
	
	today = new Date();  
	thisYear = today.getFullYear();
	
   if ((year < thisYear - minus) || (year > thisYear + plus)) {
	   alert("Invalid date format - Year out of range " + rangeString);
		formFieldObj.focus();
		return false;
	}
	return true;
}

function securemail (domain, username) {
   var address =  "";
   address = address + username + "@" + domain;
window.open ('mailto:'+address,'_blank');
}

function popUpWindow(urlName, W, H) {
   var paramStr = "status=no, toolbar=no, location=no, menu=no, scrollbars=yes, directories=no, resizable=yes";
   paramStr += ", width=" + W + ", height=" + H;
   win = window.open(urlName, "WIN", paramStr);
}  // end of function PopUpWindow()

function NewWindow(urlName) {
	var paramStr = "status=yes, toolbar=yes, location=yes, menu=yes, scrollbars=yes, directories=yes, resizable=yes";
      newwin = window.open(urlName, "NEWWIN", paramStr);
}  // end of function PopUpWindow()
