//alert('loaded');

// addValidation function
// Description: 
//	- Adds to global array of validation objects to be checked on submit.
// Template(s):
//	  addValidation('fieldName' , 'displayName', 'fieldType', 'altMessage');
//	  <script language='javascript' src='/admin/include/validate.js'></script>
// Arguments:
//	- fieldName - name of form field, or array of form fields for checkOne validation type.
//	- displayName - name to use in alert message.
//	- fieldType - a string indicating the type of validation to perform
//		'text' - requires a length of greater than 0
//		'checkOne' - requires one of the fields in fieldName (an array) to be checked
//		'radio' - requires one of the radio button instances is selected
//		'select' - requires a value
//		'multiselect' - requires a value
//		'credit' - validates a credit card #, requires the ChkCard.js to be included
//		'email' - validates email 
//		'password' - validates that fieldName and fieldName & '2' have the same value
//		'number' - validates that fieldName and fieldName & '2' have the same value
//		'maxlength' - validates value not longer than value of validateThis.altMessage (useful for textarea's)
//		'minlength' - validate value is longer than value of validateThis.altMessage
//		'telephone' - validate value is in the form of a phone number
//		'ssn' - validate the value is in the form of a Social Security Number
//		'date' - validate the value can be accepted as a date, checks most date formats.
//		'time' - validate the value can be accepted as a time, checks am/pm and military.
//		'month' - validate the value is a month, checks numeric, abbreviations, and full month names.
//		'year' - validate the value is a year, assumes 2 digit years are 2000+
//		'ansi2oem' - formats text pasted from MS Word, etc. Requires the ansi2oem.js to be included
//		'conditionalOther' - checks that fieldName has a value, if the expression in altMessage (fieldname=value) is true. 
//	- altMessage - text to display instead of generic alert message, pass '' to use generic message.

	function addValidation (fieldName,displayName,fieldType,altMessage) {
		thingsToValidate[thingsToValidate.length] = new somethingToValidate(fieldName,displayName,fieldType,altMessage);
		//alert('validation added');
	}

	var thingsToValidate = new Array();
	
	function clearValidations() {
		thingsToValidate = new Array();
	}

	function somethingToValidate (fieldName,displayName,fieldType,altMessage) {
		this.fieldName = fieldName;
		this.displayName = displayName;
		this.fieldType = fieldType;
		this.altMessage = altMessage;
	}

	// hands off validation for each field needing validation based on the validation type
	// to one of the functions below. add validation types as needed.
	function validate(frm) {
		// walk through all the validation objects that have been added
		
		for (var i = 0; i < thingsToValidate.length; i++) { 
			validateThis = thingsToValidate[i];			
			// calls the specific validation function for this
			// validation object based on the validationType...
			if (validateThis.fieldType=='credit') {
				if (!validate_credit(frm, validateThis)) {return false;};			
			} else {
				if (!eval('validate_' + validateThis.fieldType + '(frm,validateThis)')) {return false};
			}
		}
		
		return true;
	}

	//***************** Validation Functions ********************
	function validate_number(frm, validateThis) {
		var strValidChars = "0123456789";
		var strChar;
		var blnResult = true;
		var fld = eval('frm.' + validateThis.fieldName);
		var strString = fld.value;
		
		//  test strString consists of valid characters listed above
		for (i = 0; i < strString.length && blnResult == true; i++)
		  {
		  strChar = strString.charAt(i);
		  if (strValidChars.indexOf(strChar) == -1)
		     {
		     blnResult = false;
		     }
		  }
		if (!blnResult) {
			if (validateThis.altMessage=='') {
				alert('The value for ' + validateThis.displayName + ' must be a number.');
				fld.focus();
			}
		}
		return blnResult;
	}

	function validate_telephone(frm, validateThis) {    
		var fld = eval('frm.' + validateThis.fieldName);
		var aChar = null;
		var blnResult = true;
		
	
		//If the field is blank, return true to avoid alerting users that they have entered
		// a non valid Telephone when telephone is NOT required. Use MinLength Validation in
		// conjunction with Telephone validation to validate a required telephone number.		
		if(fld.value.length == 0) {
		    blnResult = true;
		}
		//If the field has some value in it, but it is less than 10 chars, it is not a phone number.
		else if (fld.value.length < 10) {
			blnResult = false;
		}
		
		//For each character in the field value, check if it is a valid character for a phone number.
		for(var i=0; i < fld.value.length; i++) {
			aChar = fld.value.charAt(i);
			
			if (!(aChar=="(" || aChar==")" || aChar=="-"  || aChar==" " || (parseInt(aChar, 10) >= 0 && parseInt(aChar, 10) <= 9 ))) {
				blnResult = false;
			}
		}
	
		if (blnResult == false) {
			alert('Please enter a valid ' + validateThis.displayName + '.');
			fld.focus();
		}
		
		return blnResult;
	}
	
	
	function validate_password(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		fld2 = eval('frm.' + validateThis.fieldName + '2');		
		if (fld.value!=fld2.value) {
			if (validateThis.altMessage == '') {
				alert('The two passwords entered do not match.');
			} else {
				alert(validateThis.altMessage);
			}
			fld.focus();
			return false;
		}
		return true;
	}
	

	function validate_email (frm, validateThis) {
		var fld = eval('frm.' + validateThis.fieldName);
		fld.value = fld.value.replace(/\s/g, "");
		// exit with success if blank...
		// use an additional 'text' validation to make it a required field
		if (fld.value=='') return true;
		// test email if there's a value
		if (!testEmail(fld.value)) {
			if (validateThis.altMessage == '') {
				alert('Please enter a valid email address.');
			} else {
				alert(validateThis.altMessage);
			}
			fld.focus();
			return false;
		}
		return true;
	}

	
	function validate_credit(frm, validateThis) {
		if (!CheckCardNumber(frm)) {
			if (validateThis.altMessage == '') {
				alert('Please enter a valid credit card number.');
			} else {
				alert(validateThis.altMessage);
			}
			frm.fld_credit_number.focus();
			return false;
		} else {
			return true;
		}
	}

	function validate_text(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		if (fld.value=="") {
			if (validateThis.altMessage == '') {
				alert('Please enter a value for ' + validateThis.displayName + '.');
			} else {
				alert(validateThis.altMessage);
			}
			fld.focus();
			return false;
		}
		return true;
	}

	function validate_maxlength(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		if (fld.value.length>validateThis.altMessage) {
			alert('The value in the ' + validateThis.displayName + ' field is too long. The maximum length is ' + validateThis.altMessage + ' characters.');
			fld.focus();
			return false;
		}
		return true;
	}
	
	function validate_minlength(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		if (fld.value.length<validateThis.altMessage) {
			alert('The value in the ' + validateThis.displayName + ' field is not complete. Please enter at least ' + validateThis.altMessage + ' characters.');
			fld.focus();
			return false;
		}
		return true;
	}

	function validate_radio(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		
		if (fld.length == null) {
			if (fld.checked) return true;
		}
		
		for (i=0 ; i<fld.length ; i++) {
			if (fld[i].checked) return true; 
		}
		if (validateThis.altMessage == '') {
			alert('Please select an option for ' + validateThis.displayName + '.');
		} else { 
			alert(validateThis.altMessage);
		}
		fld[0].focus();
		return false;
	}
	
	
		function validate_checkBox (frm, validateThis) {
		oneChecked = false;
		fld = eval('frm.' + validateThis.fieldName);		 
		//if it's just one checkbox
		if (fld.length == null) {
			if (fld.checked) oneChecked = true;
		}
		// if it's an array of checkboxes
		else {
			for (var x = 0; x < fld.length; x++) {
				if (fld[x].checked) {
					oneChecked = true;
				}
			}
		}
		
		if (!oneChecked) {
			if (validateThis.altMessage == '') {
				alert('Please check this box under ' + validateThis.displayName + '.');
			} else {
				alert(validateThis.altMessage);
			}
			return false;
		}
		return true;
	}
	
	function validate_checkOne (frm, validateThis) {
		oneChecked = false;
		fld = eval('frm.' + validateThis.fieldName);
		
		//if it's just one checkbox
		if (fld.length == null) {
			if (fld.checked) oneChecked = true;
		}
		// if it's an array of checkboxes
		else {
			for (var x = 0; x < fld.length; x++) {
				if (fld[x].checked) {
					oneChecked = true;
				}
			}
		}
		
		if (!oneChecked) {
			if (validateThis.altMessage == '') {
				alert('Please check at least one box under ' + validateThis.displayName + '.');
			} else {
				alert(validateThis.altMessage);
			}
			return false;
		}
		return true;
	}

	function validate_select (frm, validateThis) {
		oneChecked = false;
		fld = eval('frm.' + validateThis.fieldName);

		if (fld[fld.selectedIndex].value == '') {
			if (validateThis.altMessage == '') {
				alert('Please make a selection for ' + validateThis.displayName + '.');				
			} else {
				alert(validateThis.altMessage);
			}
			fld.focus();
			return false;
		}
		return true;
	}

	function validate_multiselect (frm, validateThis) {
		oneChecked = false;
		fld = eval('frm.' + validateThis.fieldName);
		if (fld.length==0) return true;
		oneIsSelected = false;
		for (i=0 ; i<fld.length ; i++) {
			o = fld.options[i];
			if (o.selected) {
				oneIsSelected = true;
				break;
			}
		}
		if (!oneIsSelected) {
			if (validateThis.altMessage == '') {
				alert('Please make a selection for ' + validateThis.displayName + '.');				
			} else {
				alert(validateThis.altMessage);
			}
			fld.focus();
			return false;
		}
		return true;
	}

	function validate_ssn(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		if (fld.value.length!=9) {
			//alert('The value in the ' + validateThis.displayName + ' field is too long. The maximum length is ' + validateThis.altMessage + ' characters.');
			alert('Please enter a valid 9 digit Social Security Number.');
			fld.focus();
			return false;
		}
		return true;
	}
		
	function validate_date(frm, validateThis) {
		//var strDatestyle = "EU";  //European date style
		var strDatestyle = "Short"; // MM/DD/YYYY
		//var strDatestyle ="Long";// Month, Day, Year
	
		fld = eval('frm.' + validateThis.fieldName);
		if (checkDate(fld, strDatestyle) == false) {
			fld.select();
			if (validateThis.altMessage == '') {
				alert('The date entered for ' + validateThis.displayName + ' is invalid.  Please try again.');
			} else {
				alert(validateThis.altMessage);
			}
			
			fld.focus();
			return false;
		}
		else {
			return true;
		}
	}
	
	function validate_time(frm, validateThis) {
		var timefield = validateThis.fieldName;
		if (checkTime(validateThis.fieldName) == false) {
			timefield.select();
			alert('The time entered for ' + validateThis.displayName + ' is invalid.  Please try again.');
			timefield.focus();
			return false;
		}
		else {
			return true;
		}
	}
		
	function validate_month(frm, validateThis) {
		//var strDatestyle = "EU";  //European date style
		var strDatestyle = "Short"; 
		//var strDatestyle ="Long";
	
		var monthfield = validateThis.fieldName;
		if (checkMonth(validateThis.fieldName, strDatestyle) == false) {
			monthfield.select();
			alert('The month entered for ' + validateThis.displayName + ' is invalid.  Please try again.');
			monthfield.focus();
			return false;
		}
		else {
			return true;
		}
	}
	function validate_year(frm, validateThis) {
		var yearfield = validateThis.fieldName;
		if (checkYear(validateThis.fieldName) == false) {
			yearfield.select();
			alert('The year entered for ' + validateThis.displayName + ' is invalid.  Please try again.');
			yearfield.focus();
			return false;
		}
		else {
			return true;
		}
	}

	//Fixes OEM characters to Ansi characters
	function validate_ansi2oem(frm,validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		fld.value = ansi2oem ( fld.value );	
		
		return true;
	}

	//conditionalOther' - checks that fieldName has a value, if the expression in altMessage (fieldname=value) is true. 
	function validate_conditionalOther(frm, validateThis) {
	    
		var arrAltMsg = validateThis.altMessage.split('=');
		var bFail = false;

		fldFirst = eval('frm.' + arrAltMsg[0]);			
		fldSecond = eval('frm.' + validateThis.fieldName);

		//alert (getValueFromField(fldFirst));
		//alert (getValueFromField(fldSecond));
		
		var fldPaymentMethod = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_paymentmethodPO');
        if (fldPaymentMethod.checked ) return true; 
				
		if (isNaN(arrAltMsg[1])) {
			if (arrAltMsg[1].toLowerCase == getValueFromField(fldFirst)) { 
				if (getValueFromField(fldSecond) == null) { bFail = true; }
			}
		}
		else {
			if (arrAltMsg[1] == getValueFromField(fldFirst)) {
				if (getValueFromField(fldSecond) == null) { bFail = true; }
			}
		}
		
		if (bFail == true) {
			alert('Please enter a value for ' + validateThis.displayName + '.');
			if (fldSecond.type == null) {
				fldSecond[0].focus();
			}
			else {
				fldSecond.focus();
			}
			return false;
		}
		
		return true;
	}
	
	//conditionalSelect' - checks that select fieldName has a value not equal to "", if the expression in altMessage (fieldname=value) is true. 
	function validate_conditionalSelect(frm, validateThis) {
		var arrAltMsg = validateThis.altMessage.split('=');
		var bFail = false;

		fldFirst = eval('frm.' + arrAltMsg[0]);			
		fldSecond = eval('frm.' + validateThis.fieldName);
		
		//alert (getValueFromField(fldFirst));
		//alert (getValueFromField(fldSecond));
		
		if (isNaN(arrAltMsg[1])) {
			if (arrAltMsg[1].toLowerCase == getValueFromField(fldFirst)) { 
				if (getValueFromField(fldSecond) == '') { bFail = true; }
			}
		}
		else {
			if (arrAltMsg[1] == getValueFromField(fldFirst)) {
				if (getValueFromField(fldSecond) == '') { bFail = true; }
			}
		}
		
		if (bFail == true) {
			alert('Please make a selection for ' + validateThis.displayName + '.');
			if (fldSecond.type == null) {
				fldSecond[0].focus();
			}
			else {
				fldSecond.focus();
			}
			return false;
		}
		
		return true;
	}		
	//************ Supporting Functions ********************
	
	function getValueFromField(fld) {
		var vReturn 
		
		//if type is null, then the field is an array of elements
		//ex. checkboxes, radio buttons. 
		if (fld.type == null) {
			for (var x = 0; x < fld.length; x++) {

				if (fld[x].checked == true) {
					vReturn = fld[x].value;
				}
			}
		}		
		else {
			// At this point, we know that the field is not an array of elements.
			// However, it could be a select box which has an array of values.
			switch (fld.type) {
				case 'select-multiple':
					for (var x = 0; x < fld.length; x++) {
						if (fld[x].selected == true) {
							vReturn = fld[x].value;
						}
					}				
				break;
				
				case 'select-one':
					vReturn = fld[fld.selectedIndex].value
				break;
				
				//at this point, the field is either a textbox or a textarea
				default:
					if (fld.value.length == 0) {
						vReturn = null;
					}
					else {
						vReturn = fld.value
					}
			}
		}

		// now we have the value from the field, whether its a checked box, or a selected element, or typed in text, etc
		// for comparison purposes, make it all lowercase if its not a number.		
		if (vReturn == null) {
			//vReturn = '';
		}
		else if (isNaN(vReturn)) {
			vReturn = vReturn.toLowerCase();
		}

		return vReturn;	
	}
	
	// Used in validate_email
	function testEmail(email) {
		var firstChar, lastChar, atPos, dotPos, legalChars;
		legalChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
		firstChar = email.charAt(0);
		if (legalChars.indexOf(firstChar)==-1) return false;
		lastChar = email.charAt(email.length-1);
		if (legalChars.indexOf(lastChar)==-1) return false;
		atPos = email.indexOf('@');
		if (atPos==-1) return false;
		dotPos = email.indexOf('.',atPos);
		if (dotPos==-1) return false;
		if (dotPos==atPos+1) return false;
		return true;
	}
	
	//Used in validate_month, validate_date
	function checkMonth(strMonth, strDatestyle) {
		var intMonth;
		var strMonthArray = new Array(12);
		var strLongMonthArray = new Array(12);
		
		strLongMonthArray[0] = "January";
		strLongMonthArray[1] = "February";
		strLongMonthArray[2] = "March";
		strLongMonthArray[3] = "April";
		strLongMonthArray[4] = "May";
		strLongMonthArray[5] = "June";
		strLongMonthArray[6] = "July";
		strLongMonthArray[7] = "August";
		strLongMonthArray[8] = "September";
		strLongMonthArray[9] = "October";
		strLongMonthArray[10] = "November";
		strLongMonthArray[11] = "December";		
		
		strMonthArray[0] = "Jan";
		strMonthArray[1] = "Feb";
		strMonthArray[2] = "Mar";
		strMonthArray[3] = "Apr";
		strMonthArray[4] = "May";
		strMonthArray[5] = "Jun";
		strMonthArray[6] = "Jul";
		strMonthArray[7] = "Aug";
		strMonthArray[8] = "Sep";
		strMonthArray[9] = "Oct";
		strMonthArray[10] = "Nov";
		strMonthArray[11] = "Dec";
		
		
		intMonth = parseInt(strMonth, 10);
		
		//If intMonth is not a number, check the array of month abbreviations.
		if (isNaN(intMonth)) {
			//If month is not a number, and we're validation against a short date style, validate = false
			if (strDatestyle == "Short") { return false}
			
			//Check Month abbreviation array first
			for (i = 0;i<12;i++) {
				if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
					intMonth = i+1;
					//If the month is found, set strMonth to its numeric equivalent
					strMonth = strMonthArray[i];
					i = 12;
		  		}
			}
		
			//Check full Month name array next
			for (i = 0;i<12;i++) {
				if (strMonth.toUpperCase() == strLongMonthArray[i].toUpperCase()) {
					intMonth = i+1;
					//If the month is found, set strMonth to its numeric equivalent
					strMonth = strLongMonthArray[i];
					i = 12;
		  		}
			}		
			//if intMonth is still not a number, then it was not found in either array.
			if (isNaN(intMonth)) return false;
		}
		
		//At this point in the function, intMonth must be a number, check to see
		//it falls in the valid range.
		if (intMonth>12 || intMonth<1) return false;
		
		return true;
	}

	//Used in validate_year, validate_date	
	function checkYear(strYear) {
		
		//Assume 2 digit years are 2000+
		if (strYear.length == 2) strYear = '20' + strYear;
		
		if (strYear.length !=4) return false;
		
		if (isNaN(strYear)) return false;	
		
		return true;
	}
	
	//Used in validate_date	
	function checkDate(datefield, strDatestyle) {

		
		var strDate, strDateArray, strDay, strMonth, strYear, intday;
		var intMonth, intYear
		
		var booFound = false;
		var strSeparatorArray = new Array("-"," ","/",".");
		var intElementNr;
		var strMonthArray = new Array(12);
		
		strMonthArray[0] = "Jan";
		strMonthArray[1] = "Feb";
		strMonthArray[2] = "Mar";
		strMonthArray[3] = "Apr";
		strMonthArray[4] = "May";
		strMonthArray[5] = "Jun";
		strMonthArray[6] = "Jul";
		strMonthArray[7] = "Aug";
		strMonthArray[8] = "Sep";
		strMonthArray[9] = "Oct";
		strMonthArray[10] = "Nov";
		strMonthArray[11] = "Dec";
		
		strDate = datefield.value;
		
		//This checks agains valid dates, if something is present. Use validate_text to validate required values
		if (strDate.length < 1) return true;
		
		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3) {
					return false;
				}
				else {
					strMonth = strDateArray[0];
					strDay = strDateArray[1];
					strYear = strDateArray[2];
				}
				booFound = true;
			}
		}

		//If we have not found the date elements at this point, then the date is not in a recognizable
		//format. If we are validating against a specific date format (Short, Long), then return false.		
		//Otherwise, assume first 2 chars are the month, next 2 are the day, and last 4 are the year.
		if (booFound == false) {
			if (strDatestyle == "Short" || strDatestyle == "Long") {
				return false;
		   	} else {
				if (strDate.length>5) {
					strMonth = strDate.substr(0, 2);
					strDay = strDate.substr(2, 2);
					strYear = strDate.substr(4);
				}
			}
		}
		
		// EU style
		if (strDatestyle == "EU") {
			strTemp = strDay;
			strDay = strMonth;
			strMonth = strTemp;
		}
		
		intday = parseInt(strDay, 10);
		
		if (isNaN(intday)) return false;
		
		//Call checkMonth Function to determine if month is valid.
		if (checkMonth(strMonth, strDatestyle) == false) return false;
		
		//Call checkYear Function to determine if year is valid.
		if (checkYear(strYear) == false) return false;
		
		intMonth = parseInt(strMonth, 10);
		
		intYear = parseInt(strYear, 10);
	
		if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
			err = 6;
			return false;
		}
		
		if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
			err = 7;
			return false;
		}
		
		if (intMonth == 2) {
			if (intday < 1) return false;

			if (LeapYear(intYear) == true) {
				if (intday > 29) return false;
			}
			else {
				if (intday > 28) return false;
			}
		}
		
		
		return true;
	}
		
	//Used in validate_date		
	function LeapYear(intYear) {
		if (intYear % 100 == 0) {
			if (intYear % 400 == 0) { return true; }
		}
		else {
			if ((intYear % 4) == 0) { return true; }
		}
		
		return false;
	}

	//Used in validate_time		
	function checkTime(timeStr) {
		// Checks if time is in HH:MM:SS AM/PM format.
		// The seconds and AM/PM are optional.
		
		var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
		
		var matchArray = timeStr.match(timePat);
		
		if (matchArray == null) return false;
	
		hour = matchArray[1];
		minute = matchArray[2];
		second = matchArray[4];
		ampm = matchArray[6];
		
		if (second=="")  second = null;
		
		if (ampm=="") ampm = null;
		
		if (hour < 0  || hour > 23) return false;
				
		if  (hour > 12 && ampm != null) return false;
	
		if (minute<0 || minute > 59) return false;
	
		if (second != null && (second < 0 || second > 59)) return false;
	
		return true;
	}

    function validate_creditcard(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		var ccNum = fld.value;
        var clen = new Array( ccNum.length );
        var n = 0,sum = 0;
        
        var fldPaymentMethod = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_paymentmethodPO');
        
		if (fldPaymentMethod.checked ) return true; 
		
        for( n = 0; n < ccNum.length; ++n )
        {
              clen [n] = parseInt ( ccNum.charAt(n) );
        }
        for( n = clen.length -2; n >= 0; n-=2 )
        {
            clen [n] *= 2;
            if( clen [n] > 9 )
                 clen [n]-=9;
        }
        for( n = 0; n < clen.length; ++n )
        {
          sum += clen [n];
        }       
                   
        if((sum%10)==0)
        {
          return true;
         }
         else
         {
           alert('Invalid credit card number.');
           fld.value = "";
           fld.focus();
		   return false;
         }                           			
	}
	
	function validate_expirationdate(frm, validateThis) {
		fld = eval('frm.' + validateThis.fieldName);
		var fldYear = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_ExpirationYear');
		
		var fldPaymentMethod = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_paymentmethodPO');			       
			if (fldPaymentMethod.checked ) return true; 
					
		today = new Date();		
        expiry = new Date(fldYear.value,fld.value,0,0,0);        
        if (today.getTime() > expiry.getTime())
        {
            alert('Please enter a valid expiration date.');
            return false;
        }
        else
            return true;		            		
	}
	
	function validate_confirmwindow(frm, validateThis) {
	    fld = eval('frm.' + validateThis.fieldName);
	    
		var fldPaymentMethod = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_paymentmethodPO');
		if (fldPaymentMethod.checked ) return true; 
		
		var fldPaymentMethodCC = eval('frm.ctl00_ctl00_cphMasterPageContent_cphTwoColumnPageContent_classregistration1_paymentmethodCC');		
		if (fldPaymentMethodCC.checked )
		{
		    var r=confirm("Are you sure you want to charge $ " + fld.value + " to your credit card?");
            if (r==true)
                return true;
            else
                return false;
		} 							
	}
