// chris larsen 6/28/2007

function cnbc_getXMLHTTPRequest()
{
	if (window.XMLHttpRequest) 
	{ 
		// Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
            // See note below about this line
		}
	} 
	else if (window.ActiveXObject) 
	{ 
		// IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	
	return http_request;
}




if(typeof(linkBlockColumnCount) == "undefined"){
	linkBlockColumnCount = 1;
}

if(typeof(linkBlockStyle) == "undefined"){
	linkBlockStyle = 'bold';
}

var http_request = cnbc_getXMLHTTPRequest(); 
http_request.open('GET', linkBlockFeed, false);
http_request.send(null);


var LBLinks = http_request.responseXML.getElementsByTagName("a");

//document.write(linkBlockColumnCount);
//document.write(LBLinks.length);

var linksPerColumn = LBLinks.length / linkBlockColumnCount;


linksPerColumn = Math.floor(linksPerColumn);
linksRemaining = LBLinks.length - (linksPerColumn * linkBlockColumnCount);
addLinksRemaining = 0;

var cLBColumn = 1;






var LBOutput = '<table cellpadding="0" cellspacing="0" border="0"><tr>';
var currentLBLinksIndex = 0;

for(i=0; i<linkBlockColumnCount; i++){
	LBOutput += '<td valign="top">';
	
		for(x=0; x<linksPerColumn || addLinksRemaining; x++){
		
			var LBLinkType = LBLinks[currentLBLinksIndex].attributes.getNamedItem('linktype').nodeValue;
			var LBHref = LBLinks[currentLBLinksIndex].attributes.getNamedItem('href').nodeValue;
			if(LBLinkType == 'Internal'){
				LBHref = '/id/' + LBHref;
			}
			
			
			if(linkBlockStyle == 'bold'){
				LBOutput += '<div id="StoryLink" class="w100p cFont clr"><div id="feat_story" class="cf12 cstrong w100p padT"><div class="fL padL10 default_bullet bullet_second_"><div class="disptable">';
			}else{
				LBOutput += '<div id="StoryLink" class="cFont cf11 clr padT"><div class="clr"><div class="fL padL10 default_bullet bullet_second_"><div class="disptable">';
			}
			
			
			LBOutput += '<a href="' +  LBHref + '">' + LBLinks[currentLBLinksIndex].firstChild.nodeValue + '</a><br>';
			
			LBOutput += '</div></div></div></div>';
			
			currentLBLinksIndex++;
			if(i < linksRemaining && x+1 == linksPerColumn && !addLinksRemaining){
				addLinksRemaining = 1;
			}else{
				addLinksRemaining = 0;
			}
		}
	
	
	LBOutput += '</td>';
	if(i < linkBlockColumnCount - 1){
		LBOutput += '<td width="10" nowrap><br></td>';
	}
}
LBOutput += '</tr></table>';
document.write(LBOutput);