// test 
function FormElement(id, name, elementLabel, elementValue, editor, defaultText) {
	this.id = id;
	this.name = name;
	this.elementLabel = elementLabel;
	this.elementValues = new Array();
	this.elementValue = "";
	if((typeof elementValue == "object") && ( elementValue instanceof Array)) {
		this.elementValues = elementValue;
		if (this.elementValues.length > 0) {
			this.elementValue = this.elementValues[0];
		}
	} else {
		this.elementValue = String(elementValue);
		this.elementValues.push(this.elementValue);
	}
	this.editor = editor;
	this.defaultText = defaultText;
	this.options = new Array();
	this.attributes = new Array();
	// init the unset values...
	this.hintText = null;
	this.hasError = false;
	this.hasInfo = false;
	this.isReadonly = false;
	this.isDisplayedAsText = false;
	this.isHidden = false;
	this.mandatory = false;
	this.multiValued = false;
	this.changeValueEvent = null;
}
FormElement.prototype.addOption = function(name, value) {
    this.options.push(name);
    this.options.push(value);
};
FormElement.prototype.hasOptions = function() {
    return this.options.length > 0;
};
FormElement.prototype.getOptionCount = function() {
    if (this.options.length <= 0) return 0;
    return this.options.length / 2;
};
FormElement.prototype.getSelectedOptionIndex = function() {
	if (this.options.length <= 0) return 0;
	if (this.elementValue == "") return 0;
	for (i=0; i<this.options.length; i=i+2) {
		if (this.options[i+1] == this.elementValue) {
			return i / 2;
		}
	}
};
FormElement.prototype.setAttribute = function(name, value) {
	for (i=0; i<this.attributes.length; i=i+2) {
		if (this.attributes[i]==name) {
			this.attributes[i+1] = value;
			return;
		}
	}
	this.attributes.push(name);
	this.attributes.push(value);
};
FormElement.prototype.getAttribute = function(name) {
	for (i=0; i<this.attributes.length; i=i+2) {
		if (this.attributes[i]==name) {
			return this.attributes[i+1];
		}
	}
	return null;
};
FormElement.prototype.hasAttribute = function(name) {
	for (i=0; i<this.attributes.length; i=i+2) {
		if (this.attributes[i]==name) {
			return true;
		}
	}
	return false;
};
FormElement.prototype.hasChangeValueEvent = function() {
	return this.changeValueEvent != null && this.changeValueEvent != "";
};
FormElement.prototype.toString = function() {
	return this.name + "=" + this.elementValue;
};

