$(document).ready(function(){
	$(".bodyColLeft").append('<div id="loadingNews">loading...</div>');
	
	$.get('feed.asp',function(data){
		parseXml(data);
	});
});

var objArray = new Array();
var eCount = 0;
function parseXml(xml)
{
	$(xml).find("item").each(function(){
		var title = $(this).find('title').text();
		if(title.indexOf('studiocue') > 0){title=title.substr(0,title.indexOf('studiocue'));}
		var pubLink = $(this).find('link').text();
		var pubDate = $(this).find('pubDate').text();
		pubDate = Date.parse(pubDate).toString('M/d');
		var desc = $(this).find('description').text();
		var newsStr = '<p><strong>'+pubDate+'</strong>&nbsp;<a href="'+pubLink+'" target="_blank">'+title+'</a><br />'+desc+'</p>';
		objArray.push(newsStr);
		eCount ++;
	});
	$("#loadingNews").remove();
	$(".bodyColLeft").append('<h2>In The Cue</h2><div id="inTheCue"></div>');
	showEntry();
}

var eLoop = 0;
var tO = 0;
function showEntry(){
	var newsStr = objArray[eLoop];
	if($("#inTheCue").css('display') == 'block'){$("#inTheCue").fadeOut('fast',function(){
		$("#inTheCue").html(newsStr).fadeIn();
		eLoop ++;
		if(eLoop >= eCount){eLoop = 0;}
		tO = setTimeout("showEntry()",10000);
	});}else{
		$("#inTheCue").html(newsStr).fadeIn();
		eLoop ++;
		if(eLoop >= eCount){eLoop = 0;}
		tO = setTimeout("showEntry()",10000);
	}
}

Date.prototype.adjust = function(yr,mn,dy,hr,mi,se) {
	var m,t;
	this.setYear(this.getFullYear() + yr);
	m = this.getMonth() + mn;
	if(m != 0) this.setYear(this.getFullYear() + Math.floor(m/12));
	if(m < 0) {
		this.setMonth(12 + (m%12));
	} else if(m > 0) {
		this.setMonth(m%12);
	}
	t = this.getTime();
	t += (dy * 86400000);
	t += (hr * 3600000);
	t += (mi * 60000);
	t += (se * 1000);
	this.setTime(t);
}
