function isBlank(theString) {
	var result = true;
	if (theString != "") {
		for (x=0; x<theString.length; x++) {
			var theChar = theString.charAt(x);
			if (theChar != " ") {
				result = false;
				break;
			}
		}
	}
	return result;
}

function validateSearch() {
	var result = true;
	if (isBlank(document.all["txtSearch"].value)) {
		alert("Please enter some search words, then click the \"Search\" button.");
		result = false;
	} else {
        var newloc = "gallery.php?txtSearch=" + encodeURIComponent(document.all["txtSearch"].value);
        window.location.href = newloc;
    }
	return result;
}

function validateForm() {
	var result = true;
    var firstBlank = isBlank(document.frmContact.fldFirstName.value);
    var lastBlank = isBlank(document.frmContact.fldLastName.value);
	if (firstBlank || lastBlank) {
		alert("Please enter your name so we can respond to your request.");
        if (firstBlank) {
            document.frmContact.fldFirstName.focus();
        } else {
            document.frmContact.fldLastName.focus();
        }
		result = false;
	} else {
		if (isBlank(document.frmContact.fldEmail.value) && isBlank(document.frmContact.fldPhone.value)) {
			alert("Please enter either your phone number or your email address so we can respond to your request.");
            document.frmContact.fldPhone.focus();
		    result = false;
		}
	}
	return result;
}
