/** Lightweight package to handle form data alteration.
 *
 * @package FCAlteration
 * @requires FCValidation
 * @author Justin J. Moses
 * 
 * @copyright © Flexirent Capital Pty Ltd 
 * @version 1.0.1
 *
 * @history 
 *		-----------------------
 *		1.0.1	Ensures only formItems that have visible containers 
 *				be modified.
 *		1.0.0	Handles simple text concatenation and formatting of 
 *				multiple fields
 *		-----------------------
 */

function FC_AlterControl()
{
	
	this.alterations = new Array(); 
	this.aCount = 0;
	
	this.appendAlteration = function(newAlteration) 
	{
		this.alterations[this.aCount++] = newAlteration;
	}
	
	this.execute = function() 
	{
		for (var i in this.alterations) 
		{
			this.alterations[i].alter();
		}
		
	}

}

/** A basic alteration, modifying to some format string
 *
 * @param formItem (FC_FormItem) The item to modify
 * @param format (String) The format string to modify by. Each 
 *						  argument should be represented by "%n" 
 *					      where n is the number of the 
 *						  current argument to insert
 * @parma args (FC_FormItem[]) The array of formItems used in format
 */
function FC_Alteration(formItem, format, args)
{
	//formItem (FC_FormItem) :: the item to modify
	this.formItem = formItem; 
	
	//format (string) :: A formatted string 
	this.format = format;
	
	//args (FC_FormItem[]) :: 
	this.args = args; 
	
	//modify the form item to the specified format
	this.alter = function() 
	{
		if (!this.formItem.container.on) 
		{
			return;
		}
		
		var str = this.format; 
		
		for (var y in this.args) 
		{
			str = str.replace("%"+y, this.args[y].getValue());
		}
		
		this.formItem.setValue(str);
	}	

}


function FC_AlterationCompareList() 
{


}


