emptyok = false;
function isblank(s)
{
	for(var i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}
function verify(f)
{
	var msg;
	var errors = "";
	var valemail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	var valphone = /\d{3}-\d{3}-\d{4}/;
		
	if (isblank(document.cookieform.name.value)
		&& isblank(document.cookieform.email.value)
		&& isblank(document.cookieform.phone.value)
		&& !emptyok)
			errors = "You must enter something in at least one of the fields.\n";
	if ((!isblank(document.cookieform.email.value)) && (!document.cookieform.email.value.match(valemail)))
		errors = "You must enter a valid email address (user@domain.name).\n";
	if ((!isblank(document.cookieform.phone.value)) && (!document.cookieform.phone.value.match(valphone)))
		errors = "You must enter a valid phone number (123-456-7890).\n";
	if (!errors) return true;
	msg = "______________________________________________________________\n\n";
	msg += "The form was not submitted because of the following error(s).\n";
	msg += "Please correct your entries and re-submit.\n";
	msg += "______________________________________________________________\n\n";
	msg += errors;
	alert(msg);
	return false;
}
function saveCookie()
{
	if (!isblank(document.cookieform.name.value)) {
		var data = document.cookieform.name.value;
		var expDate = getExpDate(180,0,0);
		setCookie("name",data,expDate);
	} else deleteCookie("name");
	if (!isblank(document.cookieform.email.value)) {
		var data = document.cookieform.email.value;
		var expDate = getExpDate(180,0,0);
		setCookie("email",data,expDate);
	} else deleteCookie("email");
	if (!isblank(document.cookieform.phone.value)) {
		var data = document.cookieform.phone.value;
		var expDate = getExpDate(180,0,0);
		setCookie("phone",data,expDate);
	} else deleteCookie("phone");
	if (document.cookieform.zone.options.selectedIndex != 0) {
		var data = document.cookieform.zone.options.selectedIndex;
		var expDate = getExpDate(180,0,0);
		setCookie("zone",data,expDate);
	} else deleteCookie("zone");
	alert("Cookie has been saved or modified.  Thank you!");
}
function readCookie()
{
	var cname = getCookie("name");
	document.cookieform.name.value = (cname == null || cname == "") ? "" : cname;
	var cemail = getCookie("email");
	document.cookieform.email.value = (cemail == null || cemail == "") ? "" : cemail;
	var cphone = getCookie("phone");
	document.cookieform.phone.value = (cphone == null || cphone == "") ? "" : cphone;
	var czone = getCookie("zone");
	document.cookieform.zone.selectedIndex = (czone == null || czone == "") ? 0 : czone;
	if (!isblank(cname) || !isblank(cemail) || !isblank(cphone) || !isblank(czone))
		emptyok = true;
}

