/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var contentfloat=['',1,1]
var offsetfrommouse=[10,10] //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="contentfloatid"></div>')
  }

function getfloat(){
if (document.getElementById)
return document.getElementById("contentfloatid")
else if (document.all)
return document.all.trailimagid
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showfloat(img, assetname, author, price, typedisplay){
  
document.onmousemove=followmouse;
//document.getElementById("contentfloatid").src = img;
//contentfloat[1]
newht = '<div style="padding: 6px; background-color: #FFFFFF; border: 1px solid #888888;">';
newht = newht + '<span class="bluebold">' + assetname + '</span><br />';
newht = newht + 'by '+ author +' - ';
newht = newht + '<span class="bluetext">' + price + '</span><br />';
newht = newht + 'formats: ' + typedisplay + '<br />';
newht = newht + '<div align="center" style="padding: 2px 2px 18px 2px;"><img src="'+img+'" border="0" width="'+200+'px" height="'+200+'px"></div>';
newht = newht + '</div>';

getfloat().innerHTML = newht;
getfloat().style.visibility="visible";
getfloat().style.z_index="1";

}

function hidefloat(){
getfloat().style.visibility="hidden";
document.onmousemove="";
getfloat().style.left="-500px";
getfloat().style.z_index="-1";
}

function followmouse(e){
  //offset from mouse is set above as two numbers
  var xcoord=offsetfrommouse[0]
  var ycoord=offsetfrommouse[1]
  
  //docwidth ternary op? truebody? If certain cond = return document element or document body
  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)
  
  
  var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

  if (typeof e != "undefined"){
    if (docwidth - e.pageX < 250){
			xcoord = e.pageX - xcoord - 320; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
  
  if (docheight - e.pageY < 400){
			ycoord += e.pageY - Math.max(0,(400 + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}
  
  }
  else if (typeof window.event !="undefined"){
    
    if (docwidth - event.clientX < 250){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 320; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < 400){
		  //alert(event.clientY);		 
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(400 + event.clientY - docheight));
			//alert(event.clientY);
			
		} else {
		  
			ycoord += truebody().scrollTop + event.clientY;
		}
    
  }

  getfloat().style.display=""
  getfloat().style.left=xcoord+"px"
  getfloat().style.top=ycoord+"px"
/*
  if (xcoord+contentfloat[1]+3>docwidth || ycoord+contentfloat[2]> docheight){
  alert(contentfloat[2]);
  getfloat().style.display="none";
  }else{ 
  getfloat().style.display=""
  getfloat().style.left=xcoord+"px"
  getfloat().style.top=ycoord+"px"
  }*/
  	
}

if (displayduration>0)
setTimeout("hidetrail()", displayduration*1000)