// ---------------------------------------------------------------------------------------
// File:      validate.js
// Date:      August 15, 2002
// Author:    Xavier Mendoza
// Purpose:   Validation of fields on a HTML form.
// Functions: checkRadios(form,radios)
//            checkDropDown(form,drop)
//            checkText(form,text)
//            checkCheck(form,check)
// ---------------------------------------------------------------------------------------


// ---------------------------------------------------------------------------------------
// checkRadios(form,radios)
// * Must supply the name of the form followed by the name of the radio buttons
// * Returns the value that is checked, else 0
// ---------------------------------------------------------------------------------------
	function checkRadios(form,radios) {
		var obj, checkvalue = 0;
		obj = eval('document.' + form + '.' + radios + ''); // obj is a handle for the radio buttons
		for (i=0, n=obj.length; i<n; i++) {
			if (obj[i].checked) {
				checkvalue = obj[i].value;
				break; // Checked value found. no need to search any further.
			}
		}
		return checkvalue; // Returns the value that is checked
	}
	
// ---------------------------------------------------------------------------------------
// checkDropDown(form,drop)
// * Must supply the name of the form followed by the name of the dropdown menu
// * Returns the selected value, else 0
// ---------------------------------------------------------------------------------------
	function checkDropDown(form,drop) {
		var obj = eval('document.' + form + '.' + drop + ''); // obj is a handle for the dropdown menu
		return obj.selectedIndex?obj.selectedIndex:0; // The selected value is returned
	}
	
// ---------------------------------------------------------------------------------------
// checkText(form,text)
// * Must supply the name of the form followed by the name of the textbox.
// * Returns the value in the textbox, else 0
// ---------------------------------------------------------------------------------------
	function checkText(form,text) {
		var obj = eval('document.' + form + '.' + text + ''); // obj is a handle for the textbox
		return (obj.value!='')?obj.value:0; // returns the value of the textbox, else 0
	}

// ---------------------------------------------------------------------------------------
// checkCheck(form,check)
// * Must supply the name of the form followed by the name of the checkbox.
// * Returns the value in the checkbox, else 0
// ---------------------------------------------------------------------------------------
	function checkCheck(form,check) {
		var obj = eval('document.' + form + '.' + check + ''); // obj is a handle for the checkbox
		return (obj.checked)?obj.value:0; // returns the value of the textbox, else 0
	}
	
	
	
	
	