var t;
var c = 0;
var simages = ['http://users.wpi.edu/~theatre/images/12.jpg','http://users.wpi.edu/~theatre/images/15.jpg','http://users.wpi.edu/~theatre/images/16.jpg','http://users.wpi.edu/~theatre/images/14.jpg','http://users.wpi.edu/~theatre/images/9.jpg','http://users.wpi.edu/~theatre/images/8.jpg','http://users.wpi.edu/~theatre/images/4.jpg','http://users.wpi.edu/~theatre/images/2.jpg'];
var stext = ['New Voices 27. From <i>A Letter Unsent</i>','New Voices 27. From <i>Men are from Oz, Women are from Venus</i>','New Voices 27. From <i>Mad City, Inhabited</i>','New Voices 27. From <i>Men are from Oz, Women are from Venus</i>','New Voices 27. From <i>Schrodinger`s Cat in the Hat (fancy that!)</i>','New Voices 27. From <i>The Spy in Size 4`s<i>','New Voices 27. From <i>Screw this Noise</i>','New Voices 27. From <i>Thirty-Six Situatioins</i>']	
function makeAjax(){
	var xmlHttp;
	try{
		xmlHttp = new XMLHttpRequest();
	}catch(e){
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				xmlHttp = null;
			}
		}
	}
	return xmlHttp;
}
function news(){
	var list = document.getElementById("newslist");
	var xmlR = makeAjax();
	if(xmlR != null){
		xmlR.onreadystatechange = function(){
			if(xmlR.readyState == 4){
				var xmlDoc = xmlR.responseXML.documentElement;
				var ilist = xmlDoc.getElementsByTagName("item");
				for(var i = 0; i < ilist.length;i++){
					var x = document.createElement("li");
					var a = document.createElement("a");	
					a.href = ilist[i].getElementsByTagName("link")[0].firstChild.nodeValue;
					a.innerHTML=ilist[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue +": "+ ilist[i].getElementsByTagName("title")[0].firstChild.nodeValue;
					x.appendChild(a);
					list.appendChild(x);
				}
			}
		}
		xmlR.open("GET","http://users.wpi.edu/~theatre/news/rss.cgi",true);
		xmlR.send(null);
	}else{
		var item = document.createElement("li");
		item.innerHTML="Failed to load news feed";
		list.appendChild(item);
	}
	slideshow();
	return;
}
function slideshow(){
	clearTimeout(t);
	p = document.getElementById("simage");
	x = document.getElementById("stext");
	p.src = simages[c % simages.length];
	x.innerHTML=stext[c % stext.length];
	c = c + 1;
	t = setTimeout(slideshow,15000);
	return
}
