// 
// File:	SimpleForm.js
// Author:	Rob Allen
// Created:	January 15, 2002
//
// Purpose:	To provide a simple form, having a single column of one or more fields with the label
//		located above the field. Fields are defined by the FieldFactory class. Each form class 
//		must support the following interface:
//
//		addField(fieldDescription)
//		fieldDescription ::= same as input to field factory ctor.
//
//		getHTML()
//
//
// Copyright (c) 2002, ThoughtByDesign. All rights reserved.
// 
// This computer program is protected by copyright law and international treaties.
// Unauthorized reproduction or distribution of this program, or any portion of it,
// may result in severe civil and criminal penalties, and will be prosecuted to the
// maximum extent possible under the law.
// 
// Modification History: 
//	RLA, 1/15/2002, Creation and initial definition
// 


function SimpleForm(title) {

	this.formTitle = title;
	this.fieldList = new Array();
}


SimpleForm.prototype.addField = function(fieldLabel, fieldDescription) {
	this.fieldLabel = fieldLabel;
	this.fieldList[this.fieldList.length] = {_label: fieldLabel, _description: fieldDescription};
} // addField()


SimpleForm.prototype.getHTML = function() {

	var stringToWrite = "<TABLE cellspacing='2px' cellpadding='3px' valign='top'>";
	
	if (this.formTitle != null && this.formTitle.length > 0) {
		stringToWrite += "<TR><TD CLASS=clsHeaderBar>"+this.formTitle+"</TD></TR>";
	} // if
	
	for (var i = 0; i < this.fieldList.length; i++) {
		stringToWrite += "<TR><TD class='clsField'>";
		stringToWrite += "<SPAN class='clsFieldLabel'>"+this.fieldList[i]._label+"</SPAN><BR>";
		var field = new FieldFactory(this.fieldList[i]._description);
		stringToWrite += field.getHTML();
		stringToWrite += "</TD></TR>";
	} // for
	stringToWrite += "</TABLE>";
	
	return stringToWrite;
} // getHTML()	
	

