if(typeof(FanboxUtil)=='undefined')
FanboxUtil={};
FanboxUtil.HoverDiv=function(){}
FanboxUtil.HoverDiv.TEST=false;
FanboxUtil.HoverDiv.USESFD=false;
FanboxUtil.HoverDiv.PositionRule={
WONSidebar:0,
SA:1}
FanboxUtil.HoverDiv.ResizeDisplayPic=function(pic){
pic.style.display="block";
if(pic.height>pic.width){
pic.style.height="100%";
document.getElementById("sfd_img_container").style.width="auto";}
else{
pic.style.width="100%";
document.getElementById("sfd_img_container").style.height="auto";}
document.getElementById("sfd_lside").style.height=(document.getElementById("sfd_inner_content").clientHeight+2)+'px';
document.getElementById("sfd_rside").style.height=(document.getElementById("sfd_inner_content").clientHeight+2)+'px';
document.getElementById("sfdbar").style.height=(document.getElementById("sfdbar").parentNode.clientHeight)+'px';
FanboxUtil.HoverDivManager._setPosition();}
FanboxUtil.HoverDiv.ShowProfile=function(userID){
var mdIFrame=document.createElement('iframe');
mdIFrame.src='http://www.fanbox.com/socnet/LaunchPublicProfile.html?userID='+userID;
mdIFrame.style.display='none';
var container=document.body;
container.appendChild(mdIFrame);}
FanboxUtil.HoverDiv.prototype={
DelayShow:function(ele,memberId,rule){
clearTimeout(this._createInterval);
clearTimeout(this._destroyInterval);
var me=this;
this._createInterval=setTimeout(function(){me.Show(ele,memberId,rule);},500);},
Show:function(ele,memberId,rule){
if(FanboxUtil.HoverDiv.USESFD){
this.Destroy();
this._setCoords(ele,rule);
if(FanboxUtil.HoverDiv.TEST){
this.Render("<div style='background-color:#FFF; width:100px; height:100px;'>Hello World!</div>");
return;}
new Ajax.Request('http://profile.fanbox.com/StandardUtils/FriendsHoverDiv.ashx?memberId='+memberId,{onSuccess:function(reply){FanboxUtil.HoverDivManager.Render(reply.responseText);}});}},
Render:function(html){
if(this._mydiv==null){
this._mydiv=document.createElement('DIV');
this._mydiv.id='CommonFriendsHoverDiv';
this._mydiv.style.position='absolute';
this._mydiv.style.display='none';
this._mydiv.style.zIndex='9999';
this._mydiv.style.width='auto';
this._mydiv.style.height='auto';
var me=this;
this._mydiv.onmouseover=function(){me._pauseDestroy();};
this._mydiv.onmouseout=function(){me.DelayDestroy();};
document.body.appendChild(this._mydiv);}
this._mydiv.innerHTML=html;
this._mydiv.style.display='';
this._setPosition();},
DelayDestroy:function(){
var me=this;
clearTimeout(this._createInterval);
this._destroyInterval=setTimeout(function(){me.Destroy();},2000);},
Destroy:function(){
if(FanboxUtil.HoverDiv.USESFD){
if(this._mydiv)
this._mydiv.style.display='none';
clearTimeout(this._createInterval);
clearTimeout(this._destroyInterval);}},
_setPosition:function(){
if(this._coords==null)
return;
if(this._coords[0]!=null)
this._mydiv.style.top=this._coords[0]+'px';
if(this._coords[1]!=null)
this._mydiv.style.left=this._coords[1]+'px';
if(this._coords[2]!=null)
this._mydiv.style.top=(this._coords[2]-this._mydiv.offsetHeight)+'px';
if(this._coords[3]!=null)
this._mydiv.style.left=(this._coords[3]-this._mydiv.offsetWidth)+'px';},
_pauseDestroy:function(){
clearTimeout(this._destroyInterval);},
_setCoords:function(ele,rule){
if(rule==FanboxUtil.HoverDiv.PositionRule.WONSidebar){
var arr=Position.cumulativeOffset(ele);
if(Position.page(ele)[1]<=240)
this._coords=[arr[1]+30,arr[0],null,null];
else
this._coords=[null,arr[0],arr[1]-5,null];}
else{
var arr=Position.cumulativeOffset(ele);
var arr2=Position.page(ele);
if(arr2[1]<=240){
if(arr2[0]>=610)
this._coords=[arr[1]+ele.height+5,null,null,arr[0]+ele.width];
else
this._coords=[arr[1]+ele.height+5,arr[0],null,null];}
else{
if(arr2[0]>=610)
this._coords=[null,null,arr[1]-5,arr[0]+ele.width];
else
this._coords=[null,arr[0],arr[1]-5,null];}}},
_createInterval:null,
_destroyInterval:null,
_mydiv:null,
_coords:null}
FanboxUtil.HoverDivManager=new FanboxUtil.HoverDiv();
