<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://www.willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition() {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
}

function move_f_p(d){

// -- get window/viewport size and check if the box goes over the edgeÉ
    var viewportwidth;
    var viewportheight;
    if (typeof window.innerWidth != 'undefined'){
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
    } else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0){
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
    } else{
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
    }
// -- end of get viewport

  if(cX+360>viewportwidth){ cX=viewportwidth-360; }

  d.style.left = (cX-30) + "px";
  d.style.top = (cY-30) + "px";
}
function float_players(v,x,y,p,p2,friend, new_rating, old_rating, games_average, games_high, painted_rating, painted_highest, painted_average, triple_rating, triple_highest, triple_average, gold_medals, silver_medals, bronze_medals,thumbs_ups ){
  if(document.all){
    var f = document.all.tags("DIV")['players_float'];
  } else{
    var f = document.getElementById('players_float');
  }
  if(games_average>0){
    stats = "<TABLE BORDER=0 WIDTH=100% cellpadding=2 cellspacing=0><tr><td width=60>&nbsp;</td><td width=100 style=\"border-right:1px solid black\" align=center><b>Standard</b></td><td style=\"border-right:1px solid black\" width=100 align=center><b>Painted</b></td><td width=100 align=center><b>Triple</b></td></tr><tr><td>Rating:</td><td style=\"border-right:1px solid black\" align=right>"+new_rating+"</td><td style=\"border-right:1px solid black\" align=right>"+painted_rating+"</td><td align=right>"+triple_rating+"</td></tr><tr><td>Highest:</td><td style=\"border-right:1px solid black\" align=right>"+games_high+"</td><td style=\"border-right:1px solid black\" align=right>"+painted_highest+"</td><td align=right>"+triple_highest+"</td></tr><tr><td>Average:</td><td style=\"border-right:1px solid black\" align=right>"+games_average+"</td><td style=\"border-right:1px solid black\" align=right>"+painted_average+"</td><td align=right>"+triple_average+"</td></tr></table>";
    stats += "<table border=0 width=100% cellpadding=2 cellspacing=0 style=\"margin-top:10px\"><td>XP: <b>"+old_rating+"</b></td><td><img src=\"/web_images/misc/gold25.png\">:</td><td>"+gold_medals+"</td><td><img src=\"/web_images/misc/silver25.png\">:</td><td>"+silver_medals+"</td><td><img src=\"/web_images/misc/bronze25.png\">:</td><td>"+bronze_medals+"</td><td><img src=\"/web_images/misc/thumb-up.png\">:</td><td>"+thumbs_ups+"</td></tr></table>";
  } else{
    stats = '';
  }
  switch(friend){
    case '1':
      p2 += " - FRIEND";
      friendlink = "<A HREF='/players/friends.php?playername="+p2+"' TITLE='Go To Friends List'><IMG SRC='/web_images/icons/user--minus.png' HEIGHT='24' WIDTH='24' ALT='Go To Friends List' BORDER='0'></A>";
      break;
    case '-1':
      p2 += " - FOE";
      friendlink = "<A HREF='/players/foes.php?playername="+p2+"'><IMG SRC='/web_images/icons/user-thief-female.png' HEIGHT='24' WIDTH='24' ALT='Go To To Foes List' BORDER='0'></A>";
      break;
    default:
      friendlink = "<A HREF='/players/friends.php?playername="+p2+"' TITLE='Add To Friends List'><IMG SRC='/web_images/icons/user--plus.png' HEIGHT='24' WIDTH='24' ALT='Add To Friends List' BORDER='0'></A>&nbsp;&nbsp;<A HREF='/players/foes.php?playername="+p2+"' TITLE='Add To Foes List'><IMG SRC='/web_images/icons/user-thief.png' HEIGHT='24' WIDTH='24' ALT='Add To Foes List' BORDER='0'></A>";
      break;
  }
  if(v=='visible'){
    f.innerHTML = "<table cellspacing=0 border=0 cellpadding=1 width=98%><tr><td width=55% style=\"border-bottom:2px solid black\"><h4>"+p2+"</h4></td><td width=50% align=right style=\"padding:5px;border-bottom:2px solid black\"><A HREF='/players/profile_view.php?player="+p+"' TITLE='"+language['js_l2']+"'><IMG SRC='/web_images/icons/user-silhouette-question.png' HEIGHT='24' WIDTH='24' ALT='"+language['js_l2']+"' BORDER='0'></A>&nbsp;&nbsp;<A HREF='/community/messages_compose.php?sendto="+p+"' TITLE='"+language['js_l1']+"'><IMG SRC='/web_images/icons/mail--arrow.png' HEIGHT='24' WIDTH='24' ALT='"+language['js_l1']+"' BORDER='0'></A>&nbsp;&nbsp;"+friendlink+"&nbsp;&nbsp;<A HREF='/community/admin_support.php?sendto=0&reportplayer="+p+"' TITLE='"+language['js_la1']+"'><IMG SRC='/web_images/icons/user-report.png' HEIGHT='24' WIDTH='24' ALT='"+language['js_la1']+"' BORDER='0'></A></td></tr></table>"+stats;
  }
  AssignPosition();
  oldt = f.style.top.substr(0,f.style.top.length-2);
  oldl = f.style.left.substr(0,f.style.left.length-2);
  oldb = oldt*1 + 150;
  oldr = oldl*1 + 360;
  if(v!='hidden' || (v=='hidden' && !(cX+2<=oldr && cX-2>=oldl && cY+2<=oldb && cY-2>=oldt)) ){
    move_f_p(f);
    f.style.visibility = v;
  }
  if(f.style.visibility=='hidden'){
    f.style.top = '1px';
    f.style.left = '1px';
  }
}
function hidefloat(){
c = setTimeout("float_players('hidden',0,0,0);",10);
}


function showsmiley(symbol, field){
  if(field==''){
    var field = document.messageform.message;
  }
  symbol = ' ' + symbol + ' ';
  field.value += symbol;
}
