<!--
	// _validate_input.js;
	// Copyright (c) 2008 Big River Data.  All Rights Reserved.
	// To obtain a legal license for this software, contact info@bigriversystems.com.
	// Unauthorized usage, distribution and/or reverse engineering are strictly prohibited and may result in legal action.
	// code generated by the appGenerator on January 27, 2008

	// use = return inValidCharSet(str,"0123456789");
	// is the user-input valid?  If asking for numbers, did user enter characters?;
	function inValidCharSet(str,charset)	{
		var result = true;
		for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1)) < 0) {
			result = false;
			break;
		}
		return result;
	}

	// highlight the background color of a question when it is required, and is not answered (until onChange);
	function changeit(obj) {
		thisCell = document.getElementById(obj);
		if (thisCell.className='highlight') {
			thisCell.className='normal';
		}
	}

	// slight modification for integer and decimal types; they may have a math calculation associated with them.
	// Just in case they do, call a function that will be at the end of this file to process any equations that may exist.;

	function changeitCalc(obj) {
		thisCell = document.getElementById(obj);
		if (thisCell.className='highlight') {
			thisCell.className='normal';
		}
		return calc_values();
	}

	// restrict the number of characters that can be typed into a textarea;
	function textCounter (field, countfield, maxlimit) {
		if (field.value.length > maxlimit) {
			field.value = field.value.substring(0, maxlimit);
		} else {
			countfield.value = maxlimit - field.value.length;
		}
	}

	// safari will not render the toFixed javascript feature, so we have to use the following
	// Original:  Cyanide_7 (leo7278@hotmail.com)
	// Web Site:  http://www7.ewebcity.com/cyanide7

	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
			num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();
		if(cents<10)
			cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
				num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + num + '.' + cents);
		}

		function validateInput() {
			frm = false;
			if (document.inputForm) {
				// if the form (element) exists;
				var frm = document.inputForm;
			}

			if (document.modifyForm) {
				// if the form (element) exists;
				var frm = document.modifyForm;
			}

			if (frm) {
				// if either the modify or input form exists;
		
		 if ((frm.name.value == "") || (frm.name.value == null)) {
			 alert("#1 - 'Name' is required.");
			 document.getElementById("form_name").className = "highlight";
			 frm.name.focus();
			 return false;
		}

		 document.getElementById("form_name").className = "normal";




		 strng = frm.email_address.value;
		if (strng != "") {
			var emailFilter=/^.+@.+\..{2,3}$/;
			if (!(emailFilter.test(strng))) {
			 alert("Please enter a valid email address.");
			 document.getElementById("form_email_address").className = "highlight";
			 frm.email_address.focus();
			 return false;
		 } else {
			   //test email for illegal characters;
			 	   var illegalChars= /[\(\)\<\>\,\;\:\"\[\]]/
			 		if (strng.match(illegalChars)) {
			 			alert ("The email address contains illegal characters.");
			  		document.getElementById("form_email_address").className = "highlight";
			 			frm.email_address.focus();
			 	   		return false;
				}
		  	}
		 }

		 document.getElementById("form_email_address").className = "normal";


		 if ((frm.email_address.value == "") || (frm.email_address.value == null)) {
			 alert("#3 - 'E-Mail' is required.");
			 document.getElementById("form_email_address").className = "highlight";
			 frm.email_address.focus();
			 return false;
		}

		 document.getElementById("form_email_address").className = "normal";


		 if ((frm.phone.value == "") || (frm.phone.value == null)) {
			 alert("#4 - 'Phone' is required.");
			 document.getElementById("form_phone").className = "highlight";
			 frm.phone.focus();
			 return false;
		}

		 document.getElementById("form_phone").className = "normal";


		 var contindiv_radio = false;
		 for (counter = 0; counter < frm.contindiv.length; counter++) {
			if (frm.contindiv[counter].checked) {
				 contindiv_radio = true;
			}
		 }


		 if (!contindiv_radio) {
			 alert("#5 - 'blank' is required.");
			 document.getElementById("form_contindiv").className = "highlight";
			 document.getElementById('contindiv').focus();
			 return(false);
		 }

		 document.getElementById("form_contindiv").className = "normal";


	} // end if-frm is defined;

	// perform the auto-calc function one last time, in case the user changed the values manually;
	return calc_values();
	return toggle();
} // close main function;

function calc_values() {
	frm = false;
	if (document.inputForm) {
		// if the form exists;
		var frm = document.inputForm;
	}

	if (document.modifyForm) {
		// if the form exists;
		var frm = document.modifyForm;
	}

	if (frm) {

	} // end if-frm;
} // close calc_values;
//-->