﻿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: 999999;visibility:hidden;"></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 trailOff()
	{
	document.onmousemove='';
	gettrailobj().visibility="hidden";
	}

function trailOn(thumbimg,imgtitle,username,imgid,imgsize,credit,level,thw,thh)
	{
	if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		{
		gettrailobj().left="-500px";
		gettrailobj().zindex="999999";
		divthw = parseInt(thw) + 2;
		gettrailobject().innerHTML = '<div style="position: relative; z-index: 999999; background-color: #39435c; layer-background-color: #39435c; border: 0px solid #3B3C3E; padding:10px; width:'+divthw+'px;"><div style="position: relative; z-index: 999999; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #3B3C3E;background-image: url(Images/lloading.gif);"><img src="'+thumbimg+'" border="0" width="'+thw+'" height="'+thh+'"></div><div style="position: relative; z-index: 999999; padding-top:7px; font-size: 10px; color: White; font-family: Verdana; text-align: left;">'+imgtitle+'</div></div>';
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+25;
		divh = parseInt(thh)+130;
		document.onmousemove=followmouse;
		}
	}

function followmouse(e)
{
	var sp = document.getElementById("test");
	var Container;
	Container = document.getElementById("ContainerW3C");
	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")
	{
	    docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	    if(docwidth < 15+e.pageX+divw)
		    xcoord = e.pageX-divw-5;
	    else
		    xcoord = 15+e.pageX;
    		
	    if(docheight < Container.scrollTop+e.pageY+divh)
	    {
	        if (e.pageY + 15 > docheight - 391)
	        {
	            ycoord = docheight - 391;
	        }
	        else
	        {
		        ycoord = e.pageY + 18;
		    }
		}
	    else
	    {
	        ycoord = e.pageY + 18;
	    }
	}
    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 < Container.scrollTop+event.clientY+divh)
	        {// bottom images
	                if (event.clientY + 15 > docheight-391)
	                {
	                    ycoord = docheight-391;

	                }
	                else
	                {
    		            ycoord = event.clientY + 15;
    		        }
	        }
	        else
	        {
                ycoord = event.clientY + 15;
	        }
        }
    }	

	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}


