/**
 * jsArp3Dynamic.js
 * Classes for handling dynamic modification of forms for AutoResponderPlus 3 (ARP3)
 * entry data
 *
 * 04/28/2008
 * 
 * Dependencies:
 * Prototype (1.6.0+)
 * 
 * Developer:
 * Kris Hardy (www.submergedsolutions.com)
 * 
**/

/**
 * CLASS: jsArp3Dynamic
 * 
 * INITIALIZATION:
 * function initialize (form:DOM object or form name)
 *  Use: Binds form to class
 *  
 * 	in - form (as DOM object or form name)
 *  out - void
 * 
 * PUBLIC FUNCTIONS:
 * function set (parameters: array('fieldname'=>'value'...)
 *  Use: Sets field values
 *  
 * 	in - parameters in array('fieldname'=>'value, 'fieldname'=>'value', ...)
 * 	out - void (sets fields identified by fieldname to value=value)
 * 
 * PRIVATE FUNCTIONS:
 * 
**/

var jsArp3Dynamic = Class.create({
	initialize: function(form) {
		this._form = $(form);
		this._debug = false;
	},
	set: function(parameters) {
		var hash = $H(parameters);
		hash.each(function(pair) {
			this._form.elements[pair.key].value = pair.value;
			if (this._debug) {
				alert(pair.key+" "+pair.value);
			}
		}.bind(this))
	},
	getForm: function() {
		return this._form;
	},
	debugOn: function() {
		this._debug = true;
	},
	debugOff: function() {
		this._debug = false;
	}
});
