	function validRequired(formField,fieldLabel,Message) {
		var result = true;
		if (formField.value == "")
		{
			alert(Message);
			formField.focus();
			result = false;
		}
		return result;
	}
	
	function validTick(formField,fieldLabel,Message) {
		var result = true;
		if (formField.checked == true)
		{
		result = true;
		}
		else
		{
			alert(Message);
			formField.focus();
			result = false;
		}		
		return result;
	}
	
	
	//Validate Member Application
	function RegistrationValidate(theForm)
	{
		//if (!CheckRadio(theForm.merchantid,'Please select a merchant.')) {
			//return false;
		//}	
		
			
			if (!validRequired(theForm.username,"username", "Please enter your username"))
			return false;
			if (!validRequired(theForm.password,"password", "Please enter your password!"))
			return false;
			if (theForm.password.value != theForm.password2.value) {
				alert("Your passwords do not match!");
				theForm.password2.value=""
				theForm.password.focus();
				return false;
			}
			if (!validRequired(theForm.email,"emailaddress", "Please enter your Email Address!"))
			return false;
			if (emailcheck(theForm.email.value)==false){
					theForm.email.focus()
					return false
				}
			if (!validRequired(theForm.firstname,"firstname", "Please enter your First Name!"))
			return false;
			if (!validRequired(theForm.lastname,"lastname", "Please enter your Last Name!"))
			return false;

			if (!validTick(theForm.iagree,"iagree","You must read the Terms and Conditions before you submit the application")) 
			return false;
			if (!validRequired(theForm.strCAPTCHA,"strCAPTCHA", "Please Type the characters in the image!"))
			return false;
			
			return true;		
		

		 
		
		
	
	}
	
	function emailcheck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please check your Email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Please check your Email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Please check your Email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		 	alert("Please check your Email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		 	alert("Please check your Email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		 	alert("Please check your Email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		 	alert("Please check your Email address")
		    return false
		 }
 		 return true					
	}
	
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}

	
	