function isEmail(elm){ 
	if (elm.value.indexOf("@") != "-1" &&
		elm.value.indexOf(".") != "-1" &&
		elm.value != "")
	return true;
	else return false;
}
function isFilled(elm){
	if (elm.value == "" ||
		elm.value == null)
	return false;
	else return true;
}
function isState(elm){
	if (elm.value == "1" ||
		elm.value == null)
	return false;
	else return true;
}
function displayError(err,label,input,reveal) {
	if (reveal==1) {
		document.getElementById(err).style.display = "block";
		document.getElementById(label).style.color = "red";
		document.getElementById(input).style.borderColor = "red";
	} else {
		document.getElementById(err).style.display = "none";
		document.getElementById(label).style.color = "#004";
		document.getElementById(input).style.borderColor = "#004";
	}
}
function isReady(contact){     
	if (isFilled(contact.cname) == false){
		displayError("errName","labelName","inputName",1);
		contact.cname.focus();
		return false;
	} else {
		displayError("errName","labelName","inputName",0);
	}
	if (isEmail(contact.cemail) == false){
		displayError("errEmail","labelEmail","inputEmail",1);
		contact.cemail.focus();
		return false;
	} else {
		displayError("errEmail","labelEmail","inputEmail",0);
	}
	if (isFilled(contact.caddress) == false){
		displayError("errAddress","labelAddress","inputAddress",1);
		contact.caddress.focus();
		return false;
	} else {
		displayError("errAddress","labelAddress","inputAddress",0);
	}
	if (isFilled(contact.ccity) == false){
		displayError("errCity","labelCity","inputCity",1);
		contact.ccity.focus();
		return false;
	} else {
		displayError("errCity","labelCity","inputCity",0);
	}
	if (isState(contact.cstate) == false){
		displayError("errState","labelState","inputState",1);
		contact.cstate.focus();
		return false;
	} else {
		displayError("errState","labelState","inputState",0);
	}
	if (isFilled(contact.czip) == false){
		displayError("errZip","labelZip","inputZip",1);
		contact.czip.focus();
		return false;
	} else {
		displayError("errZip","labelZip","inputZip",0);
	}
	//if (isFilled(contact.ccomments) == false){
	//	displayError("errComments","labelComments","inputComments",1);
	//	contact.ccomments.focus();
	//	return false;
	//} else {
	//	displayError("errComments","labelComments","inputComments",0);
	//}
return true;
}
function resetError() {
	arrReset = new Array ("Name","Email","Address","City","State","Zip");
	for (i=0; i<=2; i++) {
		var errReset = "err"+arrReset[i];
		var labelReset = "label"+arrReset[i];
		var inputReset = "input"+arrReset[i];
		document.getElementById(errReset).style.display = "none";
		document.getElementById(labelReset).style.color = "#004";
		document.getElementById(inputReset).style.borderColor = "#004";
	}
}

