// JavaScript Document
function displayRandomCapper(){
	document.write("<div id='randomCapper'></div>");	
	ajaxFunction("capperRandom.php?rnd="+Math.random(),"randomCapper");
}

function displayCapper(capperID){
	document.write("<div id='capper_"+capperID+"'></div>");	
	ajaxFunction("capperRandom.php?capperID="+capperID+"&rnd="+Math.random(),"capper_"+capperID+"");
}

function displayPodcast(podID){
	document.write("<div id='pod"+podID+"'></div>");	
	ajaxFunction("podDisplay.php?podID="+podID+"&rnd="+Math.random(),"pod"+podID+"");
}

function displayPick(pickID){
	document.write("<div id='pick"+pickID+"'></div>");	
	ajaxFunction("pickDisplay.php?pickid="+pickID+"&rnd="+Math.random(),"pick"+pickID+"");
}

function displayMyPick(pickID){	
	document.write("<div id='myPick"+pickID+"'></div>");	
	ajaxFunction("pickDisplay.php?pickid="+pickID+"&rnd="+Math.random(),"myPick"+pickID+"");
}

function displayOneGame(oneGameID){
	//alert(oneGameID);
	document.write("<div id='myOneGame"+oneGameID+"'></div>");	
	ajaxFunction("oneGameDisplay.php?oneGameID="+oneGameID+"&rnd="+Math.random(),"myOneGame"+oneGameID+"");
}

function ajaxFunction(urlurl,divName)
{
	var xmlHttp;
	try{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			//alert(xmlHttp.responseText);
			var res = xmlHttp.responseText;
			arrRes = res.split("###");
			if(arrRes.length>0){
				document.getElementById(divName).innerHTML=arrRes[0];
				eval(arrRes[1]);
			}else{
				document.getElementById(divName).innerHTML=xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",urlurl,true);
	xmlHttp.send(null);
}
