function Bubble(targetObj){
	this.targetObj=targetObj;
	this.Obj;
	this.bubbleObj = false;
	this.txt = "";
}  

Bubble.prototype.invertVisibility = function(objectId, isVisible){
  if(this.Obj){
		this.ObjStyle.visibility = isVisible;
		return true;
  }
  else
		return false;
}

Bubble.prototype.moveObj = function(){
  if(this.Obj){
		this.ObjStyle.left = this.xCoordinate;
		this.ObjStyle.top = this.yCoordinate;
		return true;
  }
  else
		return false;
}

Bubble.prototype.editBubble = function(eventCoor, content, divId, xCoor, yCoor, mouseCoorX, mouseCoorY){
	this.hideBubble();
	this.set();

	if(divId)
		this.Obj = document.getElementById(divId);
	else
		this.Obj = document.getElementById('Bubble');
	this.bubbleObj = this.Obj;
	this.ObjStyle = this.bubbleObj.style;
	
	if(eventCoor && content){
		this.hideBubble();
		eventCoor.cancelBubble = true;
		var bubbleContent = (document.getElementById(content))? document.getElementById(content).innerHTML : content;
		this.Obj.innerHTML = this.balloon(bubbleContent);

		if((toolkit.getOffsetCoor(eventCoor)[toolkit.coor.Y]+eventCoor.offsetHeight+this.Obj.offsetHeight+yCoor) > document.body.clientHeight){
			
			this.yCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.Y]-this.Obj.offsetHeight+yCoor;
			if((toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]+this.Obj.offsetWidth+xCoor) > document.body.clientWidth){
				this.xCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]-this.Obj.offsetWidth+xCoor+15;
				this.cbr = "bubbr1";
				}
			else
				{
				this.xCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]+xCoor;
				this.cbl = "bubbl1";
				}
			}
		else
			{
			this.yCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.Y]+eventCoor.offsetHeight+yCoor;
			if((toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]+this.Obj.offsetWidth+xCoor) > document.body.clientWidth){
				this.xCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]-this.Obj.offsetWidth+xCoor+15;
				this.ctr = "bubtr1";
				}
			else
				{
				this.xCoordinate = toolkit.getOffsetCoor(eventCoor)[toolkit.coor.X]+8+xCoor;		
				this.ctl = "bubtl1";
				}
			}
		if (mouseCoorX){
			 this.xCoordinate = event.x+15;
			 this.set(); this.ctl = "bubtl1";
			}
		if (mouseCoorY){
			 this.yCoordinate = event.y+15;
			 this.set(); this.ctl = "bubtl1";
			}
		this.Obj.innerHTML = this.balloon(bubbleContent);
		
		this.moveObj(this.xCoordinate, this.yCoordinate);
		if (this.invertVisibility(this.targetObj,'visible')){
			this.bubbleObj = this.Obj;
			return true;
			}
			else
				return false;
	}
	else
		return false;  
}

Bubble.prototype.hideBubble = function(){      
	if(this.bubbleObj){
		this.invertVisibility(this.bubbleObj, 'hidden'); 
		this.bubbleObj = false;
		}
}
Bubble.prototype.balloon = function(content){
	str = '<table cellpadding="0" cellspacing="0" border="0">\n<tr>\n<td><img src="img/clear.gif" border="0" class="'+this.ctl+'"></td>\n<td class="bubtop">&nbsp;</td>\n<td><img src="img/clear.gif" border="0" class="'+this.ctr+'"></td>\n</tr>\n';
	str += '<tr>\n<td class="bubl">&nbsp;</td>\n';
	str += '<td id="bubblecontent" class="bubc">' + content + '</td>\n';
	str += '<td class="bubr">&nbsp;</td>\n</tr>\n';
	str += '<tr>\n<td><img src="img/clear.gif" border="0" class="'+this.cbl+'"></td>\n<td class="bubbottom">&nbsp;</td>\n<td><img src="img/clear.gif" border="0" class="'+this.cbr+'"></td>\n</tr>\n</table>';
	return(str);
}

Bubble.prototype.set = function(){this.ctl = "bubtl"; this.ctr = "bubtr"; this.cbl = "bubbl"; this.cbr = "bubbr";}