//////////////////////////////////////////////////////////////////////////////
//date function dumping ground 
//from index2.asp
//////////////////////////////////////////////////////////////////////////////
	
	function isDate(textField) {
		var myDate = new String(textField.value);
	  	var delimiterFirstInstance;
	  	var delimiterSecondInstance;
	  	var delimiterType;
	  	var monthPart;
	  	var dayPart;
	  	var yearPart;
	 
	  	//accepts delimiting characters of either "/" or "-" 
	 
	  	delimiterFirstInstance = textField.indexOf("/");
	  	if (delimiterFirstInstance == -1) {
		  	//check for the other allowed delimiter
		  	delimiterFirstInstance = myDate.indexOf("-");
		  	//if it is still not found, return false
		  	if (delimiterFirstInstance == -1) {
		    		return false;
		  	}
		  	delimiterType = "-";
	  	} else {
	  		delimiterType = "/";
	  	}
	
	  	delimiterSecondInstance = textField.indexOf(delimiterType, (delimiterFirstInstance + 1));
	  	if (delimiterSecondInstance == -1) {
	  		return false;
	  	}
	   	monthPart = textField.substring(0, delimiterFirstInstance);
	  	if(validateMonth(monthPart) == false) {
	  		return false;
	  	}
	  	yearPart = textField.substring((delimiterSecondInstance + 1), (textField.length));
	   	if(validateYear(yearPart) == false) {
	  		return false;
	  	}
	 
	  	dayPart = textField.substring((delimiterFirstInstance + 1),  (delimiterSecondInstance));
	  	if(validateDay(monthPart, dayPart, yearPart) == false) {
	  		return false;
	  	} else {
	  		return true;
	  	}
	}
	 
	function validateDay(m, d, y) {
	  	if((isNaN(d)) || d == "") {
	  		return false;
	  	}
	  	var mo = parseInt(m, 10);
	  	var da = parseInt(d, 10);
	  	var ye = parseInt(y, 10);
	 
	  	if (da < 1) {
	  		return false;
	  	}
	 
	  	if ((mo == 4) || (mo == 6) || (mo == 9) || (mo == 11)) {
	  		//it is a 30 day month
	  		if (da > 30) {
	    			return false;
	  		}
	  	} else if(mo == 2) {
	  		// it is february (either 28 or 29 depending on leap year)
	  		if (isLeapYear(ye) == true) {
	    			if (da > 29) {
	    				//leap years have 29 days in february
	    				return false;
	   	 		}
	  		} else {
	    			if (da > 28) {
	    				//non leap years have 28 days in february
	    				return false;
	    			}
	  		}
	  	} else {
	  		// it is a 31 day month
	  		if (da > 31) {
	    			return false;
	  		}
	  	}
	  	//if we made it through all of the above without falling out,
	  	//it must be a valid day for the given month and year
	  	return true;
	}
	 
	function validateMonth(mnth) {
	  	if((isNaN(mnth)) || mnth == "") {
	  		return false;
	  	}
	  	var intMonth = parseInt(mnth, 10);
	  	if((intMonth < 1) || (intMonth > 12)) {
	  		return false; //month must be between 1 and 12 (inclusive)
	  	} else {
	  		return true;
	  	}
	}
	 
	function validateYear(yr) {
	  	if((isNaN(yr)) || yr == "") {
	  		return false;
	  	}
	  	var intYear = parseInt(yr, 10);
	  	if((intYear < 1970) || (intYear > 9999)) {
	  		return false; 
	  		//year must be between 1970 and 9999 (inclusive)   
	  	} else {
	  		return true;
	  	}
	}
	 
	function isLeapYear(yr) {
	  	// classic leap year calculation: if the year is: evenly divisible by 4 and not evenly divisible by 100
	    	// or evenly divisible by 400 then it is a leap year, Otherwise it is not a leap year  
	 
	    	if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) {         
	    		return true;
	  	} else {
	    		return false;
	  	}
	}
 
	function compareDate(date1,date2){
		///-1 - if date1 < date2
	        ///0 - if date1 = date2
	        ///1 - if date1 > date2
	
	  	var aDate = new Date(date1);
	  	var bDate = new Date(date2);
	 
	  	if ( aDate.getTime() == bDate.getTime() ) return 0;

	  	return (aDate.getTime() < bDate.getTime() ? -1 : 1);
	}


	function changeDays(pcmbMonth,pMenu,iDays){
		var oldSelection = pMenu.selectedIndex; 
		if (pMenu.options.length == 1 ) {
			for (var x = pMenu.options.length; x <= iDays; x++) {
				//if (navigator.appVersion.indexOf('MSIE 5.0') > -1){
				//	pMenu.options.add(pDoc.createElement("option"));
				//	pMenu[pMenu.length].text = x;
				//} else {
					pMenu.options[pMenu.options.length] = new Option(x);
					pMenu[pMenu.length - 1].value = x;
				//}
			}
		}else {
			for (var x = pMenu.options.length - 1; x >= 28; x--) {
				pMenu.options[x] = null;
			}
			if (pMenu.options.length <= iDays){				
				for (var x = pMenu.options.length; x <= iDays; x++) {
					//if (navigator.appVersion.indexOf('MSIE 5.0') > -1){
					//	pMenu.options.add(pDoc.createElement("option"));
					//	pMenu[pMenu.length].text = x;
					//} else {
						pMenu.options[pMenu.options.length] = new Option(x);
						pMenu[pMenu.length - 1].value = x;
					//}
				}
			}
		}
		if ((oldSelection + 1) > iDays) {
			pMenu.selectedIndex = iDays;
		}else {
			if ((oldSelection + 1) == iDays) {
				pMenu.selectedIndex = iDays - 1;
			}else {
				pMenu.selectedIndex = oldSelection;
			}
		}
	}
			
	function dateBoxChange(pcmbMonth,pcmbDay,pcmbYear,phidTarget){
		var iMonth = pcmbMonth.options[pcmbMonth.selectedIndex].value;
		var iYear = pcmbYear.options[pcmbYear.selectedIndex].value;
		var pMenu = pcmbDay
	
		if (iMonth==1)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==2){
			if(((iYear % 4 == 0) && (iYear % 100 !=0)) || (iYear % 400 == 0)){
				changeDays(pcmbMonth,pMenu,29);
			}else{
				changeDays(pcmbMonth,pMenu,28);
			}
		};
		if (iMonth==3)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==4)
			changeDays(pcmbMonth,pMenu,30);	
		if (iMonth==5)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==6)
			changeDays(pcmbMonth,pMenu,30);	
		if (iMonth==7)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==8)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==9)
			changeDays(pcmbMonth,pMenu,30);	
		if (iMonth==10)
			changeDays(pcmbMonth,pMenu,31);	
		if (iMonth==11)
			changeDays(pcmbMonth,pMenu,30);	
		if (iMonth==12)
			changeDays(pcmbMonth,pMenu,31);	
	
		phidTarget.value = pcmbMonth.options[pcmbMonth.selectedIndex].value + '/' + pcmbDay.options[pcmbDay.selectedIndex].value + '/' + pcmbYear.options[pcmbYear.selectedIndex].value;
	}
//////////////////////////////////////////////////////////////////////////////
//done date functions
//////////////////////////////////////////////////////////////////////////////