var currentimageheight = 150;
var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset

function BubbleDoit(e, ActionDoit, y_to_add)
{
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	document.getElementById(ActionDoit).style.visibility = 'visible';
    var e = e || window.event;
	//alert(ActionDoit)
	//find out if window has been scrolled
	var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
	
	// posx and posy contain the mouse position relative to the document

if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY ;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX+document.documentElement.scrollLeft;
		posy = e.clientY+document.documentElement.scrollTop;
	}

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	
	//if (docwidth - e.pageX < 300){	// Changed to try & remove bottom scrollbar
		if (docwidth - posx < 800 + scrOfX){
			xcoord = posx - xcoord - 300; // Move to the left side of the cursor
		} else {
			xcoord += posx;
		}
		if (docheight - posy < (currentimageheight + 50)){
			ycoord += posy - Math.max(0,(50 + currentimageheight + posy - docheight - truebody().scrollTop));
		} else {
			ycoord += posy;
		}

	document.getElementById(ActionDoit).style.left = xcoord + "px";
	document.getElementById(ActionDoit).style.top = ycoord + "px";







}

function HideBubble(ActionHide)
{
	var posx = 0;
	var posy = 0;
	document.getElementById(ActionHide).style.visibility = 'hidden';

}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}



