
var BubbleThis = Class.create() ;

BubbleThis.prototype = {
	
	// Init
	
	initialize: function( link , id , style , text , picdir ) {	

		// Parameter

		this.BubbleLNK = link ;
		this.BubbleID  = ( id > 0 ? id : 1 ) ;
		this.BubbleTYP = ( style > 0 ? style : 1 ) ;
		this.BubbleTXT = text ;
		this.BubblePIC = picdir ;
		
		// Bubble : Size

		this.posleft   = $(this.BubbleLNK).offsetLeft ;
		this.postop    = $(this.BubbleLNK).offsetTop ;
		this.posheight = $(this.BubbleLNK).style.height ;
		
		// Bubble : Set mouseout
		
		$(this.BubbleLNK).observe('mouseout', this.linkBubbleHide.bind(this,$(this.BubbleLNK)) ) ; 
				
		// Bubble : Make Div & Img
		
    	this.bdiv = new Element( 'div' , { 'id':'boneDIV' + this.BubbleID , 'class':'bubbleoneDIV' + this.BubbleID , 'style':'display:none' } ) ;
    	this.bimg = new Element( 'img' , { 'id':'boneIMG' + this.BubbleID , 'class':'bubbleoneIMG' + this.BubbleID } ) ;
    	
    	$$('body')[0].insert(this.bdiv) ;
    	
    	// Bubble : show
    	
    	this.linkBubbleShow($(this.BubbleLNK)) ; 
	
	} ,		


	// Mouseover : Show
	
	linkBubbleShow: function (linkid) {

		// Bubble : Show

		this.bdiv.show() ;	
		
		// Style : Pic

		if ( this.BubblePIC && ( this.BubbleTYP == 2 || this.BubbleTYP == 3 ) ) {
			
			this.bdiv.insert(this.bimg) ;
			this.bimg.src = this.BubblePIC ;
		}
				
		// Style : Text
				
		if ( this.BubbleTYP == 1 || this.BubbleTYP == 3 ) {
		
			this.bdiv.insert(this.BubbleTXT) ;
		}

		// Bubble : Calc Position

		var linkleftout = Element.positionedOffset(this.BubbleLNK).left + this.BubbleLNK.getWidth() + 10 ;
		var linktopout  = Element.positionedOffset(this.BubbleLNK).top - this.bdiv.getHeight() + 1 ;
		
		if ( linktopout <= 5 ) {
			
			linktopout = Element.positionedOffset(this.BubbleLNK).top + this.posheight + 5 ; 
		}
		
		// Bubble : Set Position
		this.bdiv.style.left = linkleftout  + 'px' ;
		this.bdiv.style.top  = linktopout + 'px' ;

	} ,
	
	
	// Mouseout : Hide
	
	linkBubbleHide: function (linkid) {

		this.bdiv.remove() ;

	} 
}
