function notInRange(field, range1, range2) {
    if ( (range1 == 0) && isEmptyString(field) ) {
        return false;
    }
    if ((field.length < range1) || (field.length > range2)) {
        return true;
    } else {
        return false;
    }
}

function isEmptyString(str) {

	if(str.replace(/\s/g, "") == ""){
		return true;
	}
	return false;
}

function textCounter(field, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    }
}

function validateFeedback(feedback) {
    if (isEmptyString(feedback.name.value)) {
        alert("Please enter your name");
	return false;
    }
    if (isEmptyString(feedback.email.value)) {
        alert("Please enter your e-mail address");
	return false;
    }
    if (feedback.email.value.indexOf('@') == -1 ) {
        alert("The email address is invalid")
        return false;
    }
    if (feedback.recipient.value == "None") {
        alert("Please choose who your message is for");
	return false;
    }
    if (isEmptyString(feedback.subject.value)) {
        alert("Please enter the subject of your message");
	return false;
    }
    if (isEmptyString(feedback.captcha.value)) {
        alert("Please enter the security characters");
	return false;
    }
    if (isEmptyString(feedback.message.value)) {
        alert("Please enter your message");
	return false;
    }
    feedback.Submit.disabled=true;
    return true;
}

function validateGuestbook(guestbook) {
    if (isEmptyString(guestbook.name.value)) {
        alert("Please enter your name");
	return false;
    }
    if (isEmptyString(guestbook.email.value)) {
        alert("Please enter your e-mail address");
	return false;
    }
    if (guestbook.email.value.indexOf('@') == -1 ) {
        alert("The email address is invalid")
        return false;
    }
    if (isEmptyString(guestbook.location.value)) {
        alert("Please enter your location");
	return false;
    }
    if (isEmptyString(guestbook.captcha.value)) {
        alert("Please enter the security characters");
	return false;
    }
    guestbook.Submit.disabled=true;
    return true;
}

function validatePlayerSponsor(sponsor) {
    if (isEmptyString(sponsor.name.value)) {
        alert("Please enter your name");
	return false;
    }
    if (isEmptyString(sponsor.email.value)) {
        alert("Please enter your e-mail address");
	return false;
    }
    if (sponsor.email.value.indexOf('@') == -1 ) {
        alert("The email address is invalid")
        return false;
    }
    if (isEmptyString(sponsor.player1.value)) {
        alert("Please enter your first choice player");
	return false;
    }
    if (isEmptyString(sponsor.captcha.value)) {
        alert("Please enter the security characters");
	return false;
    }
    sponsor.Submit.disabled=true;
    return true;
}