
/* The object */
var g_oHttpReq = 0;
var g_iCounter = 0;

/* The function */
function Update_Image()
{		
	// Double check the request object, can't be too careful
	//if(g_oHttpReq == 0)
	//	return;
	
	g_oHttpReq.open("GET", "get_media_img.php?id=" + g_iCounter, true);
	g_oHttpReq.onreadystatechange = Process_Image;
	g_oHttpReq.send(null);
}

function Process_Image()
{
	if (g_oHttpReq.readyState == 4) {
		if(g_oHttpReq.status == 200) {
			response = g_oHttpReq.responseText;
			
			// Get the element		
			oElement = document.getElementById("media_center_img");
		
			// Update the source
			oElement.src = response;
			
			// Reset
			window.setTimeout("Update_Image()", 2000);
			g_iCounter++;
		}
	}
}

/* The Setup function */
function Initialize_Page()
{
	/* Attempt to set up the AJAX interface */
	if(document.all) {
		try { g_oHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e) {
			try { g_oHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e1) { g_oHttpReq = 0; }
		}
	}
	
	/* Try something different (Mozilla browsers) */
	if (!g_oHttpReq && typeof XMLHttpRequest != 'undefined')
		g_oHttpReq = new XMLHttpRequest();
	
	/* If we're setup, initialize the timer */
	window.setTimeout("Update_Image()", 2000);
}