/****************************************************************************************
Copyright (c) 2007 Ethicon Endo-Surgery, Inc.(EES).

This software is the confidential and proprietary information of EES. ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement you entered into with EES.

VERSION 	1.0
AUTHOR		Doug Scamahorn

DATE       	NAME           	DESCRIPTON
11/14/2007 	Doug Scamahorn  Initial creation.

****************************************************************************************/
//Initialize Submit button onclick listener
function validateWeightButton() {
	//Test for browser support of DOM
	if (!document.getElementById) return false;
	//Gather page information
	var formSubmitButton = getElementsByClassName("cc_formSubmitImage");
	//Attach the onclick event to the submit button
	formSubmitButton[1].onclick = function() {
		var weight = getWeightValue();
		//Validate the weight
		if (!validateWeight(weight)) {
			alert("Please enter a number for your weight.");
			return false;
		}
	}
	return;
}
//Get the weight value
function getWeightValue(){
	//Test for browser support of DOM
	if (!document.getElementById) return false;
	//Gather page information
	var forms = document.getElementsByTagName("form");
	//Find the eligibility form by looking for the FORM element on the page without a classname assigned to it.
	for(var i=0; i<=forms.length; i++){
		if (!forms[i].className){
			var quizForm = forms[i];
			//Find the weight field
			for(var j=0;j<=quizForm.length;j++){
				if (quizForm.elements[j].name=="eligQuizWeight"){
					var weightValue = quizForm.elements[j].value;
					return weightValue;
				}
			}
		}
	}
}
//Validate the value for weight is numeric
function validateWeight(w) {
	if (w=="") {
		return true;
	} else if (isNaN(w)) { //parseInt(w)
		return false;
	} else {
		return true;
	}
}
//On Page Load Events
addLoadEvent(validateWeightButton);