/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function() {
  $("body").append("<div id='ToolTipDiv'></div>");

  $("Input[em]").each(function() {
    $(this).hover(function(e) {
      $().mousemove(function(e) {
        var tipY = e.pageY - 30;
        var tipX = e.pageX + 20;
        $("#ToolTipDiv").css({'top': tipY, 'left': tipX});
      });
      $("#ToolTipDiv")
        .html($(this).attr('em'))
        .stop(true,true)
        .fadeIn("fast");
      $(this).removeAttr('em');
    }, function() {
      $("#ToolTipDiv")
        .stop(true,true)
        .fadeOut("fast");
      $(this).attr('em', $("#ToolTipDiv").html());
    });
  });

  $("Textarea[em]").each(function() {
    $(this).hover(function(e) {
      $().mousemove(function(e) {
        var tipY = e.pageY - 30;
        var tipX = e.pageX + 20;
        $("#ToolTipDiv").css({'top': tipY, 'left': tipX});
      });
      $("#ToolTipDiv")
        .html($(this).attr('em'))
        .stop(true,true)
        .fadeIn("fast");
      $(this).removeAttr('em');
    }, function() {
      $("#ToolTipDiv")
        .stop(true,true)
        .fadeOut("fast");
      $(this).attr('em', $("#ToolTipDiv").html());
    });
  });

  $("legend[em]").each(function() {
    $(this).hover(function(e) {
      $().mousemove(function(e) {
        var tipY = e.pageY - 30;
        var tipX = e.pageX + 20;
        $("#ToolTipDiv").css({'top': tipY, 'left': tipX});
      });
      $("#ToolTipDiv")
        .html($(this).attr('em'))
        .stop(true,true)
        .fadeIn("fast");
      $(this).removeAttr('em');
    }, function() {
      $("#ToolTipDiv")
        .stop(true,true)
        .fadeOut("fast");
      $(this).attr('em', $("#ToolTipDiv").html());
    });
  });

  $("a[em]").each(function() {
    $(this).hover(function(e) {
      $().mousemove(function(e) {
        var tipY = e.pageY - 30;
        var tipX = e.pageX + 20;
        $("#ToolTipDiv").css({'top': tipY, 'left': tipX});
      });
      $("#ToolTipDiv")
        .html($(this).attr('em'))
        .stop(true,true)
        .fadeIn("fast");
      $(this).removeAttr('em');
    }, function() {
      $("#ToolTipDiv")
        .stop(true,true)
        .fadeOut("fast");
      $(this).attr('em', $("#ToolTipDiv").html());
    });
  });

});