/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/
/*
	Image zoom configuration
*/
var imageObj = new Image();
var offsetfrommouse=[10,10]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var maxHeight = 300;
var maxWidth = 300;
var minHeight = 200;
var minWidth = 200;
var showPic = false;

if (document.getElementById || document.all)
	document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:200px;height:200px"><table align="center" width="100%" height="100%" valign="middle" border="0"><tr align="center" valign="middle"><td align="center"><img id="ttimg" src="/appOldStyle/images/spacer.gif" border="0" align="center" /></td></tr></table></div>');
	
	//document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:200px;height:200px"><table align="center" width="100%" height="100%" valign="middle" border="0"><tr align="center" valign="middle"><td align="center"><img onload="javascript:resizeImage()" id="ttimg" src="/ecut/images/spacer.gif" border="0" align="center" /></td></tr></table></div>');
	
	//document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:200px;height:200px;border:1px solid #666666"><table align="center" valign="middle" width="100%" height="100%" border="0"><tr align="center" valign="middle"><td align="center" valign="middle"><img width="100%" height="100%" id="ttimg" src="/ecut/images/spacer.gif" border="0" align="center" /></td></tr></table></div>');
	//document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:200px;height:200px;border:1px solid #666666"><img width="50%" height="50%" id="ttimg" src="/ecut/images/spacer.gif" border="0" align="center" /></div>');



function resizeImage(){
	var w = document.getElementById('ttimg').width;
	var h = document.getElementById('ttimg').height;

	if(w < minWidth || h < minHeight)
		return;
		
	while(w > maxWidth || h > maxHeight){
		w = w / 1.1;
		h = h / 1.1;
	}
	gettrailobj().width = w;
	gettrailobj().height = h;
	document.getElementById('ttimg').width = w;
	document.getElementById('ttimg').height = h;
	followmouse;
	if(showPic)
	{
		showPic = false;
		gettrailobj().visibility="visible";
	}
}

function gettrailobj(){
	if (document.getElementById)
		return document.getElementById("trailimageid").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(){
	document.getElementById('ttimg').src='';
	gettrailobj().visibility="hidden";
	document.onmousemove="";
}

function showtrail(file)
{
	//alert(navigator.appName+'-'+navigator.appCodeName);
	if (navigator.appName.indexOf("Opera") > -1) {return ;}
	
	img = new Image;
	img.src = file;
	showPic = true;
	document.getElementById('ttimg').src=file;
	document.getElementById('ttimg').width=img.width;
	document.getElementById('ttimg').height=img.height;
	resizeImage();
	document.onmousemove = followmouse;
	//gettrailobj().visibility="visible";
}

function followmouse(e){
	var xcoord=offsetfrommouse[0];
	var ycoord=offsetfrommouse[1];
	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+3>docwidth || ycoord> docheight)
	{
		gettrailobj().display="none";
	}
	else 
	{
		var IE = document.all?true:false;

		var img_height = document.getElementById('ttimg').height;
		var height = 0;
		var y = 0;
		var diff = 0;
				
		if(IE) {
			y = event.clientY;
			height = document.body.clientHeight;
			diff = y+img_height-height+20;
		}
		else {
			y = e.clientY;
			height = window.innerHeight;
			diff = y+img_height-height+40;
		}

		if(diff > 0) ycoord = ycoord - diff;

		gettrailobj().display="";
		gettrailobj().left=xcoord+"px";
		gettrailobj().top=ycoord+"px";
	}
}
