var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

if (document.getElementById || document.all){
	document.write('<div id="imgtrailer" style="position:absolute; z-index:4;visibility:hidden;"><img src="images/loading.gif"  width="32" height="32"></div>')
	//document.write('<div id="imgtrailer_load" style="position:absolute; height:600px; width:600px; z-index:4;display:none;"><center><img src="images/loading.gif"  width="32" height="32"></center></div>')
}

function gettrailobject()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.trailimagid
	}

function gettrailobj()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer").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 hidetrail()
	{
	gettrailobject().innerHTML=" ";
	document.onmousemove='';
	gettrailobj().visibility="hidden";
	}

	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}


function trailOn(thumbimg,thh,thw)
	{
		var a = thumbimg; 
		//document.getElementById("imgtrailer").style.display = '';
		gettrailobj().visibility="visible";
		
		//document.getElementById('imgtrailer_load').innerHTML='<div style="background-color: #FFFFFF;"><center><img src="images/loading.gif"  width="32" height="32"></center></div>'
		//document.getElementById('imgtrailer_load').style.display='';
		//document.getElementById('imgtrailer').style.display='none';
	//if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		//{
		gettrailobj().left="-500px";
		divthw = parseInt(thw) + 2;
		var preloadFlag = false;
		if (document.images) {
			index_1 = newImage(thumbimg);
			preloadFlag = true;
		}
		if (preloadFlag)
		{
			gettrailobject().innerHTML = '<div style="background-color: #FFFFFF;border: 1px solid #000000;background-repeat: no-repeat;height:390px;width:482px;" id="test1"><center><br><br><br><br><img src="images/loading.gif"><br><P STYLE="font-family:arial;color:#000000;font-size:12px;font-weight:bold;"><br><br>downloading.. please wait...</p></center></div><div style="background-color: #FFFFFF;border: 1px solid #000000;background-repeat: no-repeat;visibility:hidden;" id="test2"><center><img src="'+a+'" height="'+thh+'" width="'+thw+'" ONLOAD="showmyimg();"></center></div>';
	
			//document.getElementById('imgtrailer_load').style.display='none';
			//document.getElementById('imgtrailer').style.display='';
			//gettrailobj().visibility="visible";
			divw = parseInt(thw)+25;
			divh = parseInt(thh)+130;
			document.onmousemove=followmouse;
		}
		//}
	}

function showmyimg()
{
	
 	//document.getElementById('test1').style.visibility="hidden";
	document.getElementById('test1').style.display="none";
	document.getElementById('test2').style.visibility="visible";
// 	document.getElementById('imgtrailer').style.display='';
// 	document.getElementById('imgtrailer').style.visibility="visible";
}

function followmouse(e)
	{
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
if(typeof e != "undefined")
	{
	if(docwidth < 15+e.pageX+divw)
		xcoord = e.pageX-divw-5;
	else
		xcoord = 15+e.pageX;
	if(docheight < 15+e.pageY+divh)
		ycoord = 15+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
	else
		ycoord = 15+e.pageY;
	}
else if (typeof window.event != "undefined")
	{
	if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
		xcoord = truebody().scrollLeft-5+event.clientX-divw;
	else
		xcoord = truebody().scrollLeft+15+event.clientX;

	if(docheight < 15+truebody().scrollTop+event.clientY+divh)
		ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
	else
		ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}
