var _ms_XMLHttpRequest_ActiveX = ""; // Holds type of ActiveX to instantiate

var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
	
var AJAX_obj;

var last_image = "";

function change_artwork(name,img,id)
{
	var url = "/change_artwork.php?id=" + id + "&name=" + name + "&img=" + img;
	
	if (img != last_image)
	{
		document.getElementById("show_image").innerHTML = "<table width='300' border='0'><tr><td height='256' align='center' valign='middle'><img src='/animations/loading.gif' width='70' height='18' border='0'></td></tr></table>";
	
		//if (!AJAX_obj) // Object not yet created?
		//{
			if (window.XMLHttpRequest) 	// Non I.E. browsers
			{
				AJAX_obj = new XMLHttpRequest();
			} 
			else if (window.ActiveXObject)  // Internet Explorer
			{
				// Instantiate the latest MS ActiveX Objects
				if (_ms_XMLHttpRequest_ActiveX) {
					AJAX_obj = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);
				} 
				else // loops through the various versions of XMLHTTP to ensure we're using the latest
				{
					for (var i = 0; i < versions.length ; i++) 
					{
						try 
						{
							AJAX_obj = new ActiveXObject(versions[i]);
							if (AJAX_obj) {
								_ms_XMLHttpRequest_ActiveX = versions[i]; // save a reference to the proper one to speed up future instantiations
								break;
							}
						}
						catch (objException) {
						// trap; try next one
						} ;
					} ;
				}
			}
		//}
		
		AJAX_obj.onreadystatechange = call_back;    
		AJAX_obj.open( "GET", url, true );
		AJAX_obj.send(null);
	}
	last_image = img;
}

function call_back() 
{
	if ( AJAX_obj.readyState == 4 ) 
	{
		if (AJAX_obj.status == 200) 
		{
				document.getElementById("show_image").innerHTML = AJAX_obj.responseText;

				//alert();
		}
	}
}

