var img_xmlhttp = null;

function loadImg(fileId) {
	document.getElementById("entityimgresult").style.display = 'none';	
	document.getElementById("entityimgresult").innerHTML='';
	document.body.style.cursor = 'wait';
	document.getElementById("entityimgworking").style.display = 'block';
	img_xmlhttp = null;


    if(window.XMLHttpRequest) {
    	try {
			img_xmlhttp = new XMLHttpRequest();
        } catch(e) {
			img_xmlhttp = null;
        }

    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	img_xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		img_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		img_xmlhttp = null;
        	}
		}
	}
    

	if (img_xmlhttp != null)
	{
		img_xmlhttp.open("POST", "/getentityimg/", true)
		img_xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");         		
		img_xmlhttp.onreadystatechange = fillentityimgResultList
		var data = "fileid=" + fileId;
		img_xmlhttp.send(data)
	}
}

function fillentityimgResultList(){

	if(img_xmlhttp.readyState != 4) return;

	if (img_xmlhttp.status==200) {
		var xml = img_xmlhttp.responseText;
		document.getElementById("entityimgresult").style.display = 'block';
		document.getElementById("entityimgresult").innerHTML = xml;
	}
	else {
		alert("Problem retrieving data: " + img_xmlhttp.status + " " + img_xmlhttp.statusText)			
		//document.getElementById("entityimgresult").style.display = 'none';
		document.getElementById("entityimgresult").innerHTML = "";
	}

	document.body.style.cursor = 'auto';	
	document.body.style.cursor = 'auto';
	document.getElementById("entityimgworking").style.display = 'none';
}