//////////////////////////////////////////////////////////////////////////////////////////////////////
// TIGER DEMOG OPTION
//////////////////////////////////////////////////////////////////////////////////////////////////////

// TigerDemogOption object - to define information about individual possible answers to a demographic
// in particular to specify 'Other Text' settings.
function TigerDemogOption(cID) {
	this.DemogValue = cID;
	this.OtherTextAllowed = false;
}

// AddOtherText - creates a 'TigerField' object to store the OtherText field. Note that 
// while being a TigerField object, it won't be accessible from the top level RegForm object.
// Most of the properties and methods are not relevant to OtherText.
TigerDemogOption.prototype.AddOtherText = function (cFieldName) {
	this.OtherTextAllowed = true;
	this.OtherText = new TigerField(cFieldName);
	this.OtherText.parent = this;
	this.OtherText.Form = this.Form;
	return this.OtherText;
}

// OptionChosen - method to get information about whether this option is currently selected
TigerDemogOption.prototype.OptionChosen = function () {
	uVal = this.parent.GetValue();
	if (isArray(uVal)) {
		return inArray(uVal, this.DemogValue);
	} else {
		return uVal == this.DemogValue;
	}
}

// SetConditionals - sets the display status of the 'OtherText' field, based on the data value 
TigerDemogOption.prototype.SetConditionals = function () {
	if (this.OtherTextAllowed) {
		if (this.OptionChosen()) {
			this.OtherText.SetDisplayStatus(this.OtherText.DisplayStatusIfActive)
		} else {
			this.OtherText.SetDisplayStatus(this.OtherText.DisplayStatusIfNotActive)
		}
	}
}

// SetDisplayStatus - called in recursion on the whole TigerField control
TigerDemogOption.prototype.SetDisplayStatus = function (DisplayStatus) {
	if (this.OtherTextAllowed) {
		if (DisplayStatus == eDisplayStatus.Normal) {
			this.SetConditionals();
		} else {
			if (this.OtherText.IsVisible) {
				this.OtherText.SetDisplayStatus(DisplayStatus);
			}
		}
	}
}

