function ValidateRegister(){	
	if(!ValidateEmail(document.frmMain.txtUserLogin.value)){
		alert("Login is not a correct email address!");
		document.frmMain.txtUserLogin.focus();
		return false;
	}
	if(!ValidateText(document.frmMain.txtFirstName.value)){
		alert("You must enter a first name!");
		document.frmMain.txtFirstName.focus();
		return false;
	}
	if(!ValidateText(document.frmMain.txtLastName.value)){
		alert("You must enter a last name!");
		document.frmMain.txtLastName.focus();
		return false;
	}
	if (!ValidatePassword(document.frmMain.txtPassword, document.frmMain.txtConfirmPassword)){
		return false;
	}
	if((document.frmMain.dateDay.value != "")||(document.frmMain.dateMonth.value != "") || (document.frmMain.dateYear.value	!= "")){
		if (!ValidateDate(document.frmMain.dateDay.value, document.frmMain.dateMonth.value, document.frmMain.dateYear.value)){
			return false;
		}	
	}
	return true;
}
function ValidateUpdate(){
	if(!ValidateEmail(document.frmMain.txtUserLogin.value)){
		alert("Login is not a correct email address!");
		document.frmMain.txtUserLogin.focus();
		return false;
	}
	if(!ValidateText(document.frmMain.txtFirstName.value)){
		alert("You must enter a first name!");
		document.frmMain.txtFirstName.focus();
		return false;
	}
	if(!ValidateText(document.frmMain.txtLastName.value)){
		alert("You must enter a last name!");
		document.frmMain.txtLastName.focus();
		return false;
	}
	if (!ValidateText(document.frmMain.txtPassword.value)){
		alert("You must enter your password!");
		document.frmMain.txtPassword.focus();
		return false;
	}
	if((document.frmMain.txtNewPassword.value != "") || (document.frmMain.txtConfirmNewPassword.value != "")){
		if (!ValidatePassword(document.frmMain.txtNewPassword, document.frmMain.txtConfirmNewPassword)){
			return false;
		}
	}
	if((document.frmMain.dateDay.value != "")||(document.frmMain.dateMonth.value != "") || (document.frmMain.dateYear.value	!= "")){
		if (!ValidateDate(document.frmMain.dateDay.value, document.frmMain.dateMonth.value, document.frmMain.dateYear.value)){
			return false;
		}	
	}
	return true;
}
function ValidateDelete(){
	if(!ValidateText(document.frmMain.txtPassword.value)){
		alert("You must enter a Password!");
		document.frmMain.txtPassword.focus();
		return false;
	}
	if(DeleteUser()){
		return true;
	}
	else{
		return false;
	}
}
function ValidateText(strText){
	if((strText == "")||(!CheckCharacters(strText))){
		return false;
	}
	return true;
}
function CheckCharacters(strText){
	var regSpc;
	var regChr;
	
	regSpc = /[<>!]/g;
	regChr = /[\w]/g;
	
	if(strText.match(regChr)){
		if(strText.match(regSpc)){
			alert("You are not allowed to enter '<, >, !' characters!");
			return false;
		}
	}
	else{
		return false;
	}
	return true;
}
function ValidateEmail(strEmailAddress){
	if (strEmailAddress == "" ||
		strEmailAddress.length > 100 ||
		!(strEmailAddress.match(new RegExp("^[^@\ ]+@[0-9A-Za-z\-\_]+([\.]([0-9A-Za-z\-\_]{1,}))+$")))) {
		return false;
	}
	return true;
}
function ValidatePassword(obj1, obj2){
	if(obj1.value.length < 4){
		alert("Password must be at least 4 characters long!");
		obj1.focus();
		return false;
	}
	if((obj1.value != obj2.value)){
		alert("Please check your Password and it's Confirmation!");
		obj1.focus();
		return false;
	}
	return true;
}
function ValidateDate(intDay, intMonth, intYear){
	var regNumber;
	var blnDay, blnMonth, blnYear, blnLeap;
	var dtDate;
	var dtUser;
	dtDate = new Date();
	dtUser = new Date(intYear, intMonth, intDay);
	
	regNumber = new RegExp("[^0-9]");	
	blnDay = regNumber.test(intDay);
	blnMonth = regNumber.test(intMonth);
	blnYear = regNumber.test(intYear);

	//check is date entered is greater than todays date
	if(dtUser > dtDate){
		alert("You can not enter a date on/after today.");
		return false;
	}

	//is it a leap year
	blnLeap = false;
	if(!IsRound(intYear/4)){
		blnLeap=true;
		if((!IsRound(intYear/100))&&(IsRound(intYear/400))){
			blnLeap = false;
		}
	}
	
	if((blnDay) || (blnMonth) || (blnYear) || (intYear <= 0) ||(intMonth <= 0) ||(intDay <= 0)){
		alert("Please enter a valid date!");
		return false;
	}
	if((intDay=="")||(intYear=="")||(intYear=="")){
		alert("Please enter a birth date");
		return false;
	}
	if((intYear < 1901)|| (intYear <= 0)){
		alert("You're not that old!");
		return false;
	}
	if((intMonth > 12)||(intYear <= 0)){
		alert("There are only 12 months in the year!");
		return false;
	}
	if(((intMonth == 12) || (intMonth == 1) || (intMonth == 3) || (intMonth == 5) || (intMonth == 7) || (intMonth == 8) || (intMonth == 10)) && (intDay > 31)){
		alert("There are only 31 days in January, March, May, July, August, October and December!");
		return false;
	}
	if(((intMonth == 4) || (intMonth == 6) || (intMonth == 9) || (intMonth == 11)) && (intDay > 30)){
		alert("There are only 30 days in April, June, September and November!");
		return false;
	}
	if((intMonth == 2) && (intDay > 28)){
			if((blnLeap)&&(intDay==29)){
				return true;
			}
			if((blnLeap)&&(intDay>29)){
				alert("There are only 29 days in February, in a leap year!");
				return false;
			}
			alert("There are only 28 days in February!");
			return false;
	}
	return true;
}

function IsRound(intIn){
	var regNumber;
	regNumber = /[\.]/g;
	return regNumber.test(intIn);
}

function DeleteUser(){
	var blnDelete;
	blnDelete = confirm("If you choose to continue your user details will be removed from the Future Scape site and you will no longer be able to login. Delete registration details?");
	return blnDelete;
}