/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/
var offsetfrommouse=[3,3]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	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(obj,imagename){
  gettrailobj().left=(zxcPos(obj)[0]+offsetfrommouse[0])+'px';
  gettrailobj().top=(zxcPos(obj)[1]+offsetfrommouse[1])+'px';
  newHTML = '<div align="center" ><img src="' + imagename + '" border="0" title=""></div>';
  gettrailobjnostyle().innerHTML = newHTML;
  gettrailobj().display="inline";
}


function hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
}


function zxcPos(zxcobj){
  zxclft=zxcobj.offsetLeft;
  zxctop=zxcobj.offsetTop;
  zxcwidth=zxcobj.width;
  zxcheight=zxcobj.height;
  while(zxcobj.offsetParent!=null){
    zxcpar=zxcobj.offsetParent;
    zxclft+=zxcpar.offsetLeft;
    zxctop+=zxcpar.offsetTop;
    zxcobj=zxcpar;
  }
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)


/*
  if ((docheight + truebody().scrollTop - zxctop - zxcheight) < (zxctop-truebody().scrollTop)){
    if (zxctop > (7.08*zxcheight+10)){ //10 je soucet sirky pozadi obrazku viz css, 7.08 je pomer mezi malym a velkym obrazkem
      zxctop += -7.08*zxcheight-12-2*offsetfrommouse[1]; //12 je soucet sirky ramu a sirky pozadi obrazku viz css
    }
  }
*/  
  
  
  if ((docheight + truebody().scrollTop - zxctop) < (7.08*zxcheight+10)){
    if ((zxctop - truebody().scrollTop + zxcheight) > (7.08*zxcheight+10)){
      zxctop += -7.08*zxcheight-12-2*offsetfrommouse[1]; //12 je soucet sirky ramu a sirky pozadi obrazku viz css
    } else {
      zxctop += -((7.08*zxcheight+12+2*offsetfrommouse[1])-(truebody().scrollTop+docheight-zxctop))
    }
  }
  
  
  
  zxclft+=zxcwidth;
  zxctop+=zxcheight;
  return [zxclft,zxctop];
}
