var rFields=new Array("cemail", "cpasswd");
var bFields=new Array();

function validform(){
	with(document.entryform){
		if(cpasswd.value != ccpasswd.value){ alert("Please check your password again."); cpasswd.focus(); return false; }
		if(!validEmail()) return false;

		nPassed=true;
		for(i=0; i<rFields.length; i++){
			if(eval(rFields[i]).value==""){
				alert("Please fill the required fields");
				eval(rFields[i]).focus();
				return false;
//				nPassed=false;
//				break;
			}
		}
/*
		if(scountry_desc.selectedIndex == 0){
			alert("Please select your country");
			return false;
		}
*/

		if(nPassed==false){
			alert("Please fill all required fields");
			return false;
		}

		return true;
	}
}

function validEmail(){
	with(document.entryform){	
		var x = cemail.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(x)){
			alert("Please check your email address again");
			cemail.focus();
			return false;
		}else return true;
	}
}

function validTel(obj){
	var checkOK = "0123456789- ";

	with(document.entryform){
		checkStr = eval(obj).value;
		if(checkStr != ""){
			var allValid = true;
			if (checkStr.length < 9){
				alert("The telephone number should not less than 7 digits");
				eval(obj).focus();
				return false;
			}			
			
			for (i = 0;  i < checkStr.length;  i++){
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++){
				  if (ch == checkOK.charAt(j)) break;
				}
				if (j == checkOK.length){
				  allValid = false;
				  break;
				}
			}
			if (!allValid){
				alert("Please enter number in the \"Telephone\" field.");
				eval(obj).focus();
				return (false);
			}			
		}
	}
}
