/* Copyright (c) 2007, Rapex.dk All rights reserved. version: 0.0.0 */ 
var Output = function(name) {
	this.name=name;
	this.TableSettingsArray = "";
	this.TableRowsValue = "";
	this.CollHeadArray = "";
	this.CollUsedArray = "";
	this.CollFormatArray = "";
	this.CollStyleArray = "";
	this.CollAlignArray = "";
	this.Coll = 0;
}
Output.prototype.SetTitle = function(Obj,TitleValue) {
	Obj.title = TitleValue;
}

Output.prototype.TableSettings = function() {
	this.TableSettingsArray = arguments;
}

Output.prototype.TableRows = function(Value) {
	this.TableRowsValue = Value;
}

Output.prototype.CollHead = function() {
	this.CollHeadArray = arguments;
	this.Coll=this.CollHeadArray.length;
}

Output.prototype.CollUsed = function() {
	this.CollUsedArray = arguments;
}

Output.prototype.CollFormat = function() {
	this.CollFormatArray = arguments;
}

Output.prototype.CollStyle = function() {
	this.CollStyleArray = arguments;
}

Output.prototype.CollAlign = function() {
	this.CollAlignArray = arguments;
}


Output.prototype.ReplaceValue = function(Value,nr) {
	BOX.SetTarget(right_container);
	for (var nn=0; nn<this.CollUsedArray.length; nn++){
		var reg = new RegExp("%"+(nn+1)+"%", "ig");
		if (this.CollUsedArray[nn][nr]) Value = Value.replace(reg, this.CollUsedArray[nn][nr]);
		if (reg.test(Value)) Value="";
	}
	return Value;
}

Output.prototype.TableCreate = function(Obj) {
	ELM.Br(Obj);
	this.Table = ELM.Table(Obj,"class='TableStandard'",this.TableSettingsArray);
	this.Thead = ELM.Thead(this.Table)
	this.Tr = ELM.Tr(this.Thead,"class='TableHeader'")
	for (var n=0; n<this.Coll; n++) {
		this.Th = ELM.Th(this.Tr)
	  var aVal = this.CollAlignArray[n].split(",");
	  this.Th.align = aVal[0];
	  this.Th.valign = aVal[1];
		this.ThText = ELM.InsertTextLine(this.Th,this.CollHeadArray[n]);
  }
	this.Tbody = ELM.Tbody(this.Table)
	for (var t=0; t<this.TableRowsValue; t++) {
		if (even(t)) var ClName ="TableEven"; else var ClName ="TableOdd"; 
		this.Tr = ELM.Tr(this.Tbody,"class='" + ClName + "'");
		for (var n=0; n<this.Coll; n++) {
	   	this.Td = ELM.Td(this.Tr,'style="'+this.ReplaceValue(this.CollStyleArray[n],t)+'"');
	   	var aVal = this.CollAlignArray[n].split(",");
	   	this.Td.align = aVal[0];
	   	this.Td.valign = aVal[1];
			this.TdText = ELM.InsertTextLine(this.Td,this.ReplaceValue(this.CollFormatArray[n],t));
		}
  }
}


