//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  Company: Lehigh Valley Webmasters, Inc.
//  Developer(s) : Pat Kolis
//  Date : 10/23/2001
//
//  Description : Editing for the products page.
//
//  -------------------------------------------------------------------------------------------------------
//  Copyright © 2001. Lehigh Valley Webmasters, Inc.  All Rights Reserved.
//  ====================================================
//  REVISION HISTORY:
//  Date : xx/xx/xxxx
//  Developer : xxxxxxxxxx
//  Description : xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//  ---------------------------------------------------------------------------------------------------------
//
//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	function validate_form(prod_form)   {
		var msg = "";

		// Extract all elements from form.
		var names = "";

		// Did not work on NN6   var obj = document.prod_form;
		// Did not work on NN6   for(var i in obj) names += i + " ";

		for (var i = 0; i < prod_form.length; i++) {
			names += prod_form.elements[i].name + " ";
		}

		// Check if they entered a quantity, search for the qty_xxxxx fields
		var myRegExp = /qty_\d\d\d\d\d/g;
		var myArray = names.match(myRegExp);

		// Dump results into array
		var i;
		var qty_valid = 0;

		for (i = 0; i < myArray.length; i++) {
			//alert(myArray[i]);

			var1 = "prod_form." + myArray[i] + ".value;";
			var qty = eval(var1);

			if (qty) {
				var v = parseFloat(qty);
				if (isNaN(v) || v < 0) {
					msg += "> Quantity entered is invalid.\n";
					var wrkvar = myArray[i].toString();
					var foc = "document.prod_form." + wrkvar + ".focus();";
					eval(foc);
					var sel = "document.prod_form." + wrkvar + ".select();";
					eval(sel);
				} else {
					// We got a valid quantity.
					qty_valid = 1;
				}
			} else {
				msg += "> \"Quantity\" is missing or invalid.\n";
				var wrkvar = myArray[i].toString();
				var foc = "document.prod_form." + wrkvar + ".focus();";
				eval(foc);
				var sel = "document.prod_form." + wrkvar + ".select();";
				eval(sel);
			}

		}

		if (msg) {
			errormsg   = "____________________________________________________\n\n";
			errormsg += "The form was NOT submitted because of the following error(s).\n";
			errormsg += "Please correct error(s), and re-submit.\n";
			errormsg += "____________________________________________________\n\n";

			errormsg += msg;
			alert(errormsg);
			return false;
		}

	 	return true;

	  }
