var w = 1;
var h = 1;

if (document.getElementById || document.all){
	document.write('<div id="imgtrace" style="position:absolute; visibility:hidden; left:0px; top:-1000px; border:1px solid #ccc; background:#fff; padding:5px;"><img id="ttimg" src="/image/loader.gif" /></div>');
}

function getImg(){
	if (document.getElementById){
		return document.getElementById("imgtrace").style;
	} else if (document.all){
		return document.all.trailimagid.style;
	}	
}

function trueBody(){
	return (!window.opera && document.compatMode && document.compatMode != "BackCompat")?document.documentElement:document.body;
}

function hideImg(){
	document.onmousemove = "";
	document.getElementById('ttimg').src = '/image/loader.gif';
	getImg().visibility = "hidden";
	getImg().left = -1000;
	getImg().top = 0;
}

function showImg(width,height,file){
	if (navigator.userAgent.toLowerCase().indexOf('opera')==-1){
		w = width;
		h = height;
		
		document.getElementById('ttimg').src = file;
		document.onmousemove = followmouse;
		getImg().visibility = "visible";
		getImg().width = w+"px";
		getImg().height = h+"px";
	}
}


function followmouse(e){
	if (navigator.userAgent.toLowerCase().indexOf('opera')==-1){
		var xcoord = 20;
		var ycoord = 20;

		if (typeof e != "undefined"){
			xcoord += e.pageX;
			ycoord += e.pageY;
		} else if (typeof window.event != "undefined"){
			xcoord += trueBody().scrollLeft+event.clientX;
			ycoord += trueBody().scrollTop+event.clientY;
		}

		var docwidth = document.all?trueBody().scrollLeft+trueBody().clientWidth:pageXOffset+window.innerWidth-15;
		var docheight = document.all?Math.max(trueBody().scrollHeight, trueBody().clientHeight):Math.max(document.body.offsetHeight,window.innerHeight);

		if (xcoord+w+3 > docwidth) xcoord = xcoord-w-(20*2);
		if (ycoord-trueBody().scrollTop+h > trueBody().clientHeight) ycoord = ycoord-h-20;

		getImg().left = xcoord+"px";
		getImg().top = ycoord+"px";
	}
}