
IndReports={

boxUpto:0,
GetTableDiv:function(header,messObj) {
	var div=document.createElement('div');
	div.className='IndustryBoxDiv';
	div.innerHTML="<table class='IndustryBoxTable'><tr><td class='IndustryBoxHeaderTl'></td><td class='IndustryBoxHeader'>"+
		header+"</td><td><img src='../wp-content/themes/invtrends/images/industrybox_tr.gif' /></td></tr>"+
		"<tr><td class='IndustryBoxLeft'></td><td class='IndustrBoxTxtTd'><div class='IndustryBoxTxt'></div></td><td class='IndustryBoxRight'></td></tr>"+
		"<tr><td style='width: 9 !important;'><img src='../wp-content/themes/invtrends/images/industrybox_bl.gif' /></td><td class='IndustryBoxBottom'><img src='/icons/blank.gif' width='1' height='1' /></td><td width='10'><img src='../wp-content/themes/invtrends/images/industrybox_br.gif' /></td></tr>"+
		"</table>";
	var txt=div.getElementsByTagName('div');
	txt[0].appendChild(messObj);
	return div;
},

GetTableDivFromList:function(header,ems,codes) {
	var html='<table>';
	for(var e=0; e<ems.length; e++) {
		var em=ems[e][0];
		var emNoInfoBox=ems[e][1];
		var code=codes[e];

		html+="<tr><td><img src='../wp-content/uploads/2009/03/keyindustry_door.gif' class='KeyIndustryDoor' /></td>";
		html+="<td>"+"<a class='"+(emNoInfoBox?'noInfoBox':'')+"' href='javascript:' id='IndLink"+this.linkUpto+"'>"+em+"</a>"+"</td>";
		this.linkUpto++;
	}
	html+="</table>";

	var d=document.createElement('div');
	d.innerHTML=html;
	var t=this.GetTableDiv(header,d);
	return t;
},

AddMouseOvers:function(t,codes) {
	var as=t.getElementsByTagName('a');
	var codeUpto=0;
	for(var aUpto=0; aUpto<as.length; aUpto++) {
		var a=as[aUpto];
		if(a.id.substring(0,7)!="IndLink") { continue; }
		if(a.className.indexOf('noInfoBox')<0) {

			var code=codes[codeUpto];
			InfoBox.AddMouseOver(a,code);
		}
		codeUpto++;
	}
},

linkUpto:0,
currentStrong:null,
currentEms:[],
currentCodes:[],
DoCurrentEms:function() {
	if(this.currentEms.length<=0) { return; }

	var tableDiv=this.GetTableDivFromList(this.currentStrong,this.currentEms,this.currentCodes);

	var boxesDiv=document.getElementById('KeyIndustryBoxes'+this.boxUpto);
	boxesDiv.appendChild(tableDiv);
	this.AddMouseOvers(tableDiv,this.currentCodes);

	this.boxUpto++;
	this.currentEms=[];
	this.currentCodes=[];
},

DoTag:function(tag) {
	if(!tag.tagName) { return; }
	var tagName=tag.tagName.toUpperCase();
	var skipChild=false;
	if(tagName=="EM") { 
		this.currentEms.push([tag.innerHTML, (tag.className.indexOf('noInfoBox')>=0?true:false) ]); 
	}
	else if(tagName=="STRONG") { 
		this.DoCurrentEms();
		this.currentStrong=tag.innerHTML;
	} else if(tagName=="CODE" || tagName=="P" || tagName=="UL" || tagName=="LI") { 
		var ih=tag.innerHTML.toLowerCase();
		if(this.currentStrong!=null
		&& ih.indexOf('<strong>')<0
		&& ih.indexOf('<em>')<0
		) {
			var n=this.currentEms.length-1;
			if(this.currentCodes[n]==undefined) {
				this.currentCodes[n]="";
			} else {
				this.currentCodes[n]+="<p />";
			}
			skipChild=true;
			if(tagName=="P") {
				this.currentCodes[n]+=tag.innerHTML;
			} else {
				this.currentCodes[n]+=
					"<"+tagName+">"+
					tag.innerHTML+"</"+tagName+">";
			}
		}
	}

	if(tagName!="UL") {
		for(var i=0; i<tag.childNodes.length; i++) {
			var child=tag.childNodes[i];
			this.DoTag(child);
		}
	}
},
Setup:function() {
	InfoBox.BoxTxt().style.width=400;
	this.currentEms=[];
	this.currentCodes=[];
	this.currentStrong=null;
	this.linkUpto=0;
	var infoDiv=document.getElementById('KeyIndustryInfo');
	this.DoTag(infoDiv);
	this.DoCurrentEms();
	InfoBox.boxFadeSpeed=0.2;
},

SetupTradingBoxes:function() {
	for(var t=1; t<100; t++) {
		var box=document.getElementById('TradingBox'+t);
		var txt=document.getElementById('TradingTxt'+t);
		if(!txt || !box) break;
		InfoBox.AddMouseOver(box,txt.innerHTML);
	}


}



};

IndReports.Setup();
IndReports.SetupTradingBoxes();


