//lookupRandomShow.js
//2008-03-01, Luke McKenzie theclockspot.com

//This .js uses lookupRandomShow.php to get, and place onto index.php
//controls dom @ <div id='randomshowbox'>
//Note that the Random Show process, unlike the Banner Stuff process, does not use XML, but plain html markup generated by lookupRandomShow.php (for now).
	
//requires pathtohome
//requires ajax.js

//request object
var request = getAjaxRequestObj();

//as this is just a randomizer, we're not expecting any input - however, both image and slogan are done by this
function lookupRandomShow() {
	//requires js pathtohome!
	var url = pathtohome+'data/lookupRandomShow.php?dummy=' + new Date().getTime(); //to prevent browser caching
	request.open("GET", url, true);
	request.onreadystatechange = lookupRandomShowUpdate;
	request.send(null); //there it gooooes
}

function lookupRandomShowUpdate() {
	if(request.readyState == 4) { //when it's done
		if(request.status == 200) {
			
			document.getElementById("randomshowbox").innerHTML = request.responseText;
			//wow i am in awe of this one line of code hbluhbgluhblgubhg
			document.getElementById("randomshowbox").style.display = 'block';
			
		} else { //if the status isn't 200, this will alert us to problems //FIX EVERYWHERE
			var msgs = 'Error! request came back with status '+request.status+'.';
			var bitsy = request.getResponseHeader("Status");
			if(bitsy) msgs += '\n\n'+bitsy;
			alert(msgs);
		} //close if request.status = 200
	}
}