/*
Based on:
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[5,0]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px; z-index: 999;">');
	document.write('</div>');
}

function gettrailobj(){
	if (document.getElementById)
		return document.getElementById("trailimageid").style
	else if (document.all)
		return document.all.trailimagid.style
}

function gettrailobjnostyle(){
	if (document.getElementById)
		return document.getElementById("trailimageid")
	else if (document.all)
		return document.all.trailimagid
}


function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,wdth,hght){

	document.onmousemove=followmouse;
	w = wdth;
	h = hght;
	newHTML = '<div style="position: absolute; padding: 0px; text-align: left; width: ' + wdth + 'px; height: ' + hght + 'px; background-color: transparent; background-image:url(' + imagename + '); background-repeat: no-repeat; background-position: center top; z-index: 999;">';
	//newHTML = '<div style="position: absolute;padding: 0px; text-align: left; width: ' + wdth + 'px; height: ' + hght + 'px; background-color: transparent;">';
	//newHTML = newHTML + '<img src="' + imagename + '" border="0" width="' + w + '" height="' + h + '">';
	newHTML = newHTML + '<img src="' + imagename + '" border="0" width="' + w + '" height="' + h + '" /><br />';
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	//alert (newHTML);
	gettrailobj().display="inline";
}

function hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	if (typeof e != "undefined"){
		//mozilla
		xcoord += e.pageX;
		//alert ('koord' + xcoord + ' / ' + e.pageX);

	} else if (typeof window.event != "undefined"){
		//ie	
		xcoord += truebody().scrollLeft+event.clientX
		//alert ('koord' + xcoord + ' / ' + event.clientX);
	}

	if(xcoord < 22) { xcoord = 22; }
	if(xcoord > 1060) { xcoord = 1060; }

	gettrailobj().left=xcoord+"px"
	
	// zde je nastavena verikální poloha!
	if (window.innerHeight) { //FF
		ycoord = window.innerHeight - 116;
		//pokud je šířka okna < šířka elementu ramec, musíme u FF ještě posunout kvůli posuvníku
		if (window.innerWidth < 1100) {
			ycoord = ycoord - 16;
		}
	} else if (document.documentElement && document.documentElement.clientHeight) { // MSIE6-7 v std. režimu
		ycoord = document.documentElement.clientHeight - 116;
	} else if (document.body.clientHeight) { //IE 6 quirk a starší IE
		ycoord = document.body.clientHeight - 116;
	}	
	gettrailobj().top=ycoord+"px"

}


