var posx=0;
var posy=0;


function initHTTP(url, e){			
	posx = e.clientX;
	posy = e.clientY;
	var xmlhttp = false;
	var divPopup =  document.getElementById("divPopup");
	
	if(divPopup){
		if(divPopup.style.display != "none"){
			divPopup.innerHTML = "";
			divPopup.style.display = "none";
		}
	}
	
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");			
		} catch(E){
			xmlhttp = false;
		}
	}

	if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
		try{
			xmlhttp = new XMLHttpRequest();
		} catch(e){
			xmlhttp = false;
		}
	}

	if(!xmlhttp && window.createRequest){
		try{
			xmlhttp = window.createRequest();
		} catch(e){
			xmlhttp=false;
		}
	}

	xmlhttp.open("GET", url, true);
	xmlhttp.setRequestHeader("Content-Type", "text/html");
	xmlhttp.setRequestHeader("Cache-Control", "no-cache"); 
	xmlhttp.setRequestHeader("Expires", new Date());	
	xmlhttp.onreadystatechange=function(){
	  	if(xmlhttp.readyState==4){		  	
			popupBox(xmlhttp);
		}
	}
	xmlhttp.send(null);
}


function popupBox(xmlhttp){
	var xmlDoc, tblObj, trObj, tdObj, selObj;
	if(xmlhttp.readyState == 4){		
		if(xmlhttp.status == 200){							
			//alert(posx + " : " + posy);
			var obj =  document.getElementById("divPopup");						
			//obj.innerHTML = xmlhttp.responseText + "<br><div style=\"text-decoration:underline;color:blue;cursor:hand;\" onclick=\"document.getElementById('divPopup').style.display='none';\">Click to close</div>";
			obj.innerHTML = xmlhttp.responseText;
			obj.style.display="block";	
			
			obj.style.left = document.body.scrollLeft + posx; //e.clientX;
			obj.style.top = document.body.scrollTop + posy; //e.clientY;			
			
			if(posy + obj.clientHeight > document.body.clientHeight)
				obj.style.top = document.body.clientHeight - obj.clientHeight + document.body.scrollTop - 4;
			if(posx + obj.clientWidth > document.body.clientWidth)
				obj.style.left = document.body.clientWidth - obj.clientWidth + document.body.scrollLeft - 4;
			obj.focus();
		}
		else if(xmlhttp.status==404)
			alert("The URL does not exists. Please contact system administrator.")
	}
	else
		alert("There was a problem retrieving the XML data");		
}

