var channels = new Array();
var categories = new Array();
var category_titles = new Array();
var counters = new Array();
var channel_cnt = 0;
var category_cnt = 0;

counters[0] = 1

function InChannelList ( test_channel ){
for (channel_ptr=0;channel_ptr<channel_cnt;channel_ptr++){
	if (channels[channel_ptr] == test_channel){
		return true;
		}
	}
return false;	
} 

function GetChannels ( ) {
for (i=0;i<news_category_array.length-1;i++){
	if (InChannelList(news_category_array[i].channel_name) == false){
		channels[channel_cnt] = news_category_array[i].channel_name;
		counters[channel_cnt] = 1;
		channel_cnt++;
		}
	else {
		counters[channel_cnt-1]++
		}
	}
}
	
function GetCategories ( selected_channel ) {
for (i=0;i<news_category_array.length-1;i++){
	if ( news_category_array[i].channel_name == selected_channel ){
		categories[category_cnt] = news_category_array[i].feed_name;
		category_titles[category_cnt] = news_category_array[i].full_name;
		category_cnt++
		}
	}
}

function WriteDir ( ) {

GetChannels();

document.write("<table cellspacing=\"6\" width=\"100%\">");
document.write("<tr>");
document.write("<td >");

for (i=0;i<channel_cnt;i++){
    selected_channel = channels[i].replace(/ /g,"%20")
	document.write("<font face=\"verdana,helvetica,arial\" size=-1><strong><a href=\"../NewsDirectory/index.cfm?contentfile=../NewsDirectory/content_newscat.cfm&selected_channel=" + selected_channel + "\">" + channels[i] + " 	(" + counters[i] + ")" + "</a></strong></font><br>");
	document.write("</td>");
	j=i+1
	if (j%2 == 0)	{
		document.write("</tr>");
		document.write("<tr>");
		}	
	document.write("<td >");
	}
document.write("<br>");
document.write("</td>");
document.write("</tr>");
document.write("</table>");
}
