media = "screen";

function setmedia()
{
	media = "handheld";
}

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 (media == "handheld") return pverify(f);
	
	if (isblank(document.contact.email.value) && isblank(document.contact.phone.value))
		errors += "You must enter either your email address or your phone number.\n";
	if ((!isblank(document.contact.email.value)) && (!document.contact.email.value.match(valemail)))
		errors += "You must enter a valid email address (user@domain.name).\n";
	if ((!isblank(document.contact.phone.value)) && (!document.contact.phone.value.match(valphone)))
		errors += "You must enter a valid phone number (123-456-7890).\n";
	if (isblank(document.contact.comments.value))
		errors += "You did not enter any comments or requests.\n";
	if (!errors) {
		if (isblank(document.contact.email.value)) document.contact.email.value = "webmaster@pcvsoftware.net";
		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 readCookie()
{
	if (media == "handheld") return preadCookie();
	
	var cname = getCookie("name");
	document.contact.name.value = (cname == null || cname == "") ? "" : cname;
	var cemail = getCookie("email");
	document.contact.email.value = (cemail == null || cemail == "") ? "" : cemail;
	var cphone = getCookie("phone");
	document.contact.phone.value = (cphone == null || cphone == "") ? "" : cphone;
	document.contact.name.focus();
}
