function set_news()
{
		news = document.getElementById('headline');
		//
		articles = getElementsByClassName('clearfloat','div',document.getElementById('headline'));
		//alert(articles);
		var ids = [];
		var custom_div;
		for(x=0;x<articles.length;x++)
		{
			if(x ==0)
			{//do nothing
			custom_div = getElementsByClassName('ca_custom','div', articles[x]);
			active = custom_div[0].id;
			}
			else
			{
				articles[x].style.display = 'none';
			}
			custom_div = getElementsByClassName('ca_custom','div',articles[x]);
			ids.push(custom_div[0].id);
			//alert(custom_div[0].id);
		}
		
		var existing = "";
		document.getElementById('ca_news_switcher').innerHTML = "";
		for(y=0;y<ids.length;y++)
		{
			 existing = document.getElementById('ca_news_switcher').innerHTML;
			 if(ids[y] == active)
			 {
				 var background = 'background-color:#303030;color:#ffffff;';
			 }
			 else
			 {
				 var background = 'background-color:#ffffff;color:#303030;';
			 }
			 document.getElementById('ca_news_switcher').innerHTML = existing + '<div style="'+background+'cursor:pointer;margin-right:5px;display:inline;padding:2px 5px;border:1px solid #303030; width:40px; height:40px;" onClick="switch_news('+ids[y]+');">' + (y+1) +'</div>';
		}
		
}

function switch_news(id)
{
	news = document.getElementById('headline');
		
		articles = getElementsByClassName('clearfloat','div',document.getElementById('headline'));
		//alert(articles);
		var ids = [];
		//hide all news articles
		for(x=0;x<articles.length;x++)
		{	
				articles[x].style.display = 'none';
		}
		
		//now display only the article we want
		for(x=0;x<articles.length;x++)
		{	
			custom_div = getElementsByClassName('ca_custom','div', articles[x]);
			new_id = custom_div[0].id;
			if(new_id == id){articles[x].style.display = 'block';}
			
			custom_div = getElementsByClassName('ca_custom','div', articles[x]);
			ids.push(custom_div[0].id);
		}
		
		//rebuild the bottom links with the correct item now selected
		var existing = "";
		document.getElementById('ca_news_switcher').innerHTML = "";
		for(y=0;y<ids.length;y++)
		{
			 existing = document.getElementById('ca_news_switcher').innerHTML;
			 if(ids[y] == id)
			 {
				 var background = 'background-color:#303030;color:#ffffff;font-weight:bold;';
			 }
			 else
			 {
				 var background = 'background-color:#ffffff;color:#303030;';
			 }
			 document.getElementById('ca_news_switcher').innerHTML = existing + '<div style="'+background+'cursor:pointer;margin-right:5px;display:inline;padding:2px 5px;border:1px solid #303030; width:40px; height:40px;" onClick="switch_news('+ids[y]+');">' + (y+1) +'</div>';
		}
		
}

function ca_news_right(current, next)
{
	document.getElementById(current).style.display = 'none';
	document.getElementById(next).style.display = 'block';
}


function ca_news_left(current, previous)
{
	document.getElementById(current).style.display = 'none';
	document.getElementById(previous).style.display = 'block';
}

var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};



//front page versions of functions
function set_frontpage()
{
		news = document.getElementById('front-list');
		//
		articles = getElementsByClassName('clearfloat','div',document.getElementById('front-list'));
		//alert(articles);
		var ids = [];
		var custom_div;
		for(x=0;x<articles.length;x++)
		{
			if(x ==0)
			{//do nothing
			custom_div = getElementsByClassName('ca_frontpage','div', articles[x]);
			active = custom_div[0].id;
			}
			else
			{
				articles[x].style.display = 'none'; 
			}
			custom_div = getElementsByClassName('ca_frontpage','div',articles[x]);
			ids.push(custom_div[0].id);
			//alert(custom_div[0].id);
		}
		
		var existing = "";
		document.getElementById('ca_frontpage_switcher').innerHTML = "";
		for(y=0;y<ids.length;y++)
		{
			 existing = document.getElementById('ca_frontpage_switcher').innerHTML;
			 if(ids[y] == active)
			 {
				 var background = 'background-color:#303030;color:#ffffff;';
			 }
			 else
			 {
				 var background = 'background-color:#ffffff;color:#303030;';
			 }
			 document.getElementById('ca_frontpage_switcher').innerHTML = existing + '<div style="'+background+'cursor:pointer;margin-right:5px;display:inline;padding:2px 5px;border:1px solid #303030; width:40px; height:40px;" onClick="switch_frontpage('+ids[y]+');">' + (y+1) +'</div>';
		}
		
}

function switch_frontpage(id)
{
	news = document.getElementById('front-list');
		
		articles = getElementsByClassName('clearfloat','div',document.getElementById('front-list'));
		//alert(articles);
		var ids = [];
		//hide all news articles
		for(x=0;x<articles.length;x++)
		{	
				articles[x].style.display = 'none';
		}
		
		//now display only the article we want
		for(x=0;x<articles.length;x++)
		{	
			custom_div = getElementsByClassName('ca_frontpage','div', articles[x]);
			new_id = custom_div[0].id;
			if(new_id == id){articles[x].style.display = 'block';}
			
			custom_div = getElementsByClassName('ca_frontpage','div', articles[x]);
			ids.push(custom_div[0].id);
		}
		
		//rebuild the bottom links with the correct item now selected
		var existing = "";
		document.getElementById('ca_frontpage_switcher').innerHTML = "";
		for(y=0;y<ids.length;y++)
		{
			 existing = document.getElementById('ca_frontpage_switcher').innerHTML;
			 if(ids[y] == id)
			 {
				 var background = 'background-color:#303030;color:#ffffff;font-weight:bold;';
			 }
			 else
			 {
				 var background = 'background-color:#ffffff;color:#303030;';
			 }
			 document.getElementById('ca_frontpage_switcher').innerHTML = existing + '<div style="'+background+'cursor:pointer;margin-right:5px;display:inline;padding:2px 5px;border:1px solid #303030; width:40px; height:40px;" onClick="switch_frontpage('+ids[y]+');">' + (y+1) +'</div>';
		}
		
}



