function vCustomE(theForm){
	var reason="";
	reason +=vNmEng(theForm.name, theForm.engraving);
	//reason +=vCkEml(theForm.email);
	reason +=vCkPh(theForm.telephone);
	reason +=vCkCd(theForm.gencode, theForm.realcode);
	if(reason!=""){
		alert("Required fields:\n\n"+reason);
		return false;
	}else{
		return true;
	}
}
//start custom event field validation
function vNmEng(nM, eG){
    var error="";
    if(nM.value.length==0){
		nM.style.background='#f4f5b9'; 
		error+="Name.\n"
	}else{
		nM.style.background='#fff';
	}
    if(eG.value.length==0){
		eG.style.background='#f4f5b9'; 
		error+="Engraving.\n"
	}else{
		eG.style.background='#fff';
	}
	return error;
}
function vCkEml(fld){
	var error="";
	var emailFilter=/^[^@]+@[^@.]+\.[^@]*\w\w$/;
	var illegalChars=/[\(\)\<\>\,\;\:\\\"\[\]]/;

	if(fld.value.length==0){
		fld.style.background='#f4f5b9';
		error+="Email.\n";
	}else if(!emailFilter.test(fld)){
		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 vCkPh(fld){
    var error="";
    var stripped=fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if(fld.value==""){
		error="Telephone.\n";
		fld.style.background='#f4f5b9';
	}else if(isNaN(parseInt(stripped))){
		error="Telephone contains illegal characters.\n";
		fld.style.background='#f4f5b9';
	}else if(!(stripped.length==10)){
		error="Telephone is the wrong length. Make sure you included an area code.\n";
		fld.style.background='#f4f5b9';
	}
	return error;
}
function vCkCd(c1, c2){
    var error="";
    if(c1.value.length==0){
		c1.style.background='#f4f5b9'; 
		error+="Enter code.\n"
	}else{
		if(c1.value!=c2.value){
			c1.style.background='#f4f5b9'; 
			error+="Wrong code entered.\n"
		}else{
			c1.style.background='#fff';
		}
	}
	return error;
}
function openwindow(){
	window.open("/rmstras/wordS.php", "mywindow","width=400,height=600,location=no,status=no,scrollbars=1");
}
