if ((top.TableSetInit == "undefined") || (top.TabSetInit != true))
{
	/**
	*
	* TableSet CLASS definition.
	*
	*/
	
	function TableSet(tableSetName){
		this.tableName = tableSetName;
		this.doc;
		this.table = null;
		this.rowsList = null;
		this.currentrow="";
		this.highlightOnSelect = true;
	}

	TableSet.prototype.getDocument = function()
	{
		return this.doc;
	}

	TableSet.prototype.getHtmlComponent = function()
	{
		return this.table;
	}

	TableSet.prototype.setHighlightOnSelect = function(_highlightOnSelect)
	{
		this.highlightOnSelect = _highlightOnSelect;
	}

	TableSet.prototype.highlightRow = function (table){
		if (typeof this.rowsList == "undefined"){
			this.initializeRowData();
		}
		for (i=0; i < this.rowsList.length; i++){
			this.rowsList[i].className = "row";
		}
		if ( this.highlightOnSelect == true ) {
			table.className = "row activeRow";
		}
	}

	TableSet.prototype.highlightRow = function (table, rowId){
		for ( var i = 0; i < this.rowsList.length; i++ ) {
			this.rowsList[i].className="row";
			if ( this.rowsList[i].id == rowId ) {
				this.rowsList[i].className="row highlight";
			}
		}
	}

	TableSet.prototype.highlightInitialRow = function (){
		if ( this.highlightOnSelect == true ) {
			if(this.rowsList[0] != "undefined" && this.rowsList[0] != null) {
				this.rowsList[0].className="row activeRow";
			}
		}
	}

	TableSet.prototype.initializeRowData = function (){
		this.table = this.doc.getElementById(this.tableName);
		this.rowsList = this.table.getElementsByTagName("TR");
	}


	TableSet.prototype.initializeRowDataInitial = function (documentObj){
		this.doc = documentObj;
		this.initializeRowData();
	}

	/**
	*
	* TableSet ACTION MANAGER definition.
	*
	* Handles user gestures
	*
	*/
	
	function TableSetActionManager(){
		this.tableSetArray = new Array();
	}

	TableSetActionManager.prototype.createNewTableSet = function (tableSetName, documentObj){
		var tableset = new TableSet(tableSetName);
		tableset.initializeRowDataInitial(documentObj);
		this.tableSetArray[tableSetName] = tableset;
		TableSetActionManager.setManager(tableSetName,this);
	}

	TableSetActionManager.prototype.getTableSet = function (tableSetName){
		return this.tableSetArray[tableSetName];
	}

	/**
	*
	* static data/methods
	*
	*/

	TableSetActionManager.handlerList = new Array();
	TableSetActionManager.managerList = new Array();

	TableSetActionManager.register = function (handler){
		TableSetActionManager.handlerList[TableSetActionManager.handlerList.length] = handler; 
	}

	TableSetActionManager.setManager = function(_table, _manager){
		TableSetActionManager.managerList[_table] = _manager;
	}

	TableSetActionManager.getManager = function(_table){
		return TableSetActionManager.managerList[_table];
	}

	TableSetActionManager.doRowSelected = function(_table, _row){
		TableSetActionManager.getManager(_table).getTableSet(_table).highlightRow(_row);
		var len = TableSetActionManager.handlerList.length;
		var handler;
		for(var i=0; i<len; i++){
			TableSetActionManager.handlerList[i].doRowSelected(_table,_row.id);
		}
	}

	TableSetActionManager.doRowHighlight = function(_table, _row){
		TableSetActionManager.getManager(_table).getTableSet(_table).highlightRow(_row);
		var len = TableSetActionManager.handlerList.length;
		var handler;
		for(var i=0; i<len; i++){
			TableSetActionManager.handlerList[i].doRowHighlighted(_table,_row.id);
		}
	}

	TableSetActionManager.doRowDoubleClick = function(_table,_row){
		var len = TableSetActionManager.handlerList.length;
		var handler;
		for(var i=0; i<len; i++){
			TableSetActionManager.handlerList[i].doRowDoubleClick(_table,_row.id);
		}
	}
	
	////////////////////////
	
	top.TableSetInit = true;
	
}