<!-- admin functions -->
/* code example
// ================
var attr = {};
attr['id'] = 'formid';
attr['action'] = 'http://www.goemerchant.com/index.aspx';
attr['method'] = 'post'
attr['target'] = '_self';
attr['onSubmit'] = 'testme()';

var elements = {};
elements['action'] = 'forward';
elements['id'] = '123123';

var form1 = new myHiddenForm(attr);
form1.set_debug(true);
form1.set_elements(elements);
form1.submitForm();

function testme()
{
	alert('test function');
}
//==================
*/


// =====================
// myHiddenForm(attributes)
// =====================
// USAGE:
// attributes is an associative array. The following elements are recognized
//
// Required:
// id
//
// Optional:
// action - default: index.aspx
// method - default: post
// target - default: _self
// onSubmit - default: null - put a function name in here that will be called before the form is submitted. e.g. 'testme(true)'
//
// Public Methods:
// submitForm()
// set_elements(elements) - elements is an associative array of key/value pairs. This is used to make the form HTML
// set_debug(true or false) - setting to true will display the form HTML and will block the form from submitting
// get_debug()

function myHiddenForm(attributes) 
{
	// form attributes
	this.formID = null;	
	this.action = null;
	this.method = null;
	this.target = null;
	this.onSubmit = null;
	this.formObj = null;
	this.formElements = {};
	this.debug  = false;
	
	if (!attributes.id)
		return null;

	// form attribute methods
	this.set_debug = function(onoff) { this.debug = onoff;}
	this.get_debug = function() { return this.debug; }

	this.set_formID = function(id) { if (!id){return;} this.formID = id;}
	this.get_formID = function() { return this.formID; }
	this.set_action  = function(newAction) {
		this.action = newAction == null ? "index.aspx":newAction;	
	}
	this.get_action = function() { return this.action; }
	this.set_method  = function(newMethod) {
		this.method = newMethod == null ? "post":newMethod;	
	}
	this.get_method = function() { return this.method; }	
	this.set_target = function(newTarget) {
		this.target = newTarget == null ? "_self":newTarget;	
	}
	this.get_target = function() { return this.target; }
	this.set_onSubmit  = function(newOnSubmit){
		this.onSubmit = newOnSubmit == null ? null:newOnSubmit;	
	}
	this.get_onSubmit = function() { return this.onSubmit; }
	this.createForm = function(){
		this.formObj = document.createElement('FORM');
		this.formObj.id = this.get_formID();
		this.formObj.action = this.get_action();
		this.formObj.method = this.get_method();
		this.formObj.target = this.get_target();
		document.body.appendChild(this.formObj); 
	}
	
	this.set_elements = function (eleArr) {
		if (!this.formObj)
			return;
			
		var str = '';
		for (var key in eleArr) 
		{
				if (isObject(eleArr[key]))
				{
					for (var x=0;x<eleArr[key].length;x++)
					{
						str += "<input type='hidden' name='" + key+"' value='"+eleArr[key][x]+"'>";
					}
				}
				else
				{
					str += "<input type='hidden' name='" + key+"' value='"+eleArr[key]+"'>";
				}
		}
		this.formObj.innerHTML = str;
	}
	
	this.submitForm = function() { 
		if (this.get_action != null)
		{
			if (this.get_onSubmit())
				eval(this.get_onSubmit());
				
			if (this.debug)
				alert('DEBUG:' + this.formObj.innerHTML);

			this.formObj.submit(); 
		}
	}

	this.set_formID(attributes.id);;		
	this.set_action(attributes.action);
	this.set_method(attributes.method);
	this.set_target(attributes.target);
	this.set_onSubmit(attributes.onSubmit);
	
	this.createForm();
} 

