// JScript source code
	
	
	//Simple validation routine to check if fields contain values
	function Validate(f)
	{
 		var msg;
		var empty_fields = "";	
		var errors = "";
		
		//Reset all fields classNames to 'active' (Normal)
		for (var i = 0; i < f.length; i++) {
			if (f.elements[i].type != "radio")
				f.elements[i].className = 'active';
		}

		for (var i = 0; i < f.length; i++) {
			var e = f.elements[i];
			if (((e.type == "text")  || (e.type == "textarea")) && !e.optional) {				
				if ((e.value == null) || (e.value == "") || isblank(e.value)) {				
					empty_fields += "\n	" + e.name.substr(3, e.name.length);
					e.className = 'error';
					continue;			
				}
			}
		}

		// Now, if there were any errors, dipslay the messages, and return false
		// to prevent th form from being submitted.
		if (!empty_fields && !errors) return true;

		msg = "______________________________________________________________\n\n"
		msg += "This 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:\n"
				+ empty_fields + "\n";
			if (errors) msg += "\n";
		}
		msg += errors;
		alert(msg);
		return false;
		
	}

	function isblank(s)
	{
		for (var i = 0; i < s.length; i++) {
			var c= s.charAt(i);
			if ((c != ' ') && (c != '\n') && (c != '')) return false;
		}
		return true;
	}

	function CheckNumeric (f) {
		if (HasNonDigits( f.value )) { 
			alert('Please enter numeric value.'); 
			f.value = ''; 
			f.focus();
		}

	}

	//Moves control to next field after value entered
	//uses input name to identify field
	function advance(f,currentField,nextField) {
		if (currentField.value.length == 1)
			f[nextField].focus();
	}

	//Moves control to next field after value entered
	//uses input id to identity field
	function advance(f,currentField,nextField) {
		if (currentField.value.length == 1)
			f[nextField].focus();
	}

	function CheckEmailAddr( testString )
	{
		var r;                // Declare variables.  
		r = testString.search(/@{1}/); // Search the string.
		return(r >= 0);           // -1 if no non-digits found. 
	}

	// function test string for non numeric characters with the exception of '.' (decimal point)
	function HasNonDigits( testString )
	{
	var r;                // Declare variables.  
	r = testString.search(/[^\d.-.]/); // Search the string.
	return(r >= 0);           // -1 if no non-digits found. 
	}

	//Disables text field declare in parameter
	function DisableTextField (bEnable, f)
	{
		//Disables text fields where length greater than 1
		for ( var i = 0; i < f.length; i++) { 
			if ( bEnable == true ) {
					f[i].disabled = false; 											
				}
			else if ( bEnable == false )  {
					f[i].disabled = true;
			
				}	
		}  	
		//Disables text fields that only contain one control
		if (( f.length == null ) && (bEnable == true)) {f.disabled = false; }
		if (( f.length == null ) && (bEnable == false)) {f.disabled = true;  }
	}

