// ADD FUNCTION TO CHECK THE EMAIL ADDRESS IS IN THE CORRECT FORMAT

/*
function CheckPassword(FormName,ElemName,Action)
{
/*
    var Password = document.forms[FormName].elements[ElemName];
    var PasswordCheck = document.forms[FormName].elements["PasswordCheck"];
    var Form = document.forms[FormName];
//

    var Password = FormName.elements[ElemName];
    var PasswordCheck = FormName.elements["PasswordCheck"];
//    var Form = document.forms[FormName];

//alert("Password value " + Password.value);


    if (Password.value != "")                                                         // if password field is not empty then
    {

        if (PasswordCheck.value == Password.value)                                    // check to see if the retyped password matches the password
        {
            // check the rest of the fields in the form
            if (verify(FormName))
            {
                //alert("Action = " + Action);
                FormName.action = Action;                                 // then set the action
                FormName.submit();                                        // and submit the form
                return true;
            }
            else
            {
                //alert("Not sending form");
                return false;
            }

        }
        else
        {

            msg  = "Your Passwords do not match\n";
            msg += "---------------------------\n";
            msg += "Please ensure that the word\n";
            msg += "you enter in the second box\n";
            msg += "matches the first\n";
            alert(msg);

            PasswordCheck.value = "";
            Password.value = "";
            Password.focus();
            return false;
        }
    }
    else
    {
        alert("Missing fields. Form not sent");
        return false;
    }

}

*/
// a utlity function that returns true if a string contains only
// whitespace characters
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;
}

// This is the function that performs the form verification. It will be invoked
// from the onSubmit() event handler. The handler should return whatever
// value this function returns

function verify(f,Action)
{
    var msg;
    var empty_fields = "";
    var errors = "";

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea")) || (e.type == "password") && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) {
                var v = parseFloat(e.value);
                if (isNaN(v) ||
                    ((e.min != null) && (v < e.min)) ||
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null)
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null)
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.
    if (!empty_fields && !errors)
    {
        f.action = Action;                                 // then set the action
        f.submit();                                        // and submit the form
        return true;
    }

    msg  = "______________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:"
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}
// rollover stuff
	state = new Object();
	state[0] = "_off"
	state[1] = "_on"
	


	function SwapImage(id,act)
		{
			if(document.images)
				document.images[id].src = eval("navigation." + id + state[act] + ".src");
		}


	if(document.images)
		{
			navigation = new Object();
		

			navigation.hockey_off = new Image();
			navigation.hockey_off.src = "img/sports-002_19.jpg";
			navigation.hockey_on = new Image();
			navigation.hockey_on.src = "img/sports-002_19_on.jpg";

			navigation.football_off = new Image();
			navigation.football_off.src = "img/sports-002_20.jpg";
			navigation.football_on = new Image();
			navigation.football_on.src = "img/sports-002_20_on.jpg";

			navigation.multisport_off = new Image();
			navigation.multisport_off.src = "img/sports-002_21.jpg";
			navigation.multisport_on = new Image();
			navigation.multisport_on.src = "img/sports-002_21_on.jpg";

			navigation.equestrian_off = new Image();
			navigation.equestrian_off.src = "img/sports-002_22.jpg";
			navigation.equestrian_on = new Image();
			navigation.equestrian_on.src = "img/sports-002_22_on.jpg";

			navigation.athletics_off = new Image();
			navigation.athletics_off.src = "img/sports-002_23.jpg";
			navigation.athletics_on = new Image();
			navigation.athletics_on.src = "img/sports-002_23_on.jpg";

			navigation.tennis_off = new Image();
			navigation.tennis_off.src = "img/sports-002_24.jpg";
			navigation.tennis_on = new Image();
			navigation.tennis_on.src = "img/sports-002_24_on.jpg";

			navigation.clubhouses_off = new Image();
			navigation.clubhouses_off.src = "img/sports-002_25.jpg";
			navigation.clubhouses_on = new Image();
			navigation.clubhouses_on.src = "img/sports-002_25_on.jpg";	

			navigation.othersports_off = new Image();
			navigation.othersports_off.src = "img/sports-002_26.jpg";
			navigation.othersports_on = new Image();
			navigation.othersports_on.src = "img/sports-002_26_on.jpg";						
		}
