/**
 * Table Column Model
 */
function IpacsTableColumnModel(inColumnConfig){
	this.COLUMN_NAME = 0;
	this.COLUMN_DESC = 1;
	this.COLUMN_WIDTH = 2;
	this.COLUMN_CLASS = 3;
	this.COLUMN_ALLOWEMPTY = 4;
	this.COLUMN_EDITABLE = 5;
	this.COLUMN_EDITOR = 6;
	this.COLUMN_EDITORPARAMS = 7;
	this.COLUMN_TOTALPATTERN = 8;

	this.alignType = new ActiveXObject("Scripting.Dictionary");
	this.alignType.Add("boolean", "center");
	this.alignType.Add("date", "left");
	this.alignType.Add("time", "right");
	this.alignType.Add("string", "left");
	this.alignType.Add("number", "right");
	this.alignType.Add("id", "center");
	this.alignType.Add("party", "left");
	this.alignType.Add("sku", "left");

	this.rendererType = new ActiveXObject("Scripting.Dictionary");
	this.rendererType.Add("boolean", "this.rendererBoolean");
	this.rendererType.Add("date", "this.rendererDate");
	this.rendererType.Add("time", "this.rendererTime");
	this.rendererType.Add("string", "this.rendererString");
	this.rendererType.Add("number", "this.rendererNumber");
	this.rendererType.Add("id", "this.rendererId");
	this.rendererType.Add("party", "this.rendererString");
	this.rendererType.Add("sku", "this.rendererString");

	this.editorType = new ActiveXObject("Scripting.Dictionary");
	this.editorType.Add("boolean", "BooleanEditor");
	this.editorType.Add("date", "DateEditor");
	this.editorType.Add("time", "TimeEditor");
	this.editorType.Add("string", "StringEditor");
	this.editorType.Add("number", "NumberEditor");
	this.editorType.Add("id", "IdEditor");
	this.editorType.Add("party", "PartyEditor");
	this.editorType.Add("sku", "SKUEditor");

	this.columnConfig = inColumnConfig;	

    this.columnIndex = new ActiveXObject("Scripting.Dictionary");
	for (var i=0; i<inColumnConfig.length; i++){
		this.columnIndex.Add(inColumnConfig[i][this.COLUMN_NAME], i);
        if (this.columnConfig[i][this.COLUMN_EDITOR] != null){
            this.columnConfig[i][this.COLUMN_EDITOR] = eval(this.columnConfig[i][this.COLUMN_EDITOR]);
        }
	}
}

IpacsTableColumnModel.prototype.swapColumn = function (aColumnIndex, bColumnIndex){
    var tempObj = this.columnConfig[aColumnIndex];
    this.columnConfig[aColumnIndex] = this.columnConfig[bColumnIndex];
    this.columnConfig[bColumnIndex] = tempObj;

    this.columnIndex = new ActiveXObject("Scripting.Dictionary");
	for (var i=0; i<this.columnConfig.length; i++){
		this.columnIndex.Add(this.columnConfig[i][this.COLUMN_NAME], i);	
	}
}

IpacsTableColumnModel.prototype.getColumnIndex = function (inColumnName){
	return this.columnIndex.Item(inColumnName);
}

IpacsTableColumnModel.prototype.getColumnCount = function(){
	if (this.columnConfig != null){
		return this.columnConfig.length;
	} else {
		return 0;
	}
}

IpacsTableColumnModel.prototype.getColumnName = function(index){
	return this.columnConfig[index][this.COLUMN_NAME];
}

IpacsTableColumnModel.prototype.getColumnDesc = function(index){
	return this.columnConfig[index][this.COLUMN_DESC];
}

IpacsTableColumnModel.prototype.getColumnWidth = function(index){
	return this.columnConfig[index][this.COLUMN_WIDTH];
}

IpacsTableColumnModel.prototype.getColumnClass = function(index){
	return this.columnConfig[index][this.COLUMN_CLASS];
}

IpacsTableColumnModel.prototype.getColumnAlign = function(index){	
	return this.alignType.Item(this.getColumnClass(index));
}

IpacsTableColumnModel.prototype.isColumnAllowEmpty = function(index){	
	return this.columnConfig[index][this.COLUMN_ALLOWEMPTY];
}

IpacsTableColumnModel.prototype.isColumnEditable = function(index){	
	return this.columnConfig[index][this.COLUMN_EDITABLE];
}

IpacsTableColumnModel.prototype.getColumnEditor = function(index){	
	return this.columnConfig[index][this.COLUMN_EDITOR];
}

IpacsTableColumnModel.prototype.setColumnEditor = function(index, inEditor){	
	this.columnConfig[index][this.COLUMN_EDITOR] = inEditor;
}

IpacsTableColumnModel.prototype.getColumnEditorParams = function(index){	
	return this.columnConfig[index][this.COLUMN_EDITORPARAMS];
}

IpacsTableColumnModel.prototype.getColumnTotalPattern = function(index){	
	return this.columnConfig[index][this.COLUMN_TOTALPATTERN];
}

IpacsTableColumnModel.prototype.release = function(){	
	this.alignType = undefined;
    this.editorType = undefined;
    this.columnIndex = undefined;
    this.columnConfig = undefined;
}