/*
Simple Image Trail script- By JavaScriptKit.com
Modified Bialis - F.Agelan - www-plantsforourfuture.com
*/

var w=1;
var h=1;
var sw=1;
var sh=1;

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:1px solid #336633;background:#DDDDDD;z-index:9000;"><img id="simg" src="../images/transparent.gif" /></div>')

function truebody() {
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function gettrailobj(){
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimageid.style
}

var coeff=4;
var coeff2=0.5;

function changer(objName) {        
    
var src = "";
obj = document.getElementsByName(objName).item(0); 
w = Math.round(obj.width*100);     
h = Math.round(obj.height*100);
    
src = obj.src.replace("images/","images/large/");   
src = src.replace(".gif","_LRG.gif");
src = src.replace(".jpg","_LRG.jpg");
src = src.replace(".png","_LRG.png");

// document.body.clientWidth/2 document.body.clientHeight/2
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 (w> docwidth/coeff) {coeff2=w/(docwidth/coeff);sw=docwidth/coeff;sh=h*(docwidth/coeff)/w;}
w = Math.round(sw); 
h = Math.round(sh);
document.getElementById('simg').src=src;
document.getElementById('simg').width=w;
document.getElementById('simg').height=h;
gettrailobj().width=w+"px";
gettrailobj().height=h+"px";
gettrailobj().visibility="visible";
document.onmousemove=followmouse;
}
function initial(objName) {
	document.onmousemove=""
	document.getElementById('simg').src='../images/transparent.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=0
}
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;
		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"
	}
}
