<!--

	function CheckJoinForm(frm)
	{
		var fieldlist='';
		if (frm.FirstName.value =='') {fieldlist=fieldlist+'  First name,\n'};
	  	if (frm.LastName.value =='') {fieldlist=fieldlist+'  Last name,\n'};
		if (frm.EmailAddress.value =='') {fieldlist=fieldlist+'  email,\n'};
		if (frm.ConfirmEmailAddress.value =='') {fieldlist=fieldlist+'  Confirm email,\n'};
		if (frm.DOB.value =='') {fieldlist=fieldlist+'  Date of birth,\n'};
		if (frm.StorePreference.value =='') {fieldlist=fieldlist+'  Store preference,\n'};

	  	
	  	fieldlist = fieldlist.substr(0,(fieldlist.length - 2));
		if (fieldlist != '') {
			alert ("Please ensure the following fields are completed:\n\n" + fieldlist + ".");
			return false;
		}
		
		if (CheckEmail(frm.EmailAddress.value) == false) {return false};

		if (frm.EmailAddress.value != frm.ConfirmEmailAddress.value) {
			alert ("The email addresses provided do not match.");
			frm.ConfirmEmailAddress.focus();
			return false;
		}

		var DOBDD, DOBMM, DOBYYYY;
		var firstSlash, lastSlash;
		frm.DOB.value = frm.DOB.value.replace(/\\/, '/');
		firstSlash = frm.DOB.value.indexOf('/');
		lastSlash = frm.DOB.value.lastIndexOf('/');
		if (firstSlash==-1 || firstSlash==lastSlash)
		{
			alert ('Incorrect Date of birth format.\nCorrect format is dd/mm/yyyy')
			frm.DOB.focus()
			return false;
		}
		else
		{
			DOBDD = frm.DOB.value.substring(0, firstSlash);
			DOBMM = frm.DOB.value.substring(firstSlash + 1, lastSlash);
			DOBYYYY = frm.DOB.value.substring(lastSlash + 1, frm.DOB.value.length)

			var d = new Date();
			

			if (DOBYYYY < 1900 || DOBYYYY > d.getFullYear())
			{
				alert ('Invalid Date of birth yyyy value.');
				return false;
			}

			if (!isDate(DOBMM + '/' + DOBDD + '/' + DOBYYYY))
				return false;

			if (DOBDD.length==1) {DOBDD = '0' + DOBDD};
			if (DOBMM.length==1) {DOBMM = '0' + DOBMM};
			frm.DOB.value = DOBDD + '/' + DOBMM + '/' + DOBYYYY;
		}
	}

	function onLoadTasks(message) {
		alert(message);
		return false;
	}

	function onLoadTasks(message) {
		alert(message);
		return false;
	}

	// ******************************************************************
	// This function accepts a string variable and verifies if it is a
	// proper date or not. It validates format matching either
	// mm-dd-yyyy or mm/dd/yyyy. Then it checks to make sure the month
	// has the proper number of days, based on which month it is.
	
	// The function returns true if a valid date, false if not.
	// ******************************************************************

	function isDate(dateStr) {

		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?

		if (matchArray == null) {
			alert("Please enter Date of birth as dd/mm/yyyy.");
			return false;
		}

		month = matchArray[1]; // p@rse date into variables
		day = matchArray[3];
		year = matchArray[5];

		if (month < 1 || month > 12) { // check month range
			alert("Month must be between 1 and 12.");
			return false;
		}

		if (day < 1 || day > 31) {
			alert("Day must be between 1 and 31.");
			return false;
		}

		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			alert("Month "+month+" doesn't have 31 days!")
			return false;
		}

		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day > 29 || (day==29 && !isleap)) {
				alert("February " + year + " doesn't have " + day + " days!");
				return false;
			}
		}
		
		return true; // date is valid
	}

//-->
