// START ---> SHOW BALOON WITH USER BASIC INFORMATION --------------------------------------------------------------------------------------------
var MyTimeOut;
function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }
  return {top:y,left:x};
}

function PlaceBallon(msjID, div_id){
	    var elemento = document.getElementById('ImgThumb_'+msjID);
       // var pos = getAbsoluteElementPosition(elemento)
      //  alert("top="+pos.top+" left="+pos.left)
		document.getElementById(div_id).style.display='none';	
		ThumbPosX=document.getElementById('ImgThumb_'+msjID).offsetLeft + document.getElementById('Thumb_'+msjID).offsetParent.offsetLeft;		
		ThumbPosY= document.getElementById('Thumb_'+msjID).offsetTop + document.getElementById('Thumb_'+msjID).offsetParent.offsetTop - document.getElementById('div_messages').scrollTop;
		ThumbWidth=document.getElementById('ImgThumb_'+msjID).width;
		ThumbHeight=document.getElementById('ImgThumb_'+msjID).height;
		//alert(ThumbPosY);
		//document.getElementById('div_user_balloon').style.left=pos.left;
		document.getElementById('div_user_balloon').style.left=ThumbPosX;
		//document.getElementById('div_user_balloon').style.top=pos.top-151;
		document.getElementById('div_user_balloon').style.top=ThumbPosY-140;
		document.getElementById(div_id).style.display='';		
}
function HideBallon(){	
	document.getElementById('div_user_balloon').style.display='none';	
	request2=null;
	clearTimeout(MyTimeOut);
}
function DisplayBalloon(MsjID,userid){	
	userid2=userid;	
	MsjID2=MsjID;
	MyTimeOut=setTimeout("ReadLayer(MsjID2,userid2)",100);
}
function ReadLayer(msjID,userid){		
	//alert(userid);
	var div_id='div_user_balloon';
	document.getElementById(div_id).style.display='none';
	var request2=null;
	request2=createRequest();	
	if (document.all)
		var url='/layer_user_stats_explorer.php?userid='+escape(userid)+'&rand='+Math.random() ;	
	else
		var url='/layer_user_stats.php?userid='+escape(userid)+'&rand='+Math.random() ;	
	//alert (url);
	request2.open("GET",url,true);
	request2.onreadystatechange=function() {
									if (request2!=null){
										if(request2.readyState==4){										
											var newtotal=request2.responseText;									
											//alert(newtotal);
											document.getElementById(div_id).innerHTML=newtotal;	
											PlaceBallon(msjID,div_id);																		
										}
									}
								}
	request2.send(null);	
}
// END ---> SHOW BALOON WITH USER BASIC INFORMATION --------------------------------------------------------------------------------------------
