//================================================================================
// Glossary tooltips
//================================================================================

// MopTip is not loaded in print preview as there's no CSS styles for it
if ($.fn.mopTip)
{
  $(document).ready(function()
  {
    $(".tooltip").mopTip({
      w: 320,
      h: 140,
      style: "overOut", 
      get: function(element)
      {
        var id = $(element).attr("href");
        if (id)
        {
          // Link to an anchor (href="#id")
          return "<h3>" + $(id).html() + "</h3>\n" + $(id + " + dd").html();
        }
        else
        {
          // Other (e.g. <acronym>)
          return "<h3>" + $(element).html() + "</h3>\n" + $(element).attr("title");
        }
      }
    });
  });
}

//================================================================================
// nav images
//================================================================================

$(document).ready(
  function()
  {
    var images = ["images/nav/on/1.png", "images/nav/on/2.png", "images/nav/on/3.png", "images/nav/on/4.png", "images/nav/on/5.png", "images/nav/on/6.png", "images/nav/on/7.png"];
    for (i in images) {
      var image = new Image();
      image.src = images[i];
    }
  }
);

//================================================================================
// Anti-spam in forms
//================================================================================

$(document).ready(function()
{
  var field = $("#input-antispam");
  if (field)
  {
    field.val(unescape("Z6FZ72Z61Z6EZ67Z65".replace(/Z/g, "%")));
    $("#antispam-container").hide();
  }
});

//================================================================================
// Anti-spam for email addresses
//================================================================================

$(document).ready(function()
{
  $("span.email").each(function()
  {
    var email = $(this).text().replace(/ at /, "@");
    var html = '<a href="mailto:' + email + '">' + email + '</a>';
    $(this)
      .html(html)
      .removeClass("email");
  });
});

