/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicForm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	DynmaicForm
	 *	This class provides a dynamic form implementation
	 *
	 *	@param width The width of the form
	 *	@param buttons Array of buttons
	 *	@param padding the padding on the form
	 *
	 *	@constructor
	 */
	function DynamicForm(width, buttons, padding) {
		this.i_width = width;
		this.i_padding = (padding == undefined ? 0 : padding);
		this.i_sections = Array();
		this.i_button_obj = Array();
		this.i_buttons = buttons;
	}
	
	/**
	 *	The height of buttons
	 */
	DynamicForm.buttonHeight = 18;
	
	/**
	 *	Get/Set the width of this form
	 *
	 *	@param width (Optional) The new width of this form
	 *
	 *	@return the current width of this form
	 */
	DynamicForm.prototype.width = function(width) {
		if (width != undefined) {
			this.i_width = width;
			for (var x = 0; x < this.i_sections.length; x++) {
				this.i_sections[x].width(width - (this.padding() * 2) - 3);
			}
			if (this.i_form != undefined) {
				this.i_form.width = this.width() + "px";
				this.i_form_pad_top.style.width = this.width() + "px";
				this.i_form_content.style.width = (this.width() - (this.padding() * 2)) + "px";
			}
		}
		return this.i_width;
	}
	
	/**
	 *	Get/Set the padding of this form
	 *
	 *	@param padding (Optional) The new padding of this form
	 *
	 *	@return the current padding on this form
	 */
	DynamicForm.prototype.padding = function(padding) {
		if (padding != undefined) {
			this.i_padding = padding;
			this.handleSectionHeight();
		}
		return this.i_padding;
	}
	
	/**
	 *	Handle when a button is clicked
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicForm.prototype.handleButtonClick = function(e) {
		if (this.onsubmit != undefined) {
			var o = new Object();
			o.type="submit";
			o.button = e.originalScope.value;
			this.onsubmit(o);
		}
	}
	
	/**
	 *	Get/Set the array of buttons
	 *
	 *	@param buttons (Optional) A new array of buttons
	 *
	 *	@return the current array of buttons
	 */
	DynamicForm.prototype.buttons = function(buttons) {
		if (buttons != undefined) {
			this.i_buttons = buttons;
			if (this.i_form != undefined) {
				for (var x = this.i_buttons.length - 1; x>=0; x--) {
					if (this.i_button_obj[x] == undefined) {
						var b = document.createElement('BUTTON');
						b.className = "DynamicForm_button";
						EventControl.listen(b, "onclick", this.handleButtonClick, this);
						b.style.height = DynamicForm.buttonHeight + "px";
						this.i_button_obj[x] = b;
						this.i_form_buttons.appendChild(b);
					}
					this.i_button_obj[x].style.display = "";
					this.i_button_obj[x].innerHTML = this.i_buttons[x];
					this.i_button_obj[x].value = this.i_buttons[x];
				}
				for (var x = this.i_buttons.length; x < this.i_button_obj.length; x++) {
					this.i_button_obj[x].style.display = "none";
				}
			}
		}
		return this.i_buttons;
	}
	
	/**
	 *	Get the height of the form
	 *
	 *	@return the height of the form
	 */
	DynamicForm.prototype.height = function() {
		var h = (this.padding() * 2) + DynamicForm.buttonHeight;
		for (var x = 0; x < this.i_sections.length; x++) {
			h+=this.i_sections[x].height();
		}
		return h;
	}
	
	/**
	 *	Get an array of sections in this form
	 *
	 *	@param index (Optional) The index of a section you want
	 *
	 *	@return the array of sections or a single input
	 */
	DynamicForm.prototype.sections = function(index) {
		if (index != undefined) {
			return this.i_sections[index];
		}
		return this.i_sections;
	}
	
	/**
	 *	Add a new section to this form
	 *
	 *	@param section The new section to add
	 *	@param beforeSection (Optional) The section to insert this before
	 *
	 *	@return the section that was just added
	 */
	DynamicForm.prototype.addSection = function(section, beforeSection) {
		var append = true;
		if (beforeSection != undefined) {
			for (var x = 0; x < this.i_sections.length; x++) {
				if (this.i_sections[x] == beforeSection) {
					this.i_sections.splice(x, 0, section);
					append = false;
					if (this.i_form != undefined) {
						this.i_form_content.insertBefore(section.getSection(), beforeSection.getSection());
					}
					break;
				}
			}
		}
		if (append) {
			this.i_sections[this.i_sections.length] = section;
			if (this.i_form != undefined) {
				this.i_form_content.appendChild(section.getSection());
			}
		}
		section.width(this.width() - (this.padding() * 2) - 3);
		section.i_rh_l = EventControl.listen(section, "onheight", this.handleSectionHeight, this);
		return section;
	}
	
	/**
	 *	Remove a section
	 *
	 *	@param section the section to remove
	 *
	 *	@return true if the section was removed, false otherwise
	 */
	DynamicForm.prototype.removeSection = function(section) {
		for (var x = 0; x < this.i_sections.length; x++) {
			if (this.i_sections[x] == section) {
				this.i_sections.splice(x, 1);
				section.i_rh_l.destroy();
				if (this.i_form != undefined) {
					this.i_form_content.removeChild(section.getSection());
				}
				return true;
			}
		}
		return false;
	}
	
	/**
	 *	Handler for when a section changes height
	 *
	 *	@private
	 *
	 *	@param e The event that triggered this
	 */
	DynamicForm.prototype.handleSectionHeight = function(e) {
		if (this.i_form != undefined) {
			this.i_form.height = this.height() + "px";
			this.i_form_pad_top.style.height = this.padding() + "px";
			this.i_form_pad_left.style.width = this.padding() + "px";
			this.i_form_pad_left.style.height = (this.height() - this.padding()) + "px";
			this.i_form_content.style.height = (this.height() - this.padding() - DynamicForm.buttonHeight) + "px";
		}
	}
	
	/**
	 *	Get the DIV that contains this form
	 *
	 *	@return the DIV that contains this form
	 */
	DynamicForm.prototype.getForm = function() {
		if (this.i_form == undefined) {
			this.i_form = document.createElement('DIV');
			this.i_form.className = "DynamicForm";
			this.i_form.width = this.width() + "px";
			this.i_form.height = this.height() + "px";
			
				this.i_form_pad_top = document.createElement('DIV');
				this.i_form_pad_top.className = "DynamicForm_padding_top";
				this.i_form_pad_top.style.width = this.width() + "px";
				this.i_form_pad_top.style.height = this.padding() + "px";
				this.i_form_pad_top.innerHTML = "&nbsp;";
				this.i_form.appendChild(this.i_form_pad_top);
			
				this.i_form_pad_left = document.createElement('DIV');
				this.i_form_pad_left.className = "DynamicForm_padding_left";
				this.i_form_pad_left.style.width = this.padding() + "px";
				this.i_form_pad_left.style.height = (this.height() - this.padding()) + "px";
				this.i_form_pad_left.innerHTML = "&nbsp;";
				this.i_form.appendChild(this.i_form_pad_left);
				

				this.i_form_content = document.createElement('DIV');
				this.i_form_content.className = "DynamicForm_content";
				this.i_form_content.style.width = (this.width() - (this.padding() * 2)) + "px";
				this.i_form_content.style.height = (this.height() - this.padding() - DynamicForm.buttonHeight) + "px";
				this.i_form.appendChild(this.i_form_content);

					for (var x = 0; x < this.i_sections.length; x++) {
						this.i_form_content.appendChild(this.i_sections[x].getSection());
					}
					
				this.i_form_buttons = document.createElement('DIV');
				this.i_form_buttons.className = "DynamicForm_buttons";
				this.i_form_buttons.style.width = (this.width() - (this.padding() * 2)) + "px";
				this.i_form_buttons.style.height = DynamicForm.buttonHeight + "px";
				this.i_form.appendChild(this.i_form_buttons);
				
				this.buttons(this.buttons());
		}
		return this.i_form;
	}
	
/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicSection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	DynamicSection
	 *	This class provides a section in the form
	 *
	 *	@param title (Optional) any title text
	 *	@param description (Optional) Any description text
	 *
	 *	@constructor
	 */
	function DynamicSection(title, description) {
		this.title(title);
		this.description(description);
		
		this.i_inputs = Array();
	}
	
	/**
	 *	Get/Set the width of this section
	 *
	 *	@param width (Optional) The new width of this section
	 *
	 *	@return the current width of this section
	 */
	DynamicSection.prototype.width = function(width) {
		if (width != undefined) {
			this.i_width = width;
			if (this.i_section != undefined) {
				this.i_section_title.style.width = width + "px";
				this.i_section_description.style.width = width + "px";
			}
			for (var x = 0; x < this.i_inputs.length; x++) {
				this.i_inputs[x].width(width);
			}
		}
		return this.i_width;
	}
	
	/**
	 *	Get the height of this section
	 *
	 *	@return the height of this section
	 */
	DynamicSection.prototype.height = function() {
		var h = this.i_title_height + this.i_description_height;
		for (var x = 0; x < this.i_inputs.length; x++) {
			h+=this.i_inputs[x].height();
		}
		return h;
	}
	
	/**
	 *	Get/Set the title of this section
	 *
	 *	@param title (Optional) The new title of this section
	 *
	 *	@return the current title of this section
	 */
	DynamicSection.prototype.title = function(title) {
		if (title != undefined) {
			this.i_title = title;
			if (this.i_section != undefined) {
				this.i_section_title.innerHTML = this.title();
			}
			this.i_title_h = Environment.getTextDimension(title, "DynamicSection_title_adjust", this.width());
			this.i_title_height = this.i_title_h[1];
			this.handleInputHeight();
		}
		return this.i_title;
	}

	/**
	 *	Get/Set the description of this section
	 *
	 *	@param description (Optional) The new description of this section
	 *
	 *	@return the current description of this section
	 */
	DynamicSection.prototype.description = function(description) {
		if (description != undefined) {
			this.i_description = description;
			if (this.i_section != undefined) {
				this.i_section_description.innerHTML = this.description();
			}
			this.i_description_h = Environment.getTextDimension(description, "DynamicSection_description_adjust", this.width());
			this.i_description_height = this.i_description_h[1];
			this.handleInputHeight();
		}
		return this.i_description;
	}
	
	/**
	 *	Handle when an inputs height changes
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicSection.prototype.handleInputHeight = function(e) {
		if (this.i_section != undefined) {
			this.i_section.style.height = this.height() + "px";
			this.i_section_title.style.height = this.i_title_height + "px";
			this.i_section_description.style.height = this.i_description_height + "px";
		}
		if (this.onheight != undefined) {
			var o = new Object();
			o.type="height";
			this.onheight(o);
		}
	}
	
	/**
	 *	Get an array of inputs
	 *
	 *	@param index (Optional) The index of an input you want
	 *
	 *	@return the array of inputs or a single input if an index was provided
	 */
	DynamicSection.prototype.inputs = function(index) {
		if (index != undefined) {
			return this.i_inputs[index];
		}
		return this.i_inputs;
	}
	
	/**
	 *	Add a new input to the section
	 *
	 *	@param input The input to add
	 *	@param beforeInput (Optional) The input to insert this input before
	 *
	 *	@return the input which was just added
	 */
	DynamicSection.prototype.addInput = function(input, beforeInput) {
		var append = true;
		if (beforeInput != undefined) {
			for (var x = 0; x < this.i_inputs.length; x++) {
				if (this.i_inputs[x] == beforeInput) {
					this.i_inputs.splice(x, 0, input);
					if (this.i_section != undefined) {
						this.i_section.insertBefore(input.getInput(), beforeInput.getInput());
					}
					append = false;
					break;
				}
			}
		}
		if (append) {
			this.i_inputs[this.i_inputs.length] = input;
			if (this.i_section != undefined) {
				this.i_section.appendChild(input.getInput());
			}
		}
		input.width(this.width());
		input.i_rh_l = EventControl.listen(input, "onheight", this.handleInputHeight, this);
		this.handleInputHeight();
		return input;
	}
	
	/**
	 *	Remove an input from this section
	 *
	 *	@param input the input to remove
	 *
	 *	@return the input which was just removed
	 */
	DynamicSection.prototype.removeInput = function(input) {
		for (var x = 0; x < this.i_inputs.length; x++) {
			if (this.i_inputs[x] == input) {
				this.i_inputs.splice(x, 1);
				input.i_rh_l.destroy();
				if (this.i_section != undefined) {
					this.i_section.removeChild(input.getInput());
				}
				this.handleInputHeight();
				return true;
			}
		}
		return false;
	}
	
	/**
	 *	Get the DIV that contains this section
	 *
	 *	@return the DIV that contains this section
	 */
	DynamicSection.prototype.getSection = function() {
		if (this.i_section == undefined) {
			this.i_section = document.createElement('DIV');
			this.i_section.className = "DyanmicSection";
			this.i_section.style.width = this.width() + "px";
			this.i_section.style.height = this.height() + "px";
			
				this.i_section_title = document.createElement('DIV');
				this.i_section_title.className = "DynamicSection_title";
				this.i_section_title.innerHTML = this.title();
				this.i_section_title.style.width = this.width() + "px";
				this.i_section_title.style.height = this.i_title_height + "px";
				this.i_section.appendChild(this.i_section_title);
				
				this.i_section_description = document.createElement('DIV');
				this.i_section_description.className = "DynamicSection_description";
				this.i_section_description.style.width = this.width() + "px";
				this.i_section_description.style.height = this.i_description_height + "px";
				this.i_section_description.innerHTML = this.description();
				this.i_section.appendChild(this.i_section_description);
			
			
				for (var x = 0; x < this.i_inputs.length; x++) {
					this.i_section.appendChild(this.i_inputs[x].getInput());
				}
		}
		return this.i_section;
	}
	
/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicInput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
*/
	/**
	 *	DynamicInput
	 *	This class is the super class for any input in a dynamic form
	 *
	 *	@constructor
	 */
	function DynamicInput() {
	}
	
	/**
	 *	The super constructor
	 *
	 *	@param name The name of the input
	 *	@param description The description of the input
	 *	@param value The default vlaue of the input
	 */
	DynamicInput.prototype.superDynamicInput = function(name, description, value) {
		this.i_name = "&nbsp;";
		this.i_description = "";
		this.i_value = "";
		this.i_width = 100;
		this.i_height = 18;
		this.i_description_height = 0;
		this.i_label_height = 0;
		
		EventControl.listen(this, "onheight", this.handleHeightChange, this);
		
		this.name(name);
		this.description(description);
		this.value(value);
	}
	
	/**
	 *	The width of a label
	 */
	DynamicInput.labelWidth = 80;
	
	/**
	 *	Get/Set the width of this input
	 *
	 *	@parma width (Optional) The new width of this input
	 *
	 *	@return the current width of this input
	 */
	DynamicInput.prototype.width = function(width) {
		if (width != undefined) {
			this.i_width = width;
			this.i_description_h = Environment.getTextDimension(this.description(), "DynamicInput_description_adjust", (this.width() - DynamicInput.labelWidth));
			this.i_description_height = this.i_description_h[1];
			if (this.onheight != undefined) {
				var o = new Object();
				o.type="height";
				this.onheight(o);
			}
			if (this.onwidth != undefined) {
				var o = new Object();
				o.type="width";
				this.onwidth(o);
			}
		}
		return this.i_width;
	}
	
	/**
	 *	Get the width of the input object
	 *
	 *	@return the width of hte input object
	 */
	DynamicInput.prototype.inputWidth = function() {
		return this.width() - DynamicInput.labelWidth;
	}
	
	/**
	 *	Get/Set the height of this input
	 *
	 *	@return the current height of this input
	 */
	DynamicInput.prototype.height = function() {
		var h = this.i_height + (this.i_description_height == 0 ? 3 : this.i_description_height) + (document.all ? 4 : 0);
		if (this.i_label_height > h) {
			return this.i_label_height;
		}
		return h;
	}

	
	/**
	 *	Get/Set the height of this input
	 *
	 *	@param height (Optional) The new height of this input
	 *
	 *	@return the current height of this input
	 */
	DynamicInput.prototype.inputHeight = function(height) {
		if (height != undefined) {
			this.i_height = height;
			if (this.onheight != undefined) {
				var o = new Object();
				o.type="height";
				this.onheight(o);
			}
		}
		return this.i_height;
	}

	/**
	 *	Get/Set the name of this input
	 *
	 *	@param name (Optional) The new name of this input
	 *
	 *	@return the current name of this input
	 */
	DynamicInput.prototype.name = function(name) {
		if (name != undefined) {
			this.i_name = name;
			this.i_name_h = Environment.getTextDimension(name, "DynamicInput_name_adjust", DynamicInput.labelWidth);
			this.i_label_height = this.i_name_h[1];
			if (this.onheight != undefined) {
				var o = new Object();
				o.type="height";
				this.onheight(o);
			}
		}
		return this.i_name;
	}
	
	/**
	 *	Get/Set the description of this input
	 *
	 *	@param description (Optional) The new description of this input
	 *
	 *	@return the current description of this input
	 */
	DynamicInput.prototype.description = function(description) {
		if (description != undefined) {
			this.i_description = description;
			this.i_description_h = Environment.getTextDimension(description, "DynamicInput_description_adjust", (this.width() - DynamicInput.labelWidth));
			this.i_description_height = this.i_description_h[1];
			if (this.onheight != undefined) {
				var o = new Object();
				o.type="height";
				this.onheight(o);
			}
		}
		return this.i_description;
	}
	
	/**
	 *	Get/Set the value of this input
	 *
	 *	@param value (Optional) The new value of this input
	 *
	 *	@return the current value of this input
	 */
	DynamicInput.prototype.value = function(value) {
		if (value != undefined) {
			this.i_value = value;
		}
		return this.i_value;
	}
	
	/**
	 *	Handler used to fix the height of the DIV's
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicInput.prototype.handleHeightChange = function(e) {
		if (this.i_input != undefined) {
			this.i_input.style.height = this.height() + "px";
			this.i_input.style.width = this.width() + "px";
			this.i_input_name.style.height = this.height() + "px";
			this.i_input_holder.style.height = this.inputHeight() + "px";
			this.i_input_holder.style.width = (this.width() - DynamicInput.labelWidth) + "px";
			this.i_input_description.style.height = this.i_description_height + "px";
			this.i_input_description.style.width = (this.width() - DyanmicInput.labelWidth) + "px";
		}
	}
	
	/**
	 *	Get the DIV that contains this input
	 *
	 *	@return the DIV that contains this input
	 */
	DynamicInput.prototype.getInput = function() {
		if (this.i_input == undefined) {
			this.i_input = document.createElement('DIV');
			this.i_input.className = "DynamicInput";
			this.i_input.style.width = this.width() + "px";
			this.i_input.style.height = this.height() + "px";
				this.i_input_name = document.createElement('DIV');
				this.i_input_name.className = "DynamicInput_name";
				this.i_input_name.style.width = DynamicInput.labelWidth + "px";
				this.i_input_name.style.height = this.height() + "px";
				this.i_input_name.innerHTML = this.name();
				this.i_input.appendChild(this.i_input_name);
				
				this.i_input_holder = document.createElement('DIV');
				this.i_input_holder.className = "DynamicInput_holder";
				this.i_input_holder.style.width = (this.width() - DynamicInput.labelWidth) + "px";
				this.i_input_holder.style.height = this.inputHeight() + "px";
				this.i_input.appendChild(this.i_input_holder);
				
					if (this.getInputObject != undefined) {
						this.i_input_holder.appendChild(this.getInputObject());
					}
					else {
						this.i_input_holder.innerHTML = "&nbsp;";
					}
				
				this.i_input_description = document.createElement('DIV');
				this.i_input_description.className = "DynamicInput_description";
				this.i_input_description.style.width = (this.width() - DynamicInput.labelWidth) + "px";
				this.i_input_description.style.height = (this.i_description_height) + "px";
				if (document.all) {
					this.i_input_description.style.paddingTop="4px";
				}
				this.i_input_description.innerHTML = this.description();
				this.i_input.appendChild(this.i_input_description);
			
		}
		return this.i_input;
	}

	/**
	 *	Get the DIV that contains the actual input object
	 *
	 *	@return the DIV that contains the actual input object
	 */
	DynamicInput.prototype.getInputObject = null;
	
/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicTextInput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	DynamicTextInput
	 *	This input provides a simple text field
	 *
	 *	@param name the name of the input
	 *	@param description the description of the input
	 *	@param value The default value of the input
	 *
	 *	@constructor
	 */
	function DynamicTextInput(name, description, value) {
		this.superDynamicInput(name, description, value);
		this.inputHeight(document.all ? 18 : 22);
		EventControl.listen(this, "onwidth", this.handleWidth, this);
	}
	
	/**
	 *	Handle when the width is changed
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicTextInput.prototype.handleWidth = function(e) {
		if (this.i_input_obj != undefined) {
			this.i_input_obj.style.width = this.inputWidth() + "px";
		}
	}
	
	/**
	 *	Get/Set the value of this input
	 *
	 *	@param value (Optional) The new value of this input
	 *
	 *	@return the current value of this input
	 */
	DynamicTextInput.prototype.value = function(value) {
		if (value != undefined) {
			this.i_value = value;
			if (this.i_input_obj != undefined) {
				this.i_input_obj.value = value;
			}
		}
		return (this.i_input_obj != undefined ? this.i_input_obj.value : this.i_value);
	}
	
	/**
	 *	Get the actual input object
	 *
	 *	@return the actual input object
	 */
	DynamicTextInput.prototype.getInputObject = function() {
		if (this.i_input_obj == undefined) {
			this.i_input_obj = document.createElement('INPUT');
			this.i_input_obj.className = "DynamicTextInput";
			this.i_input_obj.type = "text";
			this.i_input_obj.value = this.value();
			this.i_input_obj.style.width = this.inputWidth() + "px";
			this.i_input_obj.style.height = (this.inputHeight()) + "px";
		}
		return this.i_input_obj;
	}
	
	DynamicTextInput.inherit(DynamicInput);
	
/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicTextAreaInput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	DynamicTextAreaInput
	 *	This input provides a textarea field
	 *
	 *	@param name the name of the input
	 *	@param description the description of the input
	 *	@param value The default value of the input
	 *	@param height (Optional) The height of the text area
	 *
	 *	@constructor
	 */
	function DynamicTextAreaInput(name, description, value, height) {
		this.superDynamicInput(name, description, value);
		this.inputHeight((height != undefined ? height : 80));
		EventControl.listen(this, "onwidth", this.handleWidth, this);
	}
	
	/**
	 *	Handle when the width is changed
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicTextAreaInput.prototype.handleWidth = function(e) {
		if (this.i_input_obj != undefined) {
			this.i_input_obj.style.width = this.inputWidth() + "px";
		}
	}
	
	/**
	 *	Get/Set the value of this input
	 *
	 *	@param value (Optional) The new value of this input
	 *
	 *	@return the current value of this input
	 */
	DynamicTextAreaInput.prototype.value = function(value) {
		if (value != undefined) {
			this.i_value = value;
			if (this.i_input_obj != undefined) {
				this.i_input_obj.value = value;
			}
		}
		return (this.i_input_obj != undefined ? this.i_input_obj.value : this.i_value);
	}
	
	/**
	 *	Get the actual input object
	 *
	 *	@return the actual input object
	 */
	DynamicTextAreaInput.prototype.getInputObject = function() {
		if (this.i_input_obj == undefined) {
			this.i_input_obj = document.createElement('TEXTAREA');
			this.i_input_obj.className = "DynamicTextInput";
			this.i_input_obj.value = this.value();
			this.i_input_obj.style.width = this.inputWidth() + "px";
			this.i_input_obj.style.height = (this.inputHeight()) + "px";
		}
		return this.i_input_obj;
	}
	
	DynamicTextAreaInput.inherit(DynamicInput);
	
	
/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DynamicOptionInput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	DynamicOptionInput
	 *	This input provides a textarea field
	 *
	 *	@param name the name of the input
	 *	@param description the description of the input
	 *	@param value The default value of the input
	 *	@param options (Optional) an array of options
	 *	@param rows (Optional) The number of rows to display
	 *
	 *	@constructor
	 */
	function DynamicOptionInput(name, description, value, options, rows) {
		if (rows == undefined) {
			rows = 1;
		}
		this.i_rows = rows;
		this.superDynamicInput(name, description, value);
		this.inputHeight(rows * DynamicOptionInput.rowHeight);
		this.i_options = options;
		this.i_rows = rows;
		EventControl.listen(this, "onwidth", this.handleWidth, this);
	}
	
	/**
	 *	The height of a row in the option box
	 */
	DynamicOptionInput.rowHeight = 15;
	
	/**
	 *	Handle when the width is changed
	 *
	 *	@private
	 *
	 *	@param e the event that triggered this
	 */
	DynamicOptionInput.prototype.handleWidth = function(e) {
		if (this.i_input_obj != undefined) {
			this.i_input_obj.style.width = this.inputWidth() + "px";
		}
	}
	
	/**
	 *	Get/Set the value of this input
	 *
	 *	@param value (Optional) The new value of this input
	 *
	 *	@return the current value of this input
	 */
	DynamicOptionInput.prototype.value = function(value) {
		if (value != undefined) {
			this.i_value = value;
			if (this.i_input_obj != undefined) {
				var ops = this.i_input_obj.getElementsByTagName('OPTION');
				for (var x = 0; x < ops.length; x++) {
					ops.selected = false;
					for (var z = 0; z < value.length; z++) {
						if (value[z] == ops.value) {
							ops.selected = true;
						}
					}
				}
			}
		}
		var v = this.i_value;
		if (this.i_input_obj != undefined) {
			var ops = this.i_input_obj.getElementsByTagName('OPTION');
			v = Array();
			for (var x = 0; x < ops.length; x++) {
				if (ops[x].selected == true) {
					v[v.length] = ops[x].value;
				}
			}
		}
		return v;
	}
	
	/**
	 *	Get the actual input object
	 *
	 *	@return the actual input object
	 */
	DynamicOptionInput.prototype.getInputObject = function() {
		if (this.i_input_obj == undefined) {
			this.i_input_obj = document.createElement('SELECT');
			this.i_input_obj.className = "DynamicTextInput";
			this.i_input_obj.style.width = this.inputWidth() + "px";
			this.i_input_obj.style.height = "auto";
			if (this.i_rows > 1) {
				this.i_input_obj.multiple = true;
			}
			this.i_input_obj.size = this.i_rows;
			
			for (var x = 0; x < this.i_options.length; x++) {
				var op = document.createElement('OPTION');
				op.value = this.i_options[x].value;
				op.innerHTML = "&nbsp;" + this.i_options[x].name;
				if (this.i_value != undefined && this.i_value.splice != undefined) {
					for (var z = 0; z < this.i_value.length; z++) {
						if (this.i_value[z] == this.i_options[x].value) {
							op.selected = true;
						}
					}
				}
				this.i_input_obj.appendChild(op);
			}
		}
		return this.i_input_obj;
	}
	
	DynamicOptionInput.inherit(DynamicInput);
