/*
The qnote plugin
© Teemu Alapoikela 2010
MIT License (http://jquery.org/license)
*/
(function($){
  $.fn.qnote = function(options) {
    
    var note = $(".qnote");
    if (note.size() == 0) note = $("<span></span>").appendTo(document.body).addClass("qnote").hide().css("position","absolute");
    
    return this.each(function(){
      
      $t = $(this);
      
      $t.bind('mouseover', function(e){
        showNote(e.pageX,e.pageY, $(this));
      }).bind('mouseout', function(){
        hideNote();
      });
      
      function showNote(x,y, elem) {
        var noteVal = elem.attr("rel");
        if (noteVal.length > 0) {
          note.html(noteVal);
          note.css({
            left: x+30,
            top: y+30
          }).delay(1000).show();
          
          $(document.body).bind('mousemove', function(e) {
            if (note.is(":visible")) {
              note.css({
                left: e.pageX+30,
                top: e.pageY+30
              });
            }
          });
        }
      };
      
      function hideNote() {
        note = $(".qnote");
        note.hide();
        $(document.body).unbind();
      }
      

      
      
    });
    
  };
})(jQuery);
