/**
 *
 * hoverBalloon v0.1a
 * (c) joggink
 * 
 */
 var m_x = '-9999';
 var m_y = '-9999';
 var BLNMM = null;
 hoverBalloon = function(){
 	var e = $$('balloon');
 	for(var n=0;n<e.length;n++){
 		new Balloon(e[n]);
 	}
 }
 
 Balloon = function(a){
 	this.link = a;
 	this.txt  = this.getText();
 	if (!this.txt){
 		if (this.link.title){
 			this.txt = this.setText();
 		}
 	}
 	if (this.txt){
	 	this.hideText();
	 	this._mouseover = this.link.onmouseover;
	 	this._mouseout  = this.link.onmouseout;
	 	this.link.onmouseover = bind(this, this.showBalloon);
	 	this.link.onmousemove = bind(this, this.setPos);
	 	this.link.onmouseout = bind(this, this.hideBalloon);
 	}
 }
 
 Balloon.prototype = {
 	 	
 	getText : function(){
 		
 		var c = this.link.childNodes;
 		var n = 0;
 		for (;n<c.length;n++){
 			if(/bText/.test(c[n].className)){
 				return c[n];
 				window.alert(c[n])
 			}
 		}
 		
 	},
 	
 	setText : function(){
 		
 		var s = document.createElement('span');
 		s.className = 'bText';
 		s.innerHTML = this.link.title;
 		this.link.removeAttribute('title');
 		document.body.appendChild(s);
 		return s;
 		
 	},
 	
 	hideText : function(){
 		
 		this.txt.style.display = 'none';
 		
 	},
 	
 	showBalloon : function(){
 		if (this._mouseover){
 			this._mouseover.call();
 		}
 		this.setPos();
 		this.txt.style.display = 'block';
 		document.onmousemove = tracePos;
 	},
 	
 	hideBalloon : function(){
 		if (this._mouseout){
 			this._mouseout.call();
 		}
 		this.txt.style.display = 'none'; 
 		document.mousemove = null;
 		m_x = '-9999';
 		m_y = '-9999';
 	},
 	
 	setPos : function(){
 		this.txt.style.position = 'absolute';
 		this.txt.style.left = m_x + 10 + 'px';
 		this.txt.style.top = m_y + 10 + 'px';
 		
 	}
 	
 }
 
 
function bind(el, func){
    return function() { func.call(el); }
}

 
 function getPos(o) {
	var curleft = curtop = 0;
	if (o.offsetParent) {
		curleft = o.offsetLeft
		curtop = o.offsetTop
		while (o = o.offsetParent) {
			curleft += o.offsetLeft
			curtop += o.offsetTop
		}
	}
	return [curleft,curtop];
 } 

 function tracePos(e){

    var e = e ? e : window.event;
    
    m_x = e.clientX || e.pageX;
    m_y = e.clientY || e.pageY;
    
    m_x += document.documentElement.scrollLeft;
    m_y += document.documentElement.scrollTop

 }
 
 // joink lib
 // getElementsByClassName
 function $$(c, p){
 	var f = [];
 	var e = [];
 	var r = new RegExp(c);
 	if (p){
	 	if (p.tagName){
	 		e = document.getElementsByTagName('a')
	 	}else if (p.parent){
	 		_$$($(p.parent), e);
	 	}else{
	 		_$$(document, e);
	 	}
 	}else{
 		_$$(document, e);
 	}
 	for (var n=0;n<e.length;n++){
 		if (r.test(e[n].className)){
 			f.push(e[n]);
 		}
 	}
 	if (f.length > 0){
 		return f;
 	}else{
 		return false;
 	}
 }
 
 // getChildNodes from o and push in array a
 function _$$(o, a){
 	if (typeof o == 'object'){
	 	var x = o.childNodes;
		for (var n=0;n<x.length;n++){
			a.push(x[n]);
			_$$(x[n], a);
	 	}
 	}
 } 