// Form validation //
function Validate(O) {
	O.Name.style.backgroundColor="";
	O.Email.style.backgroundColor="";
	O.Phone.style.backgroundColor="";
	O.Message.style.backgroundColor="";
	
	
	if(O.Name.value=="") {
		alert("Name is empty.");
		O.Name.focus();
		O.Name.style.backgroundColor="yellow";
		return false;
	}
	if(!isEMailAddr(O.Email)) {
		O.Email.focus();
		O.Email.style.backgroundColor="yellow";
		return false; 
	}
	//if(O.Phone.value=="") {
	//	alert("Telephone is empty.");
	//	O.Phone.focus();
	//	O.Phone.style.backgroundColor="yellow";
	//	return false;
	//}
	if(O.Message.value=="") {
		alert("Message is empty.");
		O.Message.focus();
		O.Message.style.backgroundColor="yellow";
		return false;
	}
	if(O.vericode.value=="") {
		alert("Please set Verification Code as shown below.");
		O.vericode.focus();
		O.vericode.style.backgroundColor="yellow";
		return false;
	}
	
	return true;
}
function isLen16(elem) {
    var str = elem.value;
    var re = /\b.{16}\b/;
    if (!str.match(re)) {
        alert("Entry does not contain the required 16 characters.");
        return false;
    } else {
        return true;
    }
}
   
function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Verify the email address format.");
        return false;
    } else {
        return true;
    }
}