/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

/*Extended and modified by mm 2008 for AvMatch.com*/

var contentfloat=['',1,1]
var offsetfrommouse=[15,-50] //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, local, skavgender, mem_id){

intro = intros[mem_id];
onlinestatus = online[mem_id];

	var wordwrap = '';
	var userAgent = navigator.userAgent.toLowerCase();
	var pattern6 = /msie/;
	if(pattern6.test(userAgent)){
		wordwrap = "word-wrap: break-word;";
	}


document.onmousemove=followmouse;
//document.getElementById("contentfloatid").src = img;
//contentfloat[1]
newht = '<div style="width: 245px; background-image: url('+dir+'float_r1.png); ">';
newht = newht + '<div style="padding: 6px; width: 226px; background-color: #FFFFFF; border: 1px solid #888888; ' + wordwrap +' overflow: hidden;">';
newht = newht + '<span class="bluebold14">' + assetname + '</span><br />';
newht = newht + '<div class="greygiflinemargin"></div>';
newht = newht + '<span class="greentext">' + onlinestatus + '</span><br />';
newht = newht + '<span class="bluetext">From: '+ local +'</span><br />';
newht = newht + '<span class="greentext">Seeking: '+ skavgender +' avatars</span><br />';
newht = newht + '<div class="greygiflinemargin"></div>';
newht = newht + '<span class="bluetext">Introduction: ' + intro + '</span><br /><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></div>';
newht = newht + '<div style="height: 4px; width: 245px; background-image: url('+dir+'float_b1.png);background-repeat: no-repeat;"></div>';

getfloat().innerHTML = newht;
getfloat().style.visibility="visible";
getfloat().style.zIndex="1";

}

function hidefloat(){
getfloat().style.visibility="hidden";
document.onmousemove="";
getfloat().style.left="-500px";
getfloat().style.zIndex="-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 - 240; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
  
  if (docheight - e.pageY < 400){
			ycoord += e.pageY - Math.max(0,(415 + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY - 40;
		}
  
  }
  else if (typeof window.event !="undefined"){
    
    if (docwidth - event.clientX < 250){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 240; // 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,(390 + 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"
  }*/
  	
}

function showImgFloat(img, imgname, mem_id){

offsetfrommouse=[15,20];

	var wordwrap = '';
	var userAgent = navigator.userAgent.toLowerCase();
	var pattern6 = /msie/;
	if(pattern6.test(userAgent)){
		wordwrap = "word-wrap: break-word;";
	}

document.onmousemove=followmouse;
newht = '<div style="width: 345px; background-image: url('+dir+'float_r1.png); ">';
newht = newht + '<div style="padding: 6px; width: 326px; background-color: #FFFFFF; border: 1px solid #888888; ' + wordwrap +' overflow: hidden;">';
newht = newht + '<span class="bluebold14">' + imgname + '</span><br />';
newht = newht + '<div class="greygiflinemargin"></div>';
newht = newht + '<div align="center" style="padding: 2px 2px 18px 2px;"><img src="'+img+'" border="0" width="'+320+'px" height="'+320+'px"></div>';
newht = newht + '</div></div>';
newht = newht + '<div style="height: 4px; width: 245px; background-image: url('+dir+'float_b1.png);background-repeat: no-repeat;"></div>';

getfloat().innerHTML = newht;
getfloat().style.visibility="visible";
getfloat().style.zIndex="1";

}

if (displayduration > 0){ setTimeout("hidetrail()", displayduration*1000); }