var InfoBox = new Class({
  initialize: function ()
  {
  },
  
  init: function()
  {
    
    var toolTipDivCont = new Element('div');
    var toolTipDiv = new Element('div',{
      'styles':{
        left:       '0',
        right:      '0',
        position:   'absolute',
        display:    'none'
      },
      'id': 'toolTip'
    });
    toolTipDivCont.appendChild( toolTipDiv );
    toolTipDivCont.inject($(document.body),"top");
    
    var imgs = $(document.body).getElements("img.icon");
    imgs.each( function ( img ) {
      if (img.title && img.title.length > 0) {
        img.infoBoxTitle = img.title;
        img.title = "";
        img.addEvent("mouseover", infoBox.show.bind(this,img));
        img.addEvent("mousemove", infoBox.move);
        img.addEvent("mouseout", infoBox.hide.bind(this,img));
      }
    });
  },
  
  move: function( e )
  {
    var event = new Event(e);
    var windowScroll = window.getScroll();
    var x = event.client.x;
    var y = event.client.y;
    $('toolTip').setStyle('left', ( x + 15 ) );
    $('toolTip').setStyle('top',  ( y + 15 )+windowScroll.y );
  },
  
  show: function( img )
  {
    $("toolTip").innerHTML = img.infoBoxTitle;
    $("toolTip").setStyle('display','block');
  },
  
  hide: function( img )
  {
    $("toolTip").setStyle('display','none');
  },

  handleInfo: function()
  {
    alert( 'hier' );
  }
});

var infoBox;
window.addEvent("domready", function () { infoBox = new InfoBox(); infoBox.init(); });
