function affiliate_check(theForm)

{

  if (isEmpty(theForm.afirstname))

  {

    alert("Please indicate your first name.");

	theForm.afirstname.value = "";

    theForm.afirstname.focus();

    return (false);

  }

  if (validateName(theForm.afirstname))

  {

    alert("Only characters are accepted in the name fields.");

	theForm.afirstname.value = "";

    theForm.afirstname.focus();

    return (false);

  }







  if (isEmpty(theForm.alastname))

  {

    alert("Please indicate your last name.");

	theForm.alastname.value = "";

    theForm.alastname.focus();

    return (false);

  }

  if (validateName(theForm.alastname))

  {

    alert("Only characters are accepted in the name fields.");

    theForm.alastname.focus();

	theForm.alastname.value = "";

    return (false);

  }





  if (isEmpty(theForm.awebsite))

  {

    alert("Please indicate your website address.");

	theForm.awebsite.value = "";

    theForm.awebsite.focus();

    return (false);

  }





  // Validate e-mail address

  // Check for blank / empty / spacer input

  if (isEmpty(theForm.aemail))

  {

    alert("Please indicate your email address.");

	theForm.aemail.value = "";

    theForm.aemail.focus();

    return (false);

  }

  // Allows only characters, numbers, '@', '.', '_'

  // Should conform to standard e-mail address format

  if ( !( validEmail(theForm.aemail.value) ) ) {

    alert('Please indicate a valid email address!');

	theForm.aemail.value = "";

    theForm.aemail.focus();

    return (false);	

  }





  if (isEmpty(theForm.aphone))

  {

	alert("Please enter your mobile phone number.");

	theForm.aphone.value = "";

    theForm.aphone.focus();

    return (false);

  }

  if (isNaN(theForm.aphone.value))

  {

  	alert("Please enter your phone number in numeric.");

	theForm.aphone.value ="";

	theForm.aphone.focus();

	return false;

  }





  if (isEmpty(theForm.avisitors))

  {

	alert("Please enter the monthly visitors for your website.");

	theForm.avisitors.value = "";

    theForm.avisitors.focus();

    return (false);

  }

  if (isNaN(theForm.avisitors.value))

  {

  	alert("Please enter the visitors in numeric.");

	theForm.avisitors.value ="";

	theForm.avisitors.focus();

	return false;

  }



  // Validate username

  

  if (isEmpty(theForm.ausername))

  {

    alert("Please enter your username.");

	theForm.ausername.value = "";

    theForm.ausername.focus();

    return (false);

  }

  if (theForm.ausername.value.length <3 || theForm.ausername.value.length > 20)

  {

  	alert("Username can only be 3 - 20 characters.");

	theForm.ausername.value = "";

    theForm.ausername.focus();

    return (false);

  }

  var illegalChars = /\W/;

  // allow only letters, numbers, and underscores

  if (illegalChars.test(theForm.ausername.value)) {

     alert("Only characters, numbers and underscores are accepted in the username.");

     theForm.ausername.value = "";	 

	 theForm.ausername.focus();

	 return (false);

  } 

  



  if (theForm.country.value == "#" )

  {

    alert("Please select your country.");

    return (false);

  }

  

  if (theForm.read.checked == false)

  {

  	alert("Please tick the checkbox if you agreed to our agreement.");

	return (false);

  }

    

  return (true);

}









function Login_Validator(theForm)

{

  if (theForm.username.value == "")

  {

    alert("Please enter your username");

    theForm.username.focus();

    return (false);

  }



  if (theForm.password.value == "")

  {

    alert("Please enter your password");

    theForm.password.focus();

    return (false);

  }



  return (true);

}







function LostPassword_Validator(theForm)

{

  if (theForm.email_address.value == "")

  {

    alert("Please fill your email address.");

    theForm.email_address.focus();

    return (false);

  }



  if ( !( validEmail(theForm.email_address.value) ) ) {

    alert('Please enter a valid email address!');

    theForm.email_address.focus();

    return (false);	

  }

}







function ContactUs_Validator(theForm)

{

  if (theForm.name.value == "")

  {

    alert("Please fill in your name.");

    theForm.name.focus();

    return (false);

  }



  if (theForm.email.value == "")

  {

    alert("Please fill your email address.");

    theForm.email.focus();

    return (false);

  }



  if ( !( validEmail(theForm.email.value) ) ) {

    alert('Please enter a valid email address!');

    theForm.email.focus();

    return (false);	

  }



  if (theForm.subject.value == "#" )

  {

    alert("Please select the subject");

    return (false);

  }



   if (theForm.content.value == "" )

  {

    alert("Please write your message");

    theForm.content.focus();

    return (false);

  }

	if (isEmpty(theForm.vcode))

  {

    alert("Please enter verification code.");

	theForm.vcode.value = "";

    theForm.vcode.focus();

    return (false);

  }

  //alert('Dear Valued User,\n\n You have successfully submitted your feedback. Thank You.');

  return (true);

}





// Validate the Registration Form



function Register(theForm)

{

  // Check for blank/empty or spacer input

  

  if (isEmpty(theForm.first_name))

  {

    alert("Please indicate your first name.");

	theForm.first_name.value = "";

    theForm.first_name.focus();

    return (false);

  }

  if (validateName(theForm.first_name))

  {

    alert("Only characters are accepted in the name fields.");

	theForm.first_name.value = "";

    theForm.first_name.focus();

    return (false);

  }

  



  // Validate Last Name

  

  if (isEmpty(theForm.last_name))

  {

    alert("Please indicate your last name.");

	theForm.last_name.value = "";

    theForm.last_name.focus();

    return (false);

  }

  if (validateName(theForm.last_name))

  {

    alert("Only characters are accepted in the name fields.");

    theForm.last_name.focus();

	theForm.last_name.value = "";

    return (false);

  }





  // Validate if gender is specified

  

  genderoption = -1

  for (i=0;i<theForm.gender.length;i++){

	if (theForm.gender[i].checked){

		genderoption = i

	}

  }

  if (genderoption == -1)

  {

    alert("Please indicate your gender.");

    return (false);

   }





  // Validate the year format

  

  /*clear out any spacer characters, such as parentheses, dashes, spaces, 

  and dots. We can do this with a regular expression and the replace() 

  method, replacing anything that matches our regular expression with a null string. 

  */

  var yystripped = theForm.yy.value.replace(/[\(\)\.\-\ ]/g, '');

  //strip out acceptable non-numeric characters



  if (yystripped == "")

  {

	alert ("Please indicate your birth year.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (isNaN(yystripped))

  {

	alert("Please indicate your birth year in numeric.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (yystripped > 1992)

  {

  	alert("You must be at least 18 years old to be eligible for registration.");

	theForm.yy.focus()

	return false;

  }

  if (yystripped.length < 4)

  {

  	alert("Please indicate your birth year in 4 digits.");

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  

  

  // Validate e-mail address

  // Check for blank / empty / spacer input

  if (isEmpty(theForm.email_address))

  {

    alert("Please indicate your email address.");

	theForm.email_address.value = "";

    theForm.email_address.focus();

    return (false);

  }

  // Allows only characters, numbers, '@', '.', '_'

  // Should conform to standard e-mail address format

  if ( !( validEmail(theForm.email_address.value) ) ) {

    alert('Please indicate a valid email address!');

	theForm.email_address.value = "";

    theForm.email_address.focus();

    return (false);	

  }





  // Validate username

  

  if (isEmpty(theForm.username))

  {

    alert("Please enter your username.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  if (theForm.username.value.length <3 || theForm.username.value.length > 20)

  {

  	alert("Username can only be 3 - 20 characters.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  var illegalChars = /\W/;

  // allow only letters, numbers, and underscores

  if (illegalChars.test(theForm.username.value)) {

     alert("Only characters, numbers and underscores are accepted in the username.");

     theForm.username.value = "";	 

	 theForm.username.focus();

	 return (false);

  } 



  

  // Validate if country is specified

  if (theForm.country.value == "#" )

  {

    alert("Please select your country.");

    return (false);

  }

    

  // Validate if education level is specified

  if (theForm.education.value == "#" )

  {

    alert("Please indicate your education level.");

    return (false);

  }



  // Validate if profession is specified

  if (theForm.profession.value == "#" )

  {

    alert("Please indicate your profession.");

    return (false);

  }

 

  //alert('Dear Valued User,\n\n You have successfully submitted your application. Thank You.');

  return (true);

}





function Register_check(theForm)

{



  if (isEmpty(theForm.vcode))

  {

    alert("Please enter verification code.");

	theForm.vcode.value = "";

    theForm.vcode.focus();

    return (false);

  }





  if (isEmpty(theForm.first_name))

  {

    alert("Please indicate your first name.");

	theForm.first_name.value = "";

    theForm.first_name.focus();

    return (false);

  }

  if (validateName(theForm.first_name))

  {

    alert("Only characters are accepted in the name fields.");

	theForm.first_name.value = "";

    theForm.first_name.focus();

    return (false);

  }







  if (isEmpty(theForm.last_name))

  {

    alert("Please indicate your last name.");

	theForm.last_name.value = "";

    theForm.last_name.focus();

    return (false);

  }

  if (validateName(theForm.last_name))

  {

    alert("Only characters are accepted in the name fields.");

    theForm.last_name.focus();

	theForm.last_name.value = "";

    return (false);

  }





  // Validate if gender is specified

  

  genderoption = -1

  for (i=0;i<theForm.gender.length;i++){

	if (theForm.gender[i].checked){

		genderoption = i

	}

  }

  if (genderoption == -1)

  {

    alert("Please indicate your gender.");

    return (false);

   }





  // Validate the year format

  

  /*clear out any spacer characters, such as parentheses, dashes, spaces, 

  and dots. We can do this with a regular expression and the replace() 

  method, replacing anything that matches our regular expression with a null string. 

  */

  var yystripped = theForm.yy.value.replace(/[\(\)\.\-\ ]/g, '');

  //strip out acceptable non-numeric characters



  if (yystripped == "")

  {

	alert ("Please indicate your birth year.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (isNaN(yystripped))

  {

	alert("Please indicate your birth year in numeric.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (yystripped > 1992)

  {

  	alert("You must be at least 18 years old to be eligible for registration.");

	theForm.yy.focus()

	return false;

  }

  if (yystripped.length < 4)

  {

  	alert("Please indicate your birth year in 4 digits.");

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }





  // Validate e-mail address

  // Check for blank / empty / spacer input

  if (isEmpty(theForm.email_address))

  {

    alert("Please indicate your email address.");

	theForm.email_address.value = "";

    theForm.email_address.focus();

    return (false);

  }

  // Allows only characters, numbers, '@', '.', '_'

  // Should conform to standard e-mail address format

  if ( !( validEmail(theForm.email_address.value) ) ) {

    alert('Please indicate a valid email address!');

	theForm.email_address.value = "";

    theForm.email_address.focus();

    return (false);	

  }

  if (theForm.email_address.value != theForm.email_address2.value)

  {

    alert("Please ensure you enter correct email address");

	theForm.email_address.value = "";

	theForm.email_address2.value = "";

    theForm.email_address.focus();

    return (false);

  }







  if (isEmpty(theForm.hp))

  {

	alert("Please enter your mobile phone number.");

	theForm.hp.value = "";

    theForm.hp.focus();

    return (false);

  }

  if (isNaN(theForm.hp.value))

  {

  	alert("Please enter your mobile phone number in numeric.");

	theForm.hp.value ="";

	theForm.hp.focus();

	return false;

  }



  // Validate username

  

  if (isEmpty(theForm.username))

  {

    alert("Please enter your username.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  if (theForm.username.value.length <3 || theForm.username.value.length > 20)

  {

  	alert("Username can only be 3 - 20 characters.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  var illegalChars = /\W/;

  // allow only letters, numbers, and underscores

  if (illegalChars.test(theForm.username.value)) {

     alert("Only characters, numbers and underscores are accepted in the username.");

     theForm.username.value = "";	 

	 theForm.username.focus();

	 return (false);

  } 



  // Validate password

  

  if (isEmpty(theForm.password))

  {

    alert("Please enter your upassword.");

  theForm.password.value = "";

    theForm.password.focus();

    return (false);

  }

  if (theForm.password.value.length <6 || theForm.password.value.length > 30)

  {

    alert("Password can only be 6 - 30 characters.");

  theForm.password.value = "";

    theForm.password.focus();

    return (false);

  }

  var illegalChars = /\W/;

  // allow only letters, numbers, and underscores

  if (illegalChars.test(theForm.password.value)) {

     alert("Only characters, numbers and underscores are accepted in the password.");

     theForm.password.value = "";   

   theForm.password.focus();

   return (false);

  } 

  

  if(theForm.password.value != theForm.password2.value) {

    alert("Your passwords do not match, please enter the same password in both password and pasword re-type fields");

    theForm.password.focus();

    return (false);

  }



  if (theForm.country.value == "#" )

  {

    alert("Please select your country.");

    return (false);

  }





  // Validate if education level is specified

  if (theForm.education.value == "#" )

  {

    alert("Please indicate your education level.");

    return (false);

  }



  // Validate if profession is specified

  if (theForm.profession.value == "#" )

  {

    alert("Please indicate your profession.");

    return (false);

  }

	/*

  if (theForm.bank_name.value == "")

  {

    alert("Please indicate the name of your bank. E.g. OCBC, POSBank, UOB etc.");

    theForm.bank_name.focus();

    return (false);

  }



  if (theForm.bank_initial.value == "")

  {

    alert("Please indicate your bank initial for Internet Banking. Put 'nil' if none.");

    theForm.bank_initial.focus();

    return (false);

  }



  paymentoption = -1

  for (i=0;i<theForm.payment.length;i++){

	if (theForm.payment[i].checked){

		paymentoption = i

	}

  }



  if (paymentoption == -1)

  {

    alert("Please indicate payment method.");

    return (false);

   }*/





  if (theForm.subscription_mode.value == "#" )

  {

    alert("Please select the subscription mode.");

    return (false);

  }







  bookmakeroption = -1

  for (i=0;i<theForm.bookmaker.length;i++){

	if (theForm.bookmaker[i].checked){

		bookmakeroption = i

	}

  }

  if (bookmakeroption == -1)

  {

    alert("Please indicate your bookmaker.");

    return (false);	

  }







  if (theForm.betting_stakes.value == "#")

  {

    alert("Please indicate your average betting stakes");

    return (false);	

  }

  if (theForm.how_did_you_know_us.value == "#")

  {

    alert("Please indicate how did you hear about us");

    return (false);	

  }



/*  if (theForm.remarks.value == "" )

  {

    alert("Please give us your feedback or queries if any. Put 'nil' if none.");

    theForm.remarks.focus();

    return (false);

  }*/

  

  if (theForm.read.checked == false)

  {

  	alert("Please tick the checkbox if you agreed to our agreement.");

	return (false);

  }

    

  //alert('Dear Valued User,\n\n You have successfully submitted your application. Thank You.');

  return (true);

}





// Determine if the value input is empty



function isEmpty(str){

    strRE = new RegExp( );

    strRE.compile( '^[\s ]*$', 'gi' );

    return strRE.test( str.value );

} 



// Validate name input, can only contain characters.



function validateName(field) {

	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "			// valid name input

	var ok = "yes";

	var temp;

	for (var i=0; i<field.value.length; i++) {

		temp = "" + field.value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";

	}

	if (ok == "no") {

		return (true);

	}

}





function recommend(theForm) 

{



  if (theForm.Name.value == "")

  {

	alert("Please fill in your name.");

	theForm.Name.focus();

	return (false);

  }



  if (theForm.Email.value == "")

  {

	alert("Please fill in your e-mail address.");

	theForm.Email.focus();

	return (false);

  }



  if ( !( validEmail(theForm.Email.value) ) ) {

    alert('Please enter a valid email address!');

    theForm.Email.focus();

    return (false);	

  }





  var formObj;

  formObj = theForm.elements['f[]'];



	if(formObj.length)

	{	

		for(i=0;i<formObj.length;i++)

		{

			if(formObj[i].value=="")

			{

				alert("Enter your friends E-mail address");

				formObj[i].focus();

				return false;

			}



		}

	}

	else

	{

		if(formObj.value=="")

			{

				alert("Enter your friends E-mail address");

				formObj.focus();

				return false;

			}	



	}



  alert('Dear Valued User,\n\n You have successfully submitted the form. Thank You.');

  return (true);

}





function validEmail(email) {



	invalidChars = " /:"



	if (email == "") {

		return (false);

	}



	for (i=0; i < invalidChars.length; i++) {

		badChar = invalidChars.charAt(i)

		if (email.indexOf(badChar,0) != -1) {

			return (false);

		}

	}



	atPos = email.indexOf("@", 1)

	if (atPos == -1) {

		return (false);

	}



	//if (email.indexOf("@", atPos + 1) != -1) {

	//	return (false);

	//}



	periodPos = email.indexOf(".", atPos)

	if (periodPos == -1) {

		return (false);

	}



	if (periodPos + 3 > email.length) {

		return (false);

	}



	return (true);

}





































// Validate the Add Member Form



function finalRegister(theForm)

{

  // Check for blank/empty or spacer input

  

  if (isEmpty(theForm.first_name1))

  {

    alert("Please indicate the first name.");

	theForm.first_name1.value = "";

    theForm.first_name1.focus();

    return (false);

  }

  if (validateName(theForm.first_name1))

  {

    alert("Only characters are accepted in the name fields.");

	theForm.first_name1.value = "";

    theForm.first_name1.focus();

    return (false);

  }

  



  // Validate Last Name

  

  if (isEmpty(theForm.last_name1))

  {

    alert("Please indicate the last name.");

	theForm.last_name1.value = "";

    theForm.last_name1.focus();

    return (false);

  }

  if (validateName(theForm.last_name1))

  {

    alert("Only characters are accepted in the name fields.");

    theForm.last_name1.focus();

	theForm.last_name1.value = "";

    return (false);

  }





  // Validate if gender is specified

  

  genderoption = -1

  for (i=0;i<theForm.gender.length;i++){

	if (theForm.gender[i].checked){

		genderoption = i

	}

  }

  if (genderoption == -1)

  {

    alert("Please indicate the gender.");

    return (false);

   }





  // Validate the year format

  

  /*clear out any spacer characters, such as parentheses, dashes, spaces, 

  and dots. We can do this with a regular expression and the replace() 

  method, replacing anything that matches our regular expression with a null string. 

  */

  var yystripped = theForm.yy.value.replace(/[\(\)\.\-\ ]/g, '');

  //strip out acceptable non-numeric characters



  if (yystripped == "")

  {

	alert ("Please indicate the birth year.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (isNaN(yystripped))

  {

	alert("Please indicate the birth year in numeric.")

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  if (yystripped > 1992)

  {

  	alert("You must be at least 18 years old to be eligible for registration.");

	theForm.yy.focus()

	return false;

  }

  if (yystripped.length < 4)

  {

  	alert("Please indicate the birth year in 4 digits.");

	theForm.yy.value = ""

	theForm.yy.focus()

	return false;

  }

  

  

  // Validate e-mail address

  // Check for blank / empty / spacer input

  if (isEmpty(theForm.email_address1))

  {

    alert("Please indicate the email address.");

	theForm.email_address1.value = "";

    theForm.email_address1.focus();

    return (false);

  }

  // Allows only characters, numbers, '@', '.', '_'

  // Should conform to standard e-mail address format

  if ( !( validEmail(theForm.email_address1.value) ) ) {

    alert('Please indicate a valid email address!');

	theForm.email_address1.value = "";

    theForm.email_address1.focus();

    return (false);	

  }





  // Validate username

  

  if (isEmpty(theForm.username))

  {

    alert("Please enter the username.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  if (theForm.username.value.length <3 || theForm.username.value.length > 20)

  {

  	alert("Username can only be 3 - 20 characters.");

	theForm.username.value = "";

    theForm.username.focus();

    return (false);

  }

  var illegalChars = /\W/;

  // allow only letters, numbers, and underscores

  if (illegalChars.test(theForm.username.value)) {

     alert("Only characters, numbers and underscores are accepted in the username.");

     theForm.username.value = "";	 

	 theForm.username.focus();

	 return (false);

  } 



  

  // Validate if country is specified

  if (theForm.country.value == "#" )

  {

    alert("Please select the country.");

    return (false);

  }

    

  // Validate if education level is specified

  if (theForm.education.value == "#" )

  {

    alert("Please indicate the education level.");

    return (false);

  }



  // Validate if profession is specified

  if (theForm.profession.value == "#" )

  {

    alert("Please indicate the profession.");

    return (false);

  }

 

  //alert('Dear Valued User,\n\n You have successfully submitted your application. Thank You.');

  return (true);

}



