
var BubbleDiv = Class.create() ;

BubbleDiv.prototype = {
	
	// Init
	
	initialize: function( id , style , picdir ) {	

		// Parameter

		this.BubbleID  = id ;
		this.BubbleTYP = style ;
		this.BubblePIC = picdir ;
		
		// Link style & mouseover

		var BubbleLinks = $('BubbleMain' + this.BubbleID).getElementsBySelector('A') ;
		for( var no=0 ; no < BubbleLinks.length ; no++ ) {
			
			var posleft   = BubbleLinks[no].offsetLeft ;
			var postop    = BubbleLinks[no].offsetTop ;
			var posheight = BubbleLinks[no].getHeight() ;
			var posrel    = BubbleLinks[no].rel ;
			
			BubbleLinks[no].observe('mouseover', this.linkBubbleShow.bind(this,no,posleft,posheight,postop,posrel) ) ; 
			BubbleLinks[no].observe('mouseout', this.linkBubbleHide.bind(this,no) ) ; 
		}
		
		// Bubble erstellen
		
    	this.bdiv = new Element('div' , { 'id':'bDIV' + this.BubbleID , 'class':'bubbleDIV' + this.BubbleID , 'style':'display:none' } ) ;
    	this.bpad = new Element('div' , { 'id':'bPAD' + this.BubbleID , 'class':'bubblePAD' + this.BubbleID } ) ;
    	this.bimg = new Element('img' , { 'id':'bIMG' + this.BubbleID , 'class':'bubbleIMG' + this.BubbleID } ) ;
    	this.brel = new Element('div' , { 'id':'bREL' + this.BubbleID , 'class':'bubbleREL' + this.BubbleID } ) ;
    	
    	$$('body')[0].insert(this.bdiv) ;
    	this.bdiv.insert(this.bpad) ;
	
	} ,		


	// Mouseover start
	
	linkBubbleShow: function (linkid,linkleft,linkheight,linktop,linkrel) {

		// Bubble : Show

		this.bdiv.show() ;	
		
		// Bubble : Calc Position
		
		var linkleftout = linkleft + 10 ;
		var linktopout  = linktop - this.bdiv.getHeight() - 1 ;
		
		if ( linktopout <= 0 ) {
			
			linktopout = linktop + linkheight + 5 ; 
		}
		
		// Bubble : Set Position
		
		this.bdiv.style.left = linkleftout  + 'px' ;
		this.bdiv.style.top  = linktopout + 'px' ;

		// Style : Pic

		if ( this.BubbleTYP == 2 || this.BubbleTYP == 3 ) {
			
			this.bpad.insert(this.bimg) ;
			var picname = ( linkid + 1 ) + '.jpg' ;
			this.bimg.src = this.BubblePIC + picname ;
		}
				
		// Style : Text
				
		if ( this.BubbleTYP == 1 || this.BubbleTYP == 3 ) {
		
			this.bpad.insert(this.brel) ;
			this.brel.update(linkrel) ;
		}
		
	} ,
	
	
	// Mouseout stop
	
	linkBubbleHide: function () {

		this.bdiv.hide() ;

	} 
}

