function verifyRegister(Form) {
	
      
    if(Form.contactEmail.value=="") {
    	alert("Please enter your email address.");
        Form.contactEmail.focus();
        return false;
    }
    
    if(!isValidEmail(Form.contactEmail.value)) {
    	alert("Please enter a valid email address.");
        Form.contactEmail.focus();
        return false;
    }
	
	 
    if(Form.prefNo.value=="") {
    	alert("Please enter your preferred contact number.");
        Form.prefNo.focus();
        return false;
    }

    if(Form.prefNo.value !="") {
    	if(!isPhoneString(Form.prefNo.value)) {
    		alert("Please enter a valid Preferred Contact Number.");
        	Form.prefNo.focus();
       	 	return false;
        }	
    }   
    
    if(Form.userName.value=="")
	{
		alert("Please enter your username");	
		Form.userName.focus();
		return false;
	}
    
    if(Form.userName.value.length < 3)
	{
		alert("Username must be at least 3 characters");	
		Form.userName.focus();
		return false;
	}
    
    var idHolder = Form.userName.value;
    for (var i=0; i < idHolder.length; i++){
     if ((!((idHolder.charAt(i) >= "0") && (idHolder.charAt(i) <= "9"))) &&
         (!((idHolder.charAt(i) >= "a") && (idHolder.charAt(i) <= "z"))) &&
         (!((idHolder.charAt(i) >= "A") && (idHolder.charAt(i) <= "Z")))) {
         alert("Only characters and numbers are accepted as Username.");
         Form.userName.focus();
         return false;
     }
    }
    
    
    if (Form.password.value=="") {
    	alert("Please enter your password.");
        Form.password.focus();
        return false;
    }
    
    if (Form.confirmPassword.value=="") {
    	alert("Please enter your confirm password.");
        Form.confirmPassword.focus();
        return false;
    }
    
    if (Form.password.value != Form.confirmPassword.value) {
		alert ("The password and confirm password must be the same. Please re-enter your password");
 		Form.password.focus();
		return false;
    }
    
    if (Form.password.value.length < 6){
        alert ("Password must be between 6 to 15 characters.");
        Form.password.focus();
        return false;
    }
    
    var holder = Form.password.value;
    for (var i=0; i < holder.length; i++){
     if ((!((holder.charAt(i) >= "0") && (holder.charAt(i) <= "9"))) &&
         (!((holder.charAt(i) >= "a") && (holder.charAt(i) <= "z"))) &&
         (!((holder.charAt(i) >= "A") && (holder.charAt(i) <= "Z")))) {
         alert("Only characters and numbers are accepted as password.");
         Form.password.focus();
         return false;
     }
    }
    
   

    return true;
    
}

function verifyUpdate(Form) {
	
    if (Form.Surname.value=="") {
    	alert("Please enter your surname.");
        Form.Surname.focus();
        return false;
    }    
    if (Form.Givenname.value=="") {
    	alert("Please enter your given name.");
        Form.Givenname.focus();
        return false;
    }

    if(Form.Age.value=="") {
    	alert("Please enter your age.");
        Form.Age.focus();
        return false;
    }
    
    if(!isNumberString(Form.Age.value)) {
    	alert("Please enter a valid age.");
        Form.Age.focus();
        return false;
    }

	if(Form.Age.value.length > 3)
	{
		alert("Please enter a valid age.");
		Form.Age.focus();
		return false;
	}
	
	if (Form.Race.value=="0") {
		alert("Please enter your race.");	
		Form.Race.focus();
		return false;
	}
	
	if (Form.Occupation.value=="0") {
		alert("Please enter your occupation.");	
		Form.Occupation.focus();
		return false;
	}

    if (Form.addressL1.value=="") {
    	alert("Please enter your address line.");
        Form.address1.focus();
        return false;
    }
    
    if(Form.zip.value=="") {
    	alert("Please enter your postcode.");
        Form.zip.focus();
        return false;
    }
    
    if(!isNumberString(Form.zip.value)) {
    	alert("Please enter a valid post code.");
        Form.zip.focus();
        return false;
    }
        
    if(Form.city.value=="") {
    	alert("Please enter your city.");
        Form.city.focus();
        return false;
    }

    if(isNumberString(Form.city.value)) {
    	alert("Please enter a valid city.");
        Form.city.focus();
        return false;
    }
        
	if (Form.country.value=="0") {
		alert("Please enter your country.");	
		Form.country.focus();
		return false;
	}	
	
	if (Form.country.value=="Malaysia" && Form.state.value=="0") {
		alert("If you are in Malaysia, please enter your state.");	
		Form.state.focus();
		return false;
	}

    if(Form.phoneNo.value != "") {
    	if(!isPhoneString(Form.phoneNo.value)) {
    		alert("Please enter a valid Home Phone Number.");
        	Form.phoneNo.focus();
        	return false;
        }	
    }
    
    if(Form.mobileNo.value != "") {
    	if(!isPhoneString(Form.mobileNo.value)) {
    		alert("Please enter a valid Mobile Phone Number.");
        	Form.mobileNo.focus();
        	return false;
        }	
    }
    
    if(Form.faxNo.value != "") {
    	if(!isPhoneString(Form.faxNo.value)) {
    		alert("Please enter a valid Fax Number.");
        	Form.faxNo.focus();
        	return false;
        }	
    }
    
    if(Form.prefNo.value=="") {
    	alert("Please enter your preferred contact number.");
        Form.prefNo.focus();
        return false;
    }

    if(Form.prefNo.value !="") {
    	if(!isPhoneString(Form.prefNo.value)) {
    		alert("Please enter a valid Preferred Contact Number.");
        	Form.prefNo.focus();
       	 	return false;
        }	
    }   
        
    if(Form.DOB.value=="") {
    	alert("Please enter your date of birth.");
        Form.DOB.focus();
        return false;
    }
    
    if(!isDate(Form.DOB.value)) {
    	alert("Please enter a valid date of birth.");
    	Form.DOB.focus();
        return false;
    }
    
    var today = new Date();
    var dobString = Form.DOB.value;
    var userDOB = new Date(parseInt(dobString.substring(6,10)),parseInt(dobString.substring(3,5))-1,parseInt(dobString.substring(0,2)));
    if(userDOB > today) {
    	alert("Please enter a valid date of birth.");
    	Form.DOB.focus();
        return false;
    }


    if(Form.contactEmail.value=="") {
    	alert("Please enter your email address.");
        Form.contactEmail.focus();
        return false;
    }
    
    if(!isValidEmail(Form.contactEmail.value)) {
    	alert("Please enter a valid email address.");
        Form.contactEmail.focus();
        return false;
    }

/*    if (Form.REQ_iwtAuthMembership-userName.value=="") {
    	alert("Please enter your login ID.");
        Form.REQ_iwtAuthMembership-userName.focus();
        return false;
    }
    
    if (Form.REQ_iwtAuthMembership-password.value != Form.REQ_iwtAuthMembership-confirmPassword.value) {
	alert ("The password and confirm password must be the same. Please re-enter your password");
 	Form.REQ_iwtAuthMembership-password.focus();
	return false;
    }
    
    var holder = Form.REQ_iwtAuthMembership-password.value;
    var oldHolder = Form.oldPassword.value;
    
    if ((holder.length!=0) && (holder.length < 6)){
        alert ("New Password must be between 6 to 15 characters.");
        Form.REQ_iwtAuthMembership-password.focus();
        return false;
    }
    
    for (var i=0; i < holder.length; i++){
     if ((!((holder.charAt(i) >= "0") && (holder.charAt(i) <= "9"))) &&
         (!((holder.charAt(i) >= "a") && (holder.charAt(i) <= "z"))) &&
         (!((holder.charAt(i) >= "A") && (holder.charAt(i) <= "Z")))) {
         alert("Only characters and numbers are accepted as password.");
         Form.REQ_iwtAuthMembership-password.focus();
         return false;
     }
    }
    
    if ((holder.length!=0) && (oldHolder.length == 0)){
        alert ("To change your password, you must key in your old password.");
        Form.oldPassword.focus();
        return false;
    }
    
    if ((oldHolder.length!=0) && (oldHolder.length < 6)){
        alert ("Old Password must be between 6 to 15 characters.");
        Form.oldPassword.focus();
        return false;
    }
    
    for (var i=0; i < oldHolder.length; i++){
     if ((!((oldHolder.charAt(i) >= "0") && (oldHolder.charAt(i) <= "9"))) &&
         (!((oldHolder.charAt(i) >= "a") && (oldHolder.charAt(i) <= "z"))) &&
         (!((oldHolder.charAt(i) >= "A") && (oldHolder.charAt(i) <= "Z")))) {
         alert("Your old password can consist only characters and numbers.");
         Form.oldPassword.focus();
         return false;
     }
    }
    
    if ((holder.length==0) && (oldHolder.length != 0)){
        alert ("Your new password cannot be empty.");
        Form.REQ_iwtAuthMembership-password.focus();
        return false;
    }
    
    if ((holder.length!=0) && (holder == oldHolder)) {
    	alert ("The old password and new password cannot be the same.");
 	Form.REQ_iwtAuthMembership-password.focus();
	return false;
    }
    */
    if (Form.passwordHintQuestion.value=="0") {
    	alert("Please enter your password Hint Question.");
        Form.passwordHintQuestion.focus();
        return false;
    }

    if (Form.passwordHintAnswer.value=="") {
    	alert("Please enter your password Hint Answer.");
    	Form.passwordHintAnswer.focus();
    	return false;
	}

    
    return true;
    
}

function isPhoneString (InString)  
{
        if(InString.length==0) 
                return (false);
        RefString="1234567890-";
        for (Count=0; Count < InString.length; Count++)  
        {
                TempChar= InString.substring (Count, Count+1);
                if (RefString.indexOf (TempChar, 0)==-1)  
                        return (false);
        }
        return (true);
}

function isNumberString (InString)  
{
        if(InString.length==0) 
                return (false);
        RefString="1234567890";
        for (Count=0; Count < InString.length; Count++)  
        {
                TempChar= InString.substring (Count, Count+1);
                if (RefString.indexOf (TempChar, 0)==-1)  
                        return (false);
        }
        return (true);
}

function isDate(InString)
{
	var TempString = "";
	var Temp = "";
	var Year = "";
	var Month = "";
	var Day = "";

	if(InString.length != 10)
	{
	    return false;
	}
	
	for (Count=0; Count <InString.length; Count++) 
	{
		DateChar = InString.substring(Count, Count+1);
		if ((DateChar=="/") || (DateChar==",") || (DateChar==".") || (DateChar=="-"))
			TempString = TempString
		else if (DateChar == " ")
			return false;
		else
			TempString += DateChar
	}
	
	// Make sure string is number
	if (isNaN(TempString))
	{
		return false;
	}
	
	// Make sure string is correct length
	if (TempString.length != 8)
	{
		return false;
	}

	// Set vars for year and month
	Year = rightString(TempString, 4);
	Day = leftString(TempString, 2);
	Temp = leftString(TempString, 4);
	Month = rightString(Temp, 2);
	
	var Year1 = parseInt(Year);
	var Month1 = parseInt(Month);
	var Day1 = parseInt(Day);
	// Make sure the month is valid
	if (Month1 >= 13)
	{
		return false;	
	}	
	
	// Check the day for months that need 31
	if ((Month == "01") || (Month == "03") || ( Month == "05")|| (Month == "07") || (Month == "08") || (Month == "10") || (Month == "12"))
	{
		if (Day1 > 31)
		    return false;
	}

	// Check the day for months that need 30
	if ((Month == "04") || (Month == "06") || ( Month == "09")|| (Month == "11"))
	{
		if (Day1 > 30)
		 	return false;
	}

	// Deal with February and leap year
	if (Month == "02")
	{
		if ((Year1 % 4) == 0)
		{
			if(Day1 > 29)
			    return false;
		}
		if ((Year1 % 4) != 0)
		{
			if(Day1 > 28)
				return false;
		}
	}

	return true;
}

function isValidEmail (InString)
{
    if (InString.length==0)
        	return (false);
	if ( (InString.indexOf('@') == -1) || (InString.indexOf('@') != InString.lastIndexOf('@')) )
			return (false);
	if (InString.indexOf('.') == -1) 
			return (false);
	if ( (InString.lastIndexOf('.')) < (InString.indexOf('@')) )
			return (false); 

    return (true);
}

function leftString (InString, num)  
{
	OutString=InString.substring (0, num);
	return (OutString);
}

function rightString (InString, num)  
{
	OutString=InString.substring (InString.length-num, InString.length);
	return (OutString);
}

