function getImage(cardname,ev,setname){
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	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;
		}
	}
	if (setname)
		xmlhttp.open("GET", "/wow/image.php?fd_name="+ cardname +"&fd_setname=" + setname,true);
	if (!setname)
		xmlhttp.open("GET", "/wow/image.php?fd_name="+ cardname ,true);
	 xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		var theDiv=document.getElementById("theImageDiv");
		theDiv.innerHTML=xmlhttp.responseText;
	   	//alert(xmlhttp.responseText);
	  }
	 }
	 xmlhttp.send(null)
}
var mouseOffset = null;
var targetLock =false;
var mouseLock =false;
function getMouseOffset(target, ev){
	ev = ev || window.event;

	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	
	//alert(mousePos.x+"-"+mousePos.y);
	//return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
	return {x:mousePos.x, y:mousePos.y};
}
function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}
function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	
	return {
		//x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		x:ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft,
		y:ev.clientY + document.body.scrollTop + document.documentElement.scrollTop
		//y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}
function showImageDiv(target,ev, setname){
	if(targetLock||mouseLock) return;
	targetLock=true;
	if (!ev) ev = window.event;
	getImage(target.id, ev, setname);
	var mouseOffset=getMouseOffset(target, ev);
	var theDiv=document.getElementById("theImageDiv");
	theDiv.style.position='absolute';
	theDiv.style.top=mouseOffset.y-100+"px";
	theDiv.style.left=mouseOffset.x+120+"px";
	theDiv.style.visibility="visible";
	theDiv.zIndex=9999999999;
}
function imageDivMouseOff(){
	targetLock=false;
	setTimeout(hideImageDiv,100);
}
function mouseOverDiv(){
	targetLock=false;
	mouseLock=true;
}
function mouseOffDiv(){
	mouseLock=false;
	setTimeout(hideImageDiv,100);
}

function hideImageDiv(){
	if (targetLock || mouseLock) return;
	targetLock=false;	
	mouseLock=false;
	var theDiv=document.getElementById("theImageDiv");
	theDiv.innerHTML="";
	theDiv.style.visibility="hidden";
}
