

if (!top.____SS2)
top.____SS2 = new function()
{
	this.CONECTIONSTATE = new function()
	{
		this.INITIALISING = 0;
		this.CONNECTION_ACTIVE = 1;
		this.CONECTION_STALE_OR_RECONENCTING = 2;
		this.CONNECTION_FAILURE = 3;
		this.CONNECTION_CLOSED = 4;
		this.MAX_CLIENT_REACHED = 5;
		this.UNAUTHORISED = 6;
		this.STRINGS = ['inicializando','conexion activa', 'conexion en stale o reconectando', 'fallo de conexion', 'conexion cerrada', 'maximo de clientes excedidos', 'conexion no autorizada'];
		this.getState = function(state)
		{
			var st = parseInt(state)
			return this.STRINGS[st];
		}
	};
	this.STATE = new function()
	{
		this.OK = 0;
		this.REQUEST_PENDING = 1;
		this.STALE = 2;
		this.NO_DATA_AVAILABLE = 3;
		this.REQUEST_ERROR = 4;
		this.NOT_PERMISIONED = 5;
		this.SERVICE_STALE = 6;
		this.SERVICE_UNKNOWN = 7;
		this.UNMONITORED_OR_DROPED = 8;
		this.RECORD_PAUSED = 9;
		this.ERROR_RECORD_PAUSED = 10;
		this.getState = function(state)
		{
			var st = parseInt(state)
			switch(st)
			{
				case 0: return 'OK';
				case 1: return 'REQUEST_PENDING';
				case 2: return 'STALE';
				case 3: return 'NO_DATA_AVAILABLE';
				case 4: return 'REQUEST_ERROR';
				case 5: return 'NOT_PERMISIONED';
				case 6: return 'SERVICE_STALE';
				case 7: return 'SERVICE_UNKNOWN';
				case 8: return 'UNMONITORED_OR_DROPED';
				case 9: return 'RECORD_PAUSED';
				case 10: return 'ERROR_RECORD_PAUSED';
				default: ;
			}
			return state;
		}
	};
	this.FLAGS = new function()
	{
		this.FULL_UPDATE = 0x00000000;
		this.PARTIAL_UPDATE = 0x00000001;
		this.DELAYED_DATA = 0x20000000;
		this.UPDATES_MISSED_OR_MERGED = 0x40000000;
		this.NAME_CHANGE_BIT = 0x80000000;
	};
	
	
	
}

function SS2Comunication(){
	this._SS2applet = null;
	this._SS2Callback = null;
	this._SS2Interaction = false;
	
	this.setSS2Applet = function(myapplet){
		this._SS2applet = myapplet;
		this.setSS2Interaction(this._SS2applet!=null);
	}
	
	this.setSS2Callback = function(callback){
		this._SS2Callback = callback;
	}
	
	this.setSS2Interaction = function(flag){
		this._SS2Interaction = flag;
	}
	
	this.getSS2Interaction = function(){
		return this._SS2Interaction;
	}
	
	this.request = function(records, fields){
		if(this._SS2applet!=null && records!=null && fields!=null){
			if(typeof records=='Array')
					records = records.join(",");
			if(typeof fields=='Array')
					fields = fields.join(",");
			if(this._SS2Callback != null)
				this._SS2applet.request(records,fields,this._SS2Callback);
			else
				this._SS2applet.request(records,fields);
		}
	};
	
	this.release = function(records, fields){
		if(this._SS2applet!=null && records!=null){
			if(typeof records=='Array')
					records = records.join(",");
			this._SS2applet.releaseRics(records);
		}
	};
	
}

function DynTable(uniqueTableName){		
	DynTable.myDynTables[uniqueTableName] = this;
	
	this.SS2Comunication = new SS2Comunication();
	
	this.setSS2Applet = function(myapplet){this.SS2Comunication.setSS2Applet(myapplet)};
	this.setSS2Callback = function(callback){this.SS2Comunication.setSS2Callback(callback)};
	
	
	this.autoSaveColumns = true;
	this.autoSaveRows = true;

	this.cellIdUnique=true;
	this.showResumeRow=false;
	this.resumeRowId ="RESUME"
	this.resumeRowTitle ="RESUME"
	this.table = document.createElement("TABLE");
	this.thead = document.createElement("THEAD");
	this.tbody = document.createElement("TBODY");
	this.tbody2 = document.createElement("TBODY");

	this.table.uniqueName = uniqueTableName;
	this.tableTitles = null;
	this.alignNumber = "right";
	this.alignText = "center";
	this.rowIdClass="insts"
	this.columnNames = null;
	this.columnIds = null;
	this.columnWidths = null;
	this.headerStyles = null;
	this.cellStyles = null;
	this.idText = "";
	
	this.useHeaderStyles = true;
	
	this.rowNames = null;
	this.rowIds = null;
	
	this.maxRows = -1;
	
	this.showRowId = true;
	this.rowIdColumnWidth = 205;
	this.showColId = true;
	this.showRemoveCol = false;
	this.showRemoveRow = false;
	
	this.removeRowAlt = top.DynTable.msgs.removeRowAlt;
	this.removeColAlt = top.DynTable.msgs.removeColAlt;
	
	this.changeColors = true;
	
	this.showOptionButton = false;
	this.optionRef = null;
	this.optionAlt = top.DynTable.msgs.optionAlt;
	this.optionButtonWidth = 12;
	this.contextMenu = null;
	
	this.showGraphButton = false;
	this.graphRef = null;
	this.graphAlt = top.DynTable.msgs.graphAlt;
	this.graphButtonWidth = 12;
	
	this.showSceneButton = false;
	this.sceneRef = null;
	this.sceneEvent = null;
	this.sceneAlt = top.DynTable.msgs.sceneAlt;
	this.sceneButtonWidth = 12;
	this.sceneImageSrc="images/escenario.gif"
	this.sceneImgWidth=9
	this.sceneImgHeight=9

	this.showCalcButton = false;
	this.calcRef = null;
	this.calcEvent = null;	
	this.calcAlt = top.DynTable.msgs.calcAlt;
	this.calcButtonWidth = 12;
	this.calcImageSrc="images/calc.gif"
	this.calcImgWidth=9
	this.calcImgHeight=9
	
	this.sortable = true;
	this.ascOrder = true;
	this.compareCol = 0;
	this.highLight = true;
	this.highLightTimeout = 3000;
	this.separeTitles = false;
	
	this.showAlternativeRowColors = false;
	
	this.showDetail = true;
	this.detailLinkRef = "detail.jsp?warrant=%r&idname=%n";
	this.detailLinkWidth = 640;
	this.detailLinkHeight = 670;
	
	this.removeRowButtonWidth = 12;
	this.removeColButtonWidth = 12;
	
	this.tmpOptionButton = new Image();
	this.tmpOptionButton.src = "images/option.gif";
	this.tmpgraphButton = new Image();
	this.tmpgraphButton.src = "images/graph.gif";
	
	this.colIconSources = null; //Array
	this.colIconDefaultSrc = null;
	this.colIconFid = null;
	this.colIconRepaintAllways = false;
	
	this.showRestoreColumns = true;
	
	this.cookieColumnIds = new Cookie("CI_" + this.table.uniqueName);
	this.cookieColumnNames = new Cookie("CN_" + this.table.uniqueName);
	this.cookieColumnWidths = new Cookie("CW_" + this.table.uniqueName);
	this.cookieColumnStyles = new Cookie("CS_" + this.table.uniqueName);
	
	this.cookieRowIds = new Cookie("RI_" + this.table.uniqueName);
	this.cookieRowNames = new Cookie("RN_" + this.table.uniqueName);
	
	this.defaultColumnIds = new Array();
	this.defaultColumnNames = new Array();
	this.defaultColumnWidths = new Array();
	this.defaultColumnStyles = new Array();
	
	this.multipleAppearance = false;
	this.appearanceId = 0;
	this.multipleColumnIds = new Array();
	this.multipleColumnNames = new Array();
	this.multipleColumnWidths = new Array();
	this.multipleColumnStyles = new Array();
					
	
	this.defaultRowIds = new Array();
	this.defaultRowNames = new Array();
	
	

	this.onBeforeOfRestoreColumns = function(defaultColumns){return true;};
	this.onAfterOfRestoreColumns = function(defaultColumns){return true;};
	
	this.onBeforeOfRemoveRow = function(rowId){return true;};
	this.onAfterOfRemoveRow = function(rowId){return true;};
	
	this.onBeforeOfRemoveCol = function(colId){return true;};
	this.onAfterOfRemoveCol = function(colId){return true;};
	
	this.onBeforeOfUpdateCell = function(cell,value){return true;};
	this.onAfterOfUpdateCell = function(cell){return true;};
	
	this.onBeforeAddCol = function(columnName, columnId, columnWidth, afterIndex ){return true;}
	this.onAfterAddCol = function(columnName, columnId, columnWidth, afterIndex ){return true;}
	
	this.getPreferedWidth = function()
	{
		var aux =0;
		for(var i=0; i<this.columnWidths.length;i++)
		{
			aux += this.columnWidths[i];
		}
		if(this.showRemoveRow) aux += this.removeRowButtonWidth;
		if(this.showOptionButton) aux += this.optionButtonWidth;
		if(this.showSceneButton) aux += this.sceneButtonWidth;
		if(this.showCalcButton) aux += this.calcButtonWidth;
		
		return aux;
	}
	this.firstDataColumn = function(){
		return ((this.showRowId)?1:0)+((this.showRemoveRow)?1:0)
	}
	this.firstTailButtonColumn = function(){
		return this.firstDataColumn()+this.columnIds.length; //- (this.showOptionButton?1:0) - (this.showGraphButton?1:0) - (this.showSceneButton?1:0) - (this.showCalcButton?1:0);
	}
	this.removeAllData = function(){
		for(var j=0;j<this.tbody.rows.length;j++)
			for(var i=this.firstDataColumn();i<this.firstTailButtonColumn();i++)
			{
				this.tbody.rows[j].cells[i].innerHTML="&nbsp;"
			}			
	}
	
	this.appendTableTo = function(elementId){
		var div = document.getElementById(elementId);
		if(div!=null)
			div.appendChild(this.table);
	}
	
	this.appendTableToNode = function(elementNode){
		if(elementNode!=null)
			elementNode.appendChild(this.table);
	}
	
	this.removeTableFromParent = function(){
		var parent = this.table.parentNode;
		if (parent != null)
			parent.removeChild(this.table);
		return parent;
	}
	
	this.getTableParent = function(){
		return this.table.parentNode;
	}
	
	this.appendTableTitlesTo = function(elementId){
		if(!this.separeTitles)return;
		var div = document.getElementById(elementId);
		if(div!=null)
			div.appendChild(this.tableTitles);
	}

	this.create = function(){
	
		var oRow;
		var oCell;
		var j;
		
		if(this.autoSaveColumns || this.autoSaveRows)
			this.load();
		
		if ((!this.columnNames) || (!this.rowIds) || (!this.columnIds))return;
		
		this.table.appendChild(this.tbody);
		
		if(this.separeTitles){
			this.tableTitles = document.createElement("TABLE");
			this.tableTitles.uniqueName = uniqueTableName;
			this.tableTitles.appendChild(this.thead);
		}else{
			this.table.appendChild(this.thead);
		}
			
		if(this.showRemoveCol)
			this.addRemoveColRow();
		
		if(this.showColId)
			this.addTitleRow();
			
		if(this.showOptionButton){
			this.contextMenu = new ContextMenu(this.table.uniqueName);
			if(this.divPopup)this.contextMenu.divPopup = this.divPopup;
			if(this.optionButtons)this.contextMenu.buttons = this.optionButtons;
			if(this.optionRef)this.contextMenu.onclickRef = this.optionRef;
			if(this.ContextMenuAlignedToLeft)this.contextMenu.alignedToLeft = this.ContextMenuAlignedToLeft;
		}
		
		if(this.showResumeRow)
		{
			this.tbody2 = document.createElement("TBODY");
			this.tbody2.className = "resume"
			this.table.appendChild(this.tbody2);
			this.makeRow(this.resumeRowId,this.resumeRowTitle, true);			
		}
		
		if(this.rowNames){
			for(j=0;j<this.rowIds.length;j++){
				this.makeRow(this.rowIds[j],this.rowNames[j]);
			}
		}else{
			for(j=0;j<this.rowIds.length;j++){
				this.makeRow(this.rowIds[j],this.rowIds[j]);
			}
		}
		this.alternateRowColors();
	
	}
	
	this.setWidthToCell = function(cell){
		if(this.columnWidths!=null){
			var pos = this.showRemoveCol==true?cell.cellIndex-1:cell.cellIndex;
			pos = this.showRowId?pos-1:pos;
			if(pos < this.columnWidths.length)
				if(this.columnWidths[pos])
					cell.width = this.columnWidths[pos];
			}
	}
	
	this.addRemoveColRow = function(){	
		oRow = this.thead.insertRow(0);
		oRow.id = "removeCols";
		if(this.showRemoveRow){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "headerId";
			oCell.width = this.removeRowButtonWidth;
			oCell.noWrap = true;
			oCell.className = "colButtons";
			oCell.innerHTML = "&nbsp;";
		}
		if(this.showRowId){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "headerId";
			oCell.noWrap = true;
			oCell.className = "colButtons";
			oCell.width = this.rowIdColumnWidth;
			oCell.innerHTML = "&nbsp;";
		}
		for(i=0;i<this.columnIds.length;i++){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "removeCol_"+this.columnIds[i];
			oCell.noWrap = true;
			this.addRemoveColButton(oCell);
		}
	}
	
	this.addTitleRow = function(){
		
		oRow = this.thead.insertRow(this.thead.rows.length);
		oRow.id = "titles";
		if(this.showRemoveRow){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "removeRowBlank";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.removeRowButtonWidth;
			if(this.showRestoreColumns)
				this.addRestoreColButton(oCell);
			else
				oCell.innerHTML = "&nbsp;";
		}
		if(this.showRowId){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "headerRowId";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.rowIdColumnWidth;
			oCell.appendChild(document.createTextNode(this.idText));
			if(this.sortable)
				this.addSortColButton(oCell);
		}
		for(var i=0;i<this.columnIds.length;i++){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = this.columnIds[i];
			oCell.noWrap = true;
			if(this.useHeaderStyles && this.headerStyles && this.headerStyles[i])
				oCell.className = this.headerStyles[i];
			else
				oCell.className = "headerRow";
			this.setWidthToCell(oCell);
			oCell.appendChild(document.createTextNode(this.columnNames[i]));
			if(this.sortable)
				this.addSortColButton(oCell);
		}
		if(this.showOptionButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "optionButtonBlank";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.optionButtonWidth;
			oCell.innerHTML = "&nbsp;";
			
		}
		if(this.showGraphButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "graphButtonBlank";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.graphButtonWidth;
			oCell.innerHTML = "&nbsp;";
		}
		if(this.showSceneButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "sceneButtonBlank";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.sceneButtonWidth;
			oCell.innerHTML = "&nbsp;";
		}
		if(this.showCalcButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "calcButtonBlank";
			oCell.noWrap = true;
			oCell.className = "headerRow";
			oCell.width = this.calcButtonWidth;
			oCell.innerHTML = "&nbsp;";
		}
	}
	
	this.alternateRowColors = function(){		
		var i;
		if(this.tbody.rows.length==0)return;		
		for(i=this.tbody.rows.length;i>0;){			
			--i;
			this.alternateRowColorsByRow(i);					
		}			
	}
	
	this.alternateRowColorsByRow = function(rowIndex){
		var ncells = this.tbody.rows[0].cells.length;
		var j,c;
		var row;
		var o;
		var t = 0;
		row = this.tbody.rows[rowIndex];
		if(this.showAlternativeRowColors && rowIndex%2==0){
			for(j=0;j<ncells;j++){
				o = row.cells[j];
				c = o.className;
				if(c.indexOf("PAR")==-1){
					c = "PAR" + c;	
					o.className = c;
				}
			}
		}else{
			for(j=0;j<ncells;j++){
				o = row.cells[j];
				c = o.className;				
				if(c.indexOf("PAR")>=0){
					c = c.replace("PAR","");
					o.className = c;
				}
			}		
		}
		
		
	}
	
	this.addRow = function(rowid,rowName){
		
		if (this.maxRows!=-1 && this.rowIds.length >=this.maxRows){
			alert(top.DynTable.msgs.errorMaxNumberExceed);
			return;
		}
		
		rowid = rowid.toUpperCase();
		
		for(i=0; i<this.rowIds.length; i++) {
			if(this.rowIds[i]==rowid){
				alert(top.DynTable.msgs.errorInstrumentAlreadyIncluded);
				return;
			}
		}
		
		this.rowIds[this.rowIds.length] = rowid;
		
		if(rowName)
		{
			if (this.rowNames == null) this.rowNames = new Array();
			this.rowNames[this.rowNames.length] = rowName;
			this.makeRow(rowid,rowName);
		}	
		else
		{
			if (this.rowNames != null)
				this.rowNames[this.rowNames.length] = rowid;
			this.makeRow(rowid,rowid);
		}
						
		
		this.alternateRowColorsByRow(this.tbody.rows.length-1);
		
		this.save();
	}
	
	this.makeRow = function(rowid,rowName, resumeRow){

		var oRow,oCell;
		
		if(!!resumeRow)
		{
			oRow = this.tbody2.insertRow(this.tbody2.rows.length);
			oRow.className = "resume"
		}
		else
		{
			oRow = this.tbody.insertRow(this.tbody.rows.length);	
			if(this.SS2Comunication.getSS2Interaction())
						this.SS2Comunication.request(rowid,this.columnIds);
				
		}	
		oRow.id = this.getRowId(rowid);	
		oRow.originalId = rowid;

		if(this.showRemoveRow){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "removeRow_"+oRow.id;
			oCell.noWrap = true;
			if(!resumeRow){
				this.addRemoveRowButton(oCell);
			}else
			{
				oCell.innerHTML = "&nbsp;";
				oCell.className = "resumeId";
				oCell.resumeRow = true;
			}
		}
		if(this.showRowId){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.noWrap = true;
			oCell.className = (!resumeRow)?this.rowIdClass:"resumeId";
			oCell.width = this.rowIdColumnWidth;
			if(this.showDetail && !resumeRow){
				this.addDetailLink(oCell,rowid,rowName);
			}else{
				oCell.appendChild(document.createTextNode(rowName));
			}
			if(resumeRow)oCell.resumeRow = true;
		}
		for(i=0;i<this.columnIds.length;i++){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = this.getDataCellId(rowid , this.columnIds[i]);
			oCell.noWrap = true;
			oCell.className = (!resumeRow)?"data":"resume";
			if(resumeRow)
				oCell.resumeRow = true;
			this.setWidthToCell(oCell);
			oCell.innerHTML = "&nbsp;";
			oCell.dynTable = this.table.uniqueName;
		}
		if(this.showOptionButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "optionRow_"+oRow.id;
			oCell.noWrap = true;
			if(!resumeRow)
				this.addOptionButton(oCell,rowid,rowName);	
			else
			{
				oCell.className = "resume"
				oCell.innerHTML = "&nbsp;";
				oCell.resumeRow = true;
			}
		}
		if(this.showGraphButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "graphRow_"+oRow.id;
			oCell.noWrap = true;
			if(!resumeRow)
				this.addGraphButton(oCell,rowid, rowName);	
			else
			{
				oCell.className = "resume"
				oCell.innerHTML = "&nbsp;";
				oCell.resumeRow = true;
			}
		}
		if(this.showSceneButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "sceneRow_"+oRow.id;
			oCell.noWrap = true;
			if(!resumeRow)
				this.addSceneButton(oCell,rowid, rowName);	
			else
			{
				oCell.className = "resume"
				oCell.innerHTML = "&nbsp;";
				oCell.resumeRow = true;
			}
		}
		if(this.showCalcButton){
			oCell = oRow.insertCell(oRow.cells.length);
			oCell.id = "calcRow_"+oRow.id;
			oCell.noWrap = true;
			if(!resumeRow)
				this.addCalcButton(oCell,rowid, rowName);	
			else
			{
				oCell.className = "resume"
				oCell.innerHTML = "&nbsp;";
				oCell.resumeRow = true;
			}
		}

	}
	
	
	this.addCustomCol = function(columnName, columnId, columnWidth, headerStyle, afterIndex ){
		this.SS2Comunication.setSS2Interaction(false);
		this.addCol(columnName, columnId, columnWidth, headerStyle, afterIndex, true);
		this.SS2Comunication.setSS2Interaction(true);
	}

	
	this.addCol = function(columnName, columnId, columnWidth, headerStyle, afterIndex, noCallCallback ){
		if(noCallCallback || this.onBeforeAddCol(columnName, columnId, columnWidth, headerStyle, afterIndex)){
			var col = (!afterIndex && afterIndex!=0)? this.columnIds.length:afterIndex;	
			if(!afterIndex && afterIndex!=0){
				col = this.columnIds.length; 
			}
			this.columnIds.splice(col,0 , columnId);
			this.columnNames.splice(col,0 , columnName);
			this.columnWidths.splice(col,0 , columnWidth);
			this.headerStyles.splice(col,0 , headerStyle);
			this.makeCol(columnName, columnId, headerStyle, afterIndex);
			this.alternateRowColors();
			
			this.save();
			if(!noCallCallback)
				this.onAfterAddCol(columnName, columnId, columnWidth, headerStyle, afterIndex);
		}		
		
	}
	
	this.makeCol = function(columnName, columnId, headerStyle, afterIndex){
		var oCell, cIndex, i;
		var rIndex = 0;
		
		if(!afterIndex && afterIndex!=0)
			cIndex = this.table.rows[rIndex].cells.length;
		else
		{
			cIndex= afterIndex;
			if (this.showRowId)
				cIndex++;
			if (this.showRemoveCol)
				cIndex++;
		}
			
		
		if(this.showRemoveCol){
			oCell = this.thead.rows[rIndex].insertCell(cIndex);
			oCell.noWrap = true;
			oCell.align = "center";
			oCell.className = "colButtons";
			this.setWidthToCell(oCell);
			this.addRemoveColButton(oCell);
			rIndex++;		
		}
	
		oCell = this.thead.rows[rIndex].insertCell(cIndex);
		oCell.noWrap = true;
		oCell.id = columnId;
		this.setWidthToCell(oCell);
		oCell.appendChild(document.createTextNode(columnName));
		if(this.useHeaderStyles && headerStyle !=null && headerStyle!="")
				oCell.className = headerStyle;
			else
				oCell.className = "headerRow";
		if(this.sortable)
				this.addSortColButton(oCell);
		
		for(i=0;i<this.tbody.rows.length;i++){
			oCell = this.tbody.rows[i].insertCell(cIndex);
			oCell.id = this.getDataCellId(this.rowIds[i], columnId);
			oCell.noWrap = true;
			oCell.className = "data";
			oCell.dynTable = this.table.uniqueName;
			this.setWidthToCell(oCell);
			oCell.innerHTML = "&nbsp;";
		}
		
		for(i=0;i<this.tbody2.rows.length;i++){
			oCell = this.tbody2.rows[i].insertCell(cIndex);
			oCell.resumeRow = true;
			oCell.id = this.getDataCellId(this.rowIds[i], columnId);
			oCell.noWrap = true;
			oCell.className = "resume";			
			oCell.dynTable = this.table.uniqueName;
			this.setWidthToCell(oCell);
			oCell.innerHTML = "&nbsp;";
		}
		
		if(this.SS2Comunication.getSS2Interaction())
						this.SS2Comunication.request(this.rowIds,columnId);
	}
	
	this.addSortColButton = function(cell){
		cell.onclick = sortTableOnClick;
	}
	
	this.addRemoveColButton = function(cell){
		var img = document.createElement("IMG");
		img.setAttribute("src", "images/remove.gif");
		img.setAttribute("border", "0");
		img.onclick = removeColOnClick;
		img.alt = this.removeColAlt;
		cell.width = this.removeRowButtonWidth;
		cell.align = "center";
		cell.className = "colButtons";
		cell.style.verticalAlign="bottom";
		cell.appendChild(img);
	}
	
	this.addRemoveRowButton = function(cell){
		var img = document.createElement("IMG");
		img.setAttribute("src", "images/remove.gif");
		img.setAttribute("border", "0");
		img.onclick = removeRowOnClick;
		img.alt = this.removeRowAlt;
		cell.width = this.removeRowButtonWidth;
		cell.className = "rowButtons";
		cell.appendChild(img);
	}
	
	
	this.addOptionButton = function(cell,rowid,rowname){
		var img = new Image();
		img.src = this.tmpOptionButton.src;
		img.border ="0";
		img.alt=this.optionAlt;
		img.onclick = ContextMenu.showContextMenu;
		cell.width = this.optionButtonWidth;
		cell.appendChild(img);
		cell.align= "center";
		cell.className = "rowButtons";
		img.rowid = rowid;
		img.rowname  = rowname;
		img.myContextMenu = this.contextMenu;
		img.style.cursor = "hand";
	}
	
	this.addGraphButton = function(cell,rowid, rowname){
		var ref = this.graphRef.replace("%r",rowid);
		ref = ref.replace("%n",rowname);
		var a = document.createElement("A");
		a.setAttribute("href",ref);
		var img = new Image();
		img.src = this.tmpgraphButton.src;
		img.border ="0";
		img.alt=this.graphAlt;
		img.rowid = rowid;
		img.rowname  = rowname;
		cell.className = "rowButtons";
		cell.align= "center";
		cell.width = this.graphButtonWidth;
		a.appendChild(img);
		cell.appendChild(a);
	}
	
	this.addDetailLink = function(cell,rowid,rowName){
		var ref = this.detailLinkRef.replace("%r",escape(rowid));
		ref = ref.replace("%n",escape(rowName));
		var a = document.createElement("A");
		a.className = "detailLink";
		a.setAttribute("href","javascript:void(0);");
		a.ref = ref;
		a.detailLinkHeight = this.detailLinkHeight;
		a.detailLinkWidth = this.detailLinkWidth;
		a.onclick = this.showDetail;
		a.appendChild(document.createTextNode(rowName));
		cell.appendChild(a);
	}
	
	this.showDetail = function(element){
		if (!(element)) {
		    e = window.event.srcElement;
		  } else {
		    e = element.target;
		  }
		if(e.ref!=null){
			now = new Date();
			winName = now.getMinutes() + now.getSeconds();
			dressing = "height="+e.detailLinkHeight+",width="+e.detailLinkWidth+",location=no,scrollbars=auto,menubars=no,toolbars=no,resizable=yes";
			winPopup = window.open(e.ref,winName,dressing);
			if(winPopup!=null)winPopup.focus();
		}
		
	}
	
	
	this.addSceneButton = function(cell,rowid, rowname){
		var ref = this.sceneRef.replace("%r",rowid);
		var a = document.createElement("A");
		var img = document.createElement("IMG");
		if(this.sceneImgWidth)
		{
			img.style.width=this.sceneImgWidth;
		}
		if(this.sceneImgHeight)
		{
			img.style.height=this.sceneImgHeight;
		}
		img.setAttribute("src", this.sceneImageSrc);
		img.setAttribute("border", "0");
		img.setAttribute("alt",this.sceneAlt);
		a.setAttribute("href",ref);
		img.rowid = rowid;
		img.rowname = rowname;
		if(this.sceneEvent)
			a.onclick=this.sceneEvent
		a.appendChild(img);
		cell.className = "rowButtons";
		cell.width = this.sceneButtonWidth;
		cell.style.textAlign="center"
		cell.appendChild(a);
	}

	this.addCalcButton = function(cell,rowid, rowname){
		var ref = this.calcRef.replace("%r",rowid);
		var a = document.createElement("A");
		var img = document.createElement("IMG");
		if(this.calcImgWidth)
		{
			img.style.width=this.calcImgWidth;
		}
		if(this.calcImgHeight)
		{
			img.style.height=this.calcImgHeight;
		}
		img.setAttribute("src", this.calcImageSrc);
		img.setAttribute("border", "0");
		img.setAttribute("alt",this.calcAlt);
		img.rowid = rowid;
		img.rowname = rowname;	
		a.setAttribute("href",ref);
		if(this.calcEvent)
			a.onclick=this.calcEvent
		a.appendChild(img);
		cell.width = this.calcButtonWidth;
		cell.className = "rowButtons";
		cell.style.textAlign="center"
		cell.appendChild(a);
	}
	
	this.addRestoreColButton = function(cell){
		    if(!this.showRemoveCol) return;
			var a = document.createElement("A")
			var img = document.createElement("IMG")
			img.setAttribute("src","images/reset_form.gif");
			img.setAttribute("width", 9);
			img.setAttribute("height", 9);
			img.setAttribute("border", 0);
			img.setAttribute("alt", "Restaurar columnas");
			a.setAttribute("href","javascript:void(0)");
			a.appendChild(img);
			a.onclick = restoreColumnsOnClick;
			cell.appendChild(a);
	}
	
	this.restoreColumns = function(){
		var maximo=0
		if(this.showRemoveRow)maximo++;
		if(this.showRowId)maximo++;
		while(this.thead.rows[0].cells.length>maximo)
			this.removeCol(maximo, false);
		if(this.onBeforeOfRestoreColumns){
			if(this.onBeforeOfRestoreColumns(this.defaultColumnIds, this.defaultColumnNames, this.defaultColumnWidths,this.defaultColumnStyles )){
				for ( var i=0; i< this.defaultColumnIds.length;i++)
				{
					this.addCol(this.defaultColumnNames[i],this.defaultColumnIds[i],this.defaultColumnWidths[i],this.defaultColumnStyles[i],null,true)
				}
				if(this.onAfterOfRestoreColumns)
					this.onAfterOfRestoreColumns(this.defaultColumnIds, this.defaultColumnNames, this.defaultColumnWidths);
			}
		}
	}
	
	this.resetColumns = function(){
		var maximo=0
		if(this.showRemoveRow)maximo++;
		if(this.showRowId)maximo++;
		var cn = copyArray(this.columnNames);
		var ci = copyArray(this.columnIds);
		var cw = copyArray(this.columnWidths);
		var cs = copyArray(this.headerStyles);
		
		while(this.thead.rows[0].cells.length>maximo)
			this.removeCol(maximo, false);
			
		this.columnNames = new Array();
		this.columnIds = new Array();
		this.columnWidths = new Array();
		this.headerStyles = new Array();
		
		for ( var i=0; i< ci.length;i++){				
					this.addCol(cn[i],ci[i],cw[i],cs[i],null,true);
		}
	}
		
	this.removeCol = function(colIndex, doCallbacks){
	
		if(doCallbacks)
			remove = this.onBeforeOfRemoveCol(colIndex);
		else
			remove = true;
		if(remove){
			if(this.separeTitles){
				for(h=0;h<this.tableTitles.rows.length;h++){
					this.tableTitles.rows[h].deleteCell(colIndex);
				}
			}
			for(h=0;h<this.table.rows.length;h++){
				if(this.SS2Comunication.getSS2Interaction())
							this.SS2Comunication.release(this.rowIds,this.columnIds[colIndex]);
				this.table.rows[h].deleteCell(colIndex);
			}
			if(this.showRemoveRow)colIndex--;
			if(this.showRowId)colIndex--;
			if(this.columnNames)this.columnNames = delFromArrayIndex(this.columnNames,colIndex);
			if(this.columnIds)this.columnIds = delFromArrayIndex(this.columnIds,colIndex);	
			if(this.columnWidths)this.columnWidths = delFromArrayIndex(this.columnWidths,colIndex); //delFromArray(this.columnWidths,this.columnWidths[colIndex]);	
			if(this.headerStyles)this.headerStyles = delFromArrayIndex(this.headerStyles,colIndex); //delFromArray(this.columnWidths,this.columnWidths[colIndex]);	
			this.onAfterOfRemoveCol(colIndex);
		}
		this.save();
	}
	
	this.removeRow = function(rowIndex, noRedraw){
		if(this.onBeforeOfRemoveRow(rowIndex)){
			this.table.deleteRow(rowIndex);
			if(this.showColId)rowIndex--;
			if(this.showRemoveCol)rowIndex--;
			
			if(this.SS2Comunication.getSS2Interaction())
						this.SS2Comunication.release(this.rowIds[rowIndex],this.columnIds);
						
			if(this.rowIds)
				this.rowIds = delFromArrayIndex(this.rowIds,rowIndex);
			if(this.rowNames)
				this.rowNames = delFromArrayIndex(this.rowNames,rowIndex);

			if(!noRedraw)
			{this.alternateRowColors()};
			
			this.onAfterOfRemoveRow();
		}
		this.save();
	}
	
	this.removeAllRows = function(){
		
		if(this.SS2Comunication.getSS2Interaction()){
				this.SS2Comunication.release(this.rowIds,this.columnIds);
		}
		
		this.rowIds = new Array();
		this.rowNames = new Array();
		
		while(this.table.rows.length>0)
		{
			this.table.deleteRow(0);
		}
		
	}
	
	this.removeAllBodyRows = function(){
		
		if(this.SS2Comunication.getSS2Interaction())
						this.SS2Comunication.release(this.rowIds,this.columnIds);
						
		this.rowIds=new Array();
		this.rowNames = new Array();
		
		while(this.tbody.rows.length>0)
			this.removeRow(((this.showColId)?1:0)+((this.showRemoveCol)?1:0),true);
		this.alternateRowColors();
	}
	
	this.sortByCol= function(numCol,ascOrder)
	{
		if(numCol!=null) compareCol = numCol;
		if(ascOrder==null) 
			ascOrder = this.ascOrder;
		var myBody = this.tbody;
		
		for ( var i = 0; i < myBody.childNodes.length - 1;i++){	
			for ( var j = i+1; j < myBody.childNodes.length;j++){		
				var row = myBody.childNodes[i];
				var nextRow = myBody.childNodes[j];
				if((ascOrder)?(this.compareRow(row, nextRow)>0):(this.compareRow(row, nextRow)<0)){	
				  myBody.removeChild(nextRow);					
					myBody.insertBefore(nextRow,row);
					var aux = this.rowIds[j];
					this.rowIds.splice(j,1)
					this.rowIds.splice(i,0,aux)
					aux = this.rowNames[j];
					this.rowNames.splice(j,1)
					this.rowNames.splice(i,0,aux)
					
				}
			}
		}		

		this.alternateRowColors();
	}
	
	this.compareRow = function(a,b){			
		return  this.compare(a.getElementsByTagName("TD")[compareCol],b.getElementsByTagName("TD")[compareCol]);
	}
	this.compare = function(a,b){
		var a1 = parseFloat(a.innerHTML)
		var b1 = parseFloat(b.innerHTML)
		if(isNaN(a1) || isNaN(b1) )
		{
			return (a.innerHTML==b.innerHTML)?0:((a.innerHTML<b.innerHTML)?-1:1);
		}else
		{
			return (a1==b1)?0:((a1<b1)?-1:1);
		}
	}
	
	this.getCellById = function(rowId,colId){
		var oCell = document.getElementById(this.getDataCellId(rowId,colId));
		if(!oCell)
			return null;
		else
			return oCell;
		
	}
	
	this.getCellByIndex = function(rowIndex,colIndex){
		var oCell = this.table.rows[rowIndex].cells[colIndex];
		if(!oCell)
			return null;
		else
			return oCell;	
	}
	
	this.getCellValueById = function(rowId,colId){
		var oCell = getCellById(rowIndex,colIndex);
		if(!oCell)
			return null;
		else
			return oCell.childNodes[0].nodeValue;
		
	}
	
	this.getCellValueByIndex = function(rowIndex,colIndex){
		var oCell = getCellByIndex(rowIndex,colIndex);
		if(!oCell)
			return null;
		else
			return oCell.childNodes[0].nodeValue;
		
	}

	
	this.getDataCellId = function(rowid, colid){
		return this.cleanName(rowid) + "_" + this.cleanName(""+colid)+((this.cellIdUnique)?("_"+this.table.uniqueName):"");
	}
	
	this.getRowId = function(rowid){
		return this.cleanName(rowid) + ((this.cellIdUnique)?("_"+this.table.uniqueName):"");
	}
	
	this.getOriginalRowId = function(rowid){
		return (document.getElementById(rowid).originalId);
	}
	
	this.getValues = function(includeRowNames, includeColNames){
	    var arr = new Array();
	    if(includeColNames){
	        arr[arr.length] = (this.columnNames?this.columnNames:this.columnIds);
	    }
	    for(var j=0;j<this.tbody.rows.length;j++){
	        var arr2 = new Array();
	        if(includeRowNames ){
	            arr2[arr2.length] = (this.rowNames?this.rowNames[j]:this.rowIds[j]);
	    	}
			for(var i=this.firstDataColumn();i<this.firstTailButtonColumn();i++){
				arr2[arr2.length] = this.tbody.rows[j].cells[i].innerHTML;
			}
			arr[arr.length] =  arr2;  
	   }
	   return arr;
	}
		
	
	this.updateCell = function(rowId, colId, data, offset, state, flags){		
		if (!state) state = top.____SS2.STATE.OK;
		else{
			state = parseInt(state);					
		}
		var oCell = this.getCellById(rowId,colId);
		if(!oCell || oCell.dynTable != this.table.uniqueName){
			//alert("No es aqui"+oCell);
			return;
		}
		
		if(this.onBeforeOfUpdateCell(oCell,data)){
			if(!isNaN(data))
			{
				if(this.alignNumber != null)
					oCell.style.textAlign=this.alignNumber;
			}else
			{
				if(this.alignText != null);
					oCell.style.textAlign=this.alignText;
			}
			if(!this.updateIconCell(colId, oCell, data)){
				var cval = parseFloat(oCell.childNodes[0].nodeValue);
				var cdata = parseFloat(data);
													
				var hili = "tickSame";
				switch(state)				
				{
					case top.____SS2.STATE.OK:
						if(!isNaN(cval))
						{
							if(cdata > cval){
								hili="tickUp";
							}else if(cdata < cval){
								hili="tickDown";
							}
						}
						break;
					case top.____SS2.STATE.STALE:
					case top.____SS2.STATE.SERVICE_STALE:
					case top.____SS2.STATE.REQUEST_PENDING:
					case top.____SS2.STATE.NO_DATA_AVAILABLE:
					case top.____SS2.STATE.REQUEST_ERROR:
					case top.____SS2.STATE.NOT_PERMISIONED:
					case top.____SS2.STATE.SERVICE_UNKNOWN:
					case top.____SS2.STATE.UNMONITORED_OR_DROPED:
					case top.____SS2.STATE.RECORD_PAUSED:
					case top.____SS2.STATE.ERROR_RECORD_PAUSED:
						hili="stale";
						break;
					default:
				}
				
				oCell.childNodes[0].nodeValue = data;
				
				if(this.changeColors){
						var hiliTrace = hili;
							
						if(this.showAlternativeRowColors && (oCell.parentNode.rowIndex + ((this.separeTitles)?0:((this.showColId)?1:0)+((this.showRemoveCol)?1:0)))%2==0)
							hiliTrace = 'PAR'+ hili ;
							
						hiliTrace = hiliTrace + "Trace";
				
						if(this.highLight){
						
								if(oCell.className!=hili)
								{
									oCell.className = hili;
								}
																
								if(oCell.idTimeOut != null) {
									clearTimeout(oCell.idTimeOut);
									oCell.idTimeOut = null;
								}
													
								oCell.idTimeOut = setTimeout('DynTable.revert("' + oCell.id + '","'+ hiliTrace +'")',this.highLightTimeout);
						
						}else{
							
								DynTable.revert(oCell.id,hiliTrace);
						}
				}
			}
			this.onAfterOfUpdateCell(oCell);
		}
	}	
	
	this.updateIconCell = function(fid, cell,value){
		if(this.colIconFid == null)
			return false;
		if(fid == this.colIconFid){	
			return this.changeIcon(cell,value);
		}
		return false;
	}
	
	this.changeIcon = function(cell, value){
		var imgSrc = this.colIconDefaultSrc;
		var alt = "";
		if(typeof(this.colIconSources[value]) == "object"){
			imgSrc = this.colIconSources[value][0];
			alt = (this.colIconSources[value][1]!=null?this.colIconSources[value][1]:"");
		}else{
			imgSrc = this.colIconSources[value];
		}
		if(imgSrc!=null){
			if(!cell.tick || this.colIconRepaintAllways){
				cell.tick = value;
				cell.imgId = "___"+(new Date())+""+ Math.random();
				cell.innerHTML = '<img id="'+ cell.imgId +'" name="'+ cell.imgId +'" src="' +imgSrc+'" border="0" alt="' + alt + '"/>';
			}else if (cell.tick != value ){
				cell.tick = value;
				document.images[cell.imgId].src = imgSrc;
			}
			return true;
		}else{
			return false;
		}
	
	}
	
		
	this.save = function(){

			if(this.autoSaveColumns){
				if(this.multipleAppearance){
					this.multipleColumnIds[this.appearanceId] = this.columnIds.join(",");
					this.multipleColumnNames[this.appearanceId] = this.columnNames.join(",");
					this.multipleColumnWidths[this.appearanceId] = this.columnWidths.join(",");
					this.multipleColumnStyles[this.appearanceId] = this.headerStyles.join(",");
					
					this.cookieColumnIds.setCookie(this.multipleColumnIds.join("@"));
					this.cookieColumnNames.setCookie(this.multipleColumnNames.join("@"));
					this.cookieColumnWidths.setCookie(this.multipleColumnWidths.join("@"));
					this.cookieColumnStyles.setCookie(this.multipleColumnStyles.join("@"));
				}else{
					this.cookieColumnIds.setCookie(this.columnIds.join(","));
					this.cookieColumnNames.setCookie(this.columnNames.join(","));
					this.cookieColumnWidths.setCookie(this.columnWidths.join(","));
					this.cookieColumnStyles.setCookie(this.headerStyles.join(","));
				}
			}
			if(this.autoSaveRows){
				this.cookieRowIds.setCookie(this.rowIds.join(","));
				this.cookieRowNames.setCookie(this.rowNames.join(","));
			}
	}
	
/*	
this.onload = function(){
		this.load();
	}
	this.onunload = function(){
		this.save();
	}
*/	
	this.load = function(){
	
		if(this.multipleAppearance){
			if(this.cookieColumnIds.getCookie()!=null){
				this.multipleColumnIds = (new String(this.cookieColumnIds.getCookie())).trim().split("@");
				if(this.multipleColumnIds[this.appearanceId]!=null && this.multipleColumnIds[this.appearanceId]!="")
					this.columnIds = new String(this.multipleColumnIds[this.appearanceId]).trim().split(",");				
			}			
			if(this.cookieColumnNames.getCookie()!=null){
			  this.multipleColumnNames = (new String(this.cookieColumnNames.getCookie())).trim().split("@");
			  if(this.multipleColumnNames[this.appearanceId]!=null && this.multipleColumnNames[this.appearanceId]!="")
			  	this.columnNames = new String(this.multipleColumnNames[this.appearanceId]).trim().split(",");
			}
			if(this.cookieColumnWidths.getCookie()!=null){
			  this.multipleColumnWidths = (new String(this.cookieColumnWidths.getCookie())).trim().split("@");
			  if(this.multipleColumnWidths[this.appearanceId]!=null && this.multipleColumnWidths[this.appearanceId]!="")
			  	this.columnWidths = new String(this.multipleColumnWidths[this.appearanceId]).trim().split(",");
			} 
			if(this.cookieColumnStyles.getCookie()!=null){
			  this.multipleColumnStyles = (new String(this.cookieColumnStyles.getCookie())).trim().split("@");
			  if(this.multipleColumnStyles[this.appearanceId]!=null && this.multipleColumnStyles[this.appearanceId]!="")
			  	this.headerStyles = new String(this.multipleColumnStyles[this.appearanceId]).trim().split(",");	
			}
		}else{
		
			if(this.cookieColumnIds.getCookie()!=null)
				this.columnIds = (new String(this.cookieColumnIds.getCookie())).trim().split(",");
			
			if(this.cookieColumnNames.getCookie()!=null)
			  this.columnNames = (new String(this.cookieColumnNames.getCookie())).trim().split(",");
			
			if(this.cookieColumnWidths.getCookie()!=null)
			  this.columnWidths = (new String(this.cookieColumnWidths.getCookie())).trim().split(",");
			  
			if(this.cookieColumnStyles.getCookie()!=null)
			  this.headerStyles = (new String(this.cookieColumnStyles.getCookie())).trim().split(",");		
		}
		
		if(this.cookieRowIds.getCookie()!=null)
			  this.rowIds = (new String(this.cookieRowIds.getCookie())).trim().split(",");
				
		if(this.cookieRowNames.getCookie()!=null)
		  this.rowNames = (new String(this.cookieRowNames.getCookie())).trim().split(",");
		//alert("load " + this.table.uniqueName + " - " + this.columnIds + " - " + this.columnNames + " -  " + this.columnWidths);		
		
	}
	
	
	this.cleanName = DynTable.cleanName
}
DynTable.cleanName = function(name) {
		if(name!=null){
			// replace sensitive characters.
			name = name.replace("=","e");
			name = name.replace(".","d");
			name = name.replace(" ","_");
		}
		return name;
	}
DynTable.myDynTables = new Array();
	
DynTable.findDynTable = function(element){
	var table;
	table = findObject(element,'TABLE');
	if (table!=null)
		return DynTable.myDynTables[table.uniqueName];	
}


function sortTableOnClick(element){
	DynTable.sortTableOnClickEvent(element);
}

DynTable.sortTableOnClickEvent = function(element){
	var e, r, c, t, cIndex;
	  if (!(element)) {
	    e = window.event.srcElement;
	  } else {
	    e = element.target;
	  }
	  t = DynTable.findDynTable(e);
	  c = findObject(e,'TD');
	  	  
	  if (c != null) {
			if(!c.ascOrder)
				c.ascOrder = true;
			else
				c.ascOrder = (!c.ascOrder);
				
			t.sortByCol(c.cellIndex,c.ascOrder);
	  }

}

function removeColOnClick(element){
	DynTable.removeColOnClickEvent(element);
}

DynTable.removeColOnClickEvent = function(element){

	var e, r, c, t, cIndex;
	  if (!(element)) {
	    e = window.event.srcElement;
	  } else {
	    e = element.target;
	  }
	  t = DynTable.findDynTable(e);
	  c = findObject(e,'TD');;
	  
	  if (c != null) {
			t.removeCol(c.cellIndex,true);
	  }

}

function removeRowOnClick(element){
	DynTable.removeRowOnClickEvent(element);
}

DynTable.removeRowOnClickEvent = function(element){

	var e, r, c, t, rIndex;
	  if (!(element)) {
	    e = window.event.srcElement;
	  } else {
	    e = element.target;
	  }
	  t = DynTable.findDynTable(e);
	  r = findObject(e,'TR');

	  if (r != null) {
			t.removeRow(r.rowIndex);				
	  }

}

function restoreColumnsOnClick(element){
	DynTable.restoreColumnsOnClickEvent(element);
}

DynTable.restoreColumnsOnClickEvent = function(element){
	var e, c;
	  if (!(element)) {
	    e = window.event.srcElement;
	  } else {
	    e = element.target;
	  }
	  t = DynTable.findDynTable(e);
	  if(t!=null){	
	  	t.restoreColumns();
	  }
}

//
// revert the colous.
//
DynTable.revert = function(cID,clss){
				
	var cell = document.getElementById(cID);

	if(cell == null){
		return;
	}
	cell.idTimeOut = null;
	if (cell.resumeRow)
	{
		clss = "resume"
	}
	if (clss!=	cell.className)
	{
		cell.className = clss; 
	}
}

//
// remove an item from an array.
//
function delFromArray(array,item) {
					
	var tmpArr = new Array();
	var x = 0
						
	for ( iCount = 0; iCount < array.length; iCount++) {
		if(array[iCount] != item) {
			tmpArr[x++] = array[iCount];
		}
	}
						
	return tmpArr;
}

//
// remove an item from an array.
//
function delFromArrayIndex(array,index) {
					
	var tmpArr = new Array();
	var x = 0
	var iCount = 0;
						
	for ( iCount = 0; iCount < index && iCount < array.length; iCount++) {
		tmpArr[x++] = array[iCount];
	}
	for ( iCount++; iCount < array.length; iCount++) {
		tmpArr[x++] = array[iCount];
	}
						
	return tmpArr;
}

function findObject(e,tagName){
		if (e.tagName == tagName) {
		return e;
	} else if (e.tagName == "BODY") {
		return null;
	} else {
		return findObject(e.parentNode,tagName);
	}
}

DynTable.msgs = new function(){
	if(!top.DynTable){
		top.DynTable = DynTable;	
	}
	if(!top.DynTable.msgs){
		this.anadira = 'A&ntilde;adir <B>%0</B> a...';	
		this.optionAlt = "Opciones";
		this.graphAlt = "Ver gr?fico";
		this.sceneAlt = "Ver escenarios";
		this.calcAlt = "Ver calculadora";
		this.removeRowAlt = "Quitar fila";
		this.removeColAlt = "Quitar columna";
		this.errorMaxNumberExceed = "No se pueden establecer mas de 12 warrants";
		this.errorInstrumentAlreadyIncluded = "El instrumento ya esta incluido!";
	}else{
		this.anadira = top.DynTable.msgs.anadira;
		this.optionAlt = top.DynTable.msgs.optionAlt;
		this.graphAlt = top.DynTable.msgs.graphAlt;
		this.sceneAlt = top.DynTable.msgs.sceneAlt;
		this.calcAlt = top.DynTable.msgs.calcAlt;
		this.removeRowAlt = top.DynTable.msgs.removeRowAlt;
		this.removeColAlt = top.DynTable.msgs.removeColAlt;
		this.errorMaxNumberExceed = top.DynTable.msgs.errorMaxNumberExceed;
		this.errorInstrumentAlreadyIncluded = top.DynTable.msgs.errorInstrumentAlreadyIncluded;
	}
}
