
function Agenda(sTargetId, aArray) {
	var that = this;
	
	this.sTargetId = sTargetId;
	this.eTarget = document.getElementById(sTargetId);
	
	this.aArray = aArray;
	
	this.init = function() {
		that.buildAgenda();
	}
	
	this.buildAgenda = function() {
		that.eRows = [];
		
		that.eTable = that.addElement(that.eTarget.id, "table", [["id",sTargetId + "_table"],
																  ["border","0"]]);
		that.eTable.cellPadding = '5';
		that.eTable.cellSpacing = '2';
		
		that.eTBody = that.addElement(that.eTable.id, "tbody", [["id",sTargetId + "_tbody"]]);
		
		var eCurrentRow = that.addElement(that.eTBody.id, "tr", [["id",sTargetId + "_row_"+that.eRows.length -1]]);
		
		//1st row Times td
		var eCurrentTd = that.addElement(eCurrentRow.id, "td", []);
			
		//1st row tracks
		for (var i=0; i < that.aArray.length; i++) {
			var eCurrentTd = that.addElement(eCurrentRow.id, "td", [["class","agendaTitle"]]);
			eCurrentTd.innerHTML = "<a href='" + that.aArray[i][2] + "' target='_blank'><img src='images/btn/rss.gif' border='0' style='float:right;' /></a><span toolTip='" + that.aArray[i][3]+ "'>" + that.aArray[i][1] + "</span>";
			eCurrentTd.vAlign = 'top';
		}
		
		that.eRows.push(eCurrentRow);
		
		
		for (var i=0; i < that.aArray[0][0].length; i++) {
			var eCurrentRow = that.addElement(that.eTBody.id, "tr", [["id",sTargetId + "_row_"+i]]);
			
			if (this.aArray[0][0][i][0].substr(0,7) != "Session") {
				var eCurrentTd = that.addElement(eCurrentRow.id, "td", [["colspan",that.aArray[0][0][0].length],["class","agendaBreak"]]);
				eCurrentTd.colSpan = that.aArray[0][0][0].length;
				eCurrentTd.innerHTML = that.aArray[0][0][i][1] + " - <strong>" + that.aArray[0][0][i][2] + "</strong>";
			} else {
				var aCurrentTd = [];
					aCurrentTd[-1] = that.addElement(eCurrentRow.id, "td", [["class",'agendaTime']]);
					aCurrentTd[-1].innerHTML = "<strong>" + that.aArray[0][0][i][0] + "</strong><br/>" + that.aArray[0][0][i][1];
					
				for (var j=0; j < that.aArray.length; j++) {
					aCurrentTd[j] = that.addElement(eCurrentRow.id, "td", []);
					aCurrentTd[j].innerHTML = "<a href=\"javascript:oPopIn.expand('rss/rss_read.aspx?feed=" + that.aArray[j][1] + "&xsl=full',95)\">" + that.aArray[j][0][i][2] + "</a>";
					that.logit("that.aArray["+j+"][0]["+i+"][2] : " +that.aArray[j][0][i][2]);
				}
			}
			that.eRows.push(eCurrentRow);
		}
	}
	
	this.addElement = function(sParentId, sType, aAttributes) {
		
		var newElement = document.createElement(sType);
		for (var i=0; i < aAttributes.length; i++) {
			if (aAttributes[i][0] == "onclick" || 
				aAttributes[i][0] == "onload" ||
				aAttributes[i][0] == "onmouseover") {
				
				if (document.all) {
					//Attach event in the IE way
					function makeEventFunc(sEvents) {
						return function() {
							eval(sEvents);
						}
					}
					newElement.attachEvent(aAttributes[i][0], makeEventFunc(aAttributes[i][1]), true);
					
				} else {
					//Attach event in the Moz way
					newElement.setAttribute(aAttributes[i][0], aAttributes[i][1]);
				}
				
			} if (aAttributes[i][0] == "class") {
				newElement.className = aAttributes[i][1];
			} else {
				newElement.setAttribute(aAttributes[i][0],aAttributes[i][1]);
			}
		}
		
		if (sParentId != "") {
			document.getElementById(sParentId).appendChild(newElement);	
		} else {
			document.body.appendChild(newElement);
		}
		
		return newElement;
	}
	
	that.logit = function(sOutput) {
		if (typeof(console) != 'undefined') {
			console.log(sOutput);
		}
	}
}