function vContact(theForm){
	var reason="";
	reason+=vEmpty(theForm.name);
	reason+=vEmail(theForm.email);
	reason+=vEmpty(theForm.comments);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
function vCareer(theForm){
	var reason="";
	reason+=vEmpty(theForm.name);
	reason+=vEmpty(theForm.occupation);
	reason+=vResume(theForm.uResume, theForm.resume);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
function vForgot(theForm){
	var reason="";
	reason+=vEmail(theForm.email);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
function vHint(theForm){
	var reason="";
	reason+=vEmpty(theForm.user_name);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
function vLogin(theForm){
	var reason="";
	reason+=vEmpty(theForm.user_name);
	reason+=vEmpty(theForm.password);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
//start custom event field validation
function vEmpty(fld){
	var error="";
    if(fld.value.length==0){
		fld.style.background='#f4f5b9';
		var show=fieldName(fld.name);
		error+=show;
	}else{
		fld.style.background='#fff';
	}
	return error;
}
function vEmail(fld){
	var error="";
	var tfld=trim(fld.value);
	var emailFilter=/^[^@]+@[^@.]+\.[^@]*\w\w$/;
	var illegalChars=/[\(\)\<\>\,\;\:\\\"\[\]]/;

	if(fld.value==""){
		fld.style.background='#f4f5b9';
		error+="Email.\n";
	}else if(!emailFilter.test(tfld)){ 
		fld.style.background='#f4f5b9';
		error+="Email address is not valid.\n";
	}else if(fld.value.match(illegalChars)){
		fld.style.background='#f4f5b9';
		error+="Email address contains illegal characters.\n";
	}else{
		fld.style.background='#fff';
	}
	return error;
}
function vPsswd(p1, p2){
    var error="";
    if(p1.value.length==0){
		p1.style.background='#f4f5b9'; 
		error+="Password.\n";
	}else{
		p1.style.background='#fff';
		if(p2.value.length==0){
			p2.style.background='#f4f5b9'; 
			error+="Confirm Password.\n";
		}else{
			p2.style.background='#fff';
			if(p1.value!=p2.value){
				p1.style.background='#f4f5b9'; 
				p2.style.background='#f4f5b9'; 
				error+="Passwords do not match.\n";
			}
		}
	}
	return error;
}
function vSelect(fld){
	var error="";
	if(fld.value=='Select From List'){
		var show=fieldName(fld.name);
		error+=show;
	}
	return error;
}
function trim(s){
  return s.replace(/^\s+|\s+$/, '');
}
function fieldName(w){
	var fUnd=w.split('_');
	var properName="";
	if(fUnd.length>0){
		for(var i in fUnd){
			properName+=fUnd[i].substr(0,1).toUpperCase()+fUnd[i].substr(1);
			if(i!=(fUnd.length-1)){
				properName+=' ';
			}else{
				properName+='.\n';
			}
		}
	}else{
		properName+=fld.name+='.\n';
	}
	return properName;
}
function vResume(uR, rS){
	var error="";
	if(uR.value.length==0 && rS.value.length==0){
		rS.style.background='#f4f5b9'; 
		uR.style.background='#f4f5b9'; 
		error+="Resume Text or Upload Resume.\n"
	}else{
		uR.style.background='#fff';
		rS.style.background='#fff';
	}
	return error;
}
