// Script: Form Handling Functions
// Version: 1.0
// Last Updated: 25 August 2005
// Author: Paul Hunt
// Org: CustomSUPPORT
// Email: webmaster@CustomSUPPORT.com
// functions:
//				_formAll			Process Form - all options except setTimeout		
// 				_formSetAct			Set Form Action Value
//				_formSetElem		Set Form Element Value
//				_formSubmit			Submit Form
//				_formTimeOut		Submit on Timeout
			   
function _formAll(formName, actValue, elemName, elemValue, submitOpt) {
	if (window.document.forms[formName].formDone.value != "1") {
		if (actValue) _formSetAct(formName, actValue);
		if (elemName) _formSetElem(formName, elemName, elemValue);
		if (submitOpt == "submit") _formSubmit(formName);
		return true;
		}
	}

function _formPPSubmit(item_no, item_name, amount) {
	_formSetElem("PPForm", "item_name", item_name);
	_formSetElem("PPForm", "amount", amount);
	_formSetElem("PPForm", "quantity", window.document.forms["PPForm"].elements["quantity" + item_no].value);
	_formSetElem("PPForm", 'JS', 'YES'); 
	_formSetElem("PPForm", 'formDone', "1");
	return true;
	}

function _formSetAct(formName, actValue) {
	window.document.forms[formName].action = actValue;
	}

function _formSetElem(formName, elemName, elemValue) {
	window.document.forms[formName].elements[elemName].value = elemValue;
	}

function _formSubmit(formName) {
	alert(window.document.forms["PPForm"].elements["item_name"].value);
		_formSetElem(formName, 'JS', 'YES'); 
		_formSetElem(formName, 'formDone', "1");
		window.document.forms[formName].submit();
	}

function _formTimeOut(formName, actValue, elemName, elemValue, minutes) {
	if (minutes != 0) {
		var time = minutes * 60000;
		var call = "_formAll('" + formName + "', '" + actValue + "', '" + elemName + "', '" + elemValue + "', 'submit')";
		setTimeout(call, time);
		}
	}