var dragLock=false;


function ShowProfilePic(userid,url)
{
	if(dragLock)
		return true;
	
	InitRollOver(userid+'<BR><img src = "'+url+'" >');
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function MoveProfilePic(e)
{
	var ie=document.all
	var ns6=document.getElementById && !document.all
	var offsetxpoint=550 //Customize x offset of tooltip
	var offsetypoint=70 //Customize y offset of tooltip
	
	e = Event(e);
	
//	var x = e.clientX + document.body.scrollLeft+20;
//	var y = e.clientY + document.body.scrollTop;
	
	if(Pic()){
	/*	if (x>document.body.scrollWidth-Pic().offsetWidth)
		{
			x=x-Pic().offsetWidth-40;
		}		
		
		Pic().style.top = y + 'px';
		Pic().style.left = x+'px';
	*/
	
		var curX=(ns6)?e.pageX : e.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : e.clientY+ietruebody().scrollTop;
	
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<Pic().offsetWidth)
		{
			//move the horizontal position of the menu to the left by it's width
			Pic().style.left=ie? ietruebody().scrollLeft+event.clientX-Pic().offsetWidth+"px" : window.pageXOffset+e.clientX-Pic().offsetWidth+"px"
		}
		else if (curX<leftedge)
		{
			Pic().style.left="5px"
		}
		else
		{
			//position the horizontal position of the menu where the mouse is positioned
			Pic().style.left=curX+offsetxpoint+"px";
		}

		//same concept with the vertical position
		if (bottomedge<Pic().offsetHeight)
		{
			Pic().style.top=ie? ietruebody().scrollTop+event.clientY-Pic().offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-Pic().offsetHeight-offsetypoint+"px";
		}
		else
		{
			Pic().style.top=curY+offsetypoint+"px"
		}		
	}
	
	if(Pic() && Frame())
	{
		if(Pic().style.display == "inline" || Pic().style.display=="block" || Pic().style.visibility == "visible")
		{
			Frame().style.top = Pic().style.top;//document.body.clientHeight/2 - (myDiv.offsetHeight/2);
			Frame().style.left = Pic().style.left;//document.body.clientWidth/2 - (myDiv.offsetWidth/2);
			Frame().style.width = Pic().offsetWidth+"px";
			Frame().style.height = Pic().offsetHeight+"px";
			Frame().style.display = "block";
		}
		else
		{
			Frame().style.display = "none";
		}
	}
}



function HideProfilePic()
{
	if(dragLock)
		return true;	
	
	if(!Pic())
		return;

	if(Frame())
		Frame().style.display = "none";
	DestroyDiv(Pic());
	
	
	document.onmousemove=MouseBuffer;
	MouseBuffer=null;
}
function Pic()
{
	return Get('divPic');
}
function Frame()
{
	return Get('divPicFrame');
}
function ShowBucketRollover(PodTypeName, PodLongName, e)
{
	if(dragLock)
		return true;
	
	if(!Pic())
		return false;
				
	InitRollOver('<table height=\'22\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\' class=\'bx_border\'><tr valign=\'middle\'><td height=\'20\' align=\'left\' class=\'p_text_color\'>&nbsp;' + PodTypeName + ': ' + PodLongName + '&nbsp;</td></tr></table>');
}
function HideBucketRollover()
{	
	HideProfilePic();
}
function ShowPic(url,userid,greetingtxt)
{
	if(dragLock)
		return true;
	
    if(!url)
		url = "";

	if(!userid)
		userid = "";

	if(!greetingtxt)
		greetingtxt = "";

	InitRollOver('<div style=\'BORDER-RIGHT: black thin solid;BORDER-TOP: black thin solid;BORDER-LEFT: black thin solid;BORDER-BOTTOM: black thin solid; \'><span class=\'p_text_md\'>' + userid+'</span> <img src = \''+url+'\' height=\'267\'><table width=\'400\' class=\'divMagnifytd\' border=0></table></div>');
}

function MovePic(e)
{
	MoveProfilePic(e);
}

function HidePic()
{				
	HideProfilePic();
}

function InitRollOver(html)
{
	Pic().style.visibility = 'visible';		
	Pic().innerHTML = html;	
	
	//if(Frame())
		//Frame().style.display = "inline"
	
	MouseBuffer=document.onmousemove;
	document.onmousemove=MoveProfilePic;
}
function ShowSMSRollover(SMSText, e)
{
	if(dragLock)
		return true;
	
	if(!Pic())
		return false;
				
	InitRollOver('<table height=\'22\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\' class=\'bx_border\'><tr valign=\'middle\'><td height=\'20\' align=\'left\' class=\'p_text_color\'><nobr>&nbsp;' + SMSText + '&nbsp;</nobr></td></tr></table>');
}

