var xmlHttp;
var dataDiv;
var offserE1;

function createXMLHttpRequest(){
	if(window.XMLHttpRequest){
		xmlHttp=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		xmlHttp=new ActiveXObject("MSXML2.XMLHTTP.3.0");
	}
}

function initVars(){
	dataDiv=document.getElementById("popup");
}

function getCourseData(element,showid){
	initVars();
	createXMLHttpRequest();
	offsetE1=element;
	var url="toolTip.asp?id="+showid;

	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=callback;
	xmlHttp.send(null);
}

function callback(){
	if(xmlHttp.readyState==4){
		if(xmlHttp.status==200 || xmlHttp.status==0){
			setData(xmlHttp.responseText);
		}
	}
}

function setData(courseData){
	clearData();
	setOffsets();
	dataDiv.innerHTML=xmlHttp.responseText;
}

function setOffsets(){
	var end=calculateOffsetLeft(offsetE1)+offsetE1.offsetWidth+5;
	var top=calculateOffsetTop(offsetE1);
	dataDiv.style.border="black 1px solid";
	dataDiv.style.left=end+"px";
	dataDiv.style.top=top+"px";
}

function calculateOffsetLeft(field){
	return calculateOffset(field,"offsetLeft");
}

function calculateOffsetTop(field){
	return calculateOffset(field,"offsetTop");
}

function calculateOffset(field,attr){
	var offset=0;
	while(field){
		offset+=field[attr];
		field=field.offsetParent;
	}
	return offset;
}

function clearData(){
	dataDiv.innerHTML="";
	dataDiv.style.border="none";
}