var timer;
var timed = true;
var flip = 0;

function assocTimerOff() { timed = false; }
function assocTimerOn() { timed = true; }
function assocTimerStart() { timer = setTimeout("hideAssociated()",3000); }
function hideAssociated() { if (timed) { $(".associated").slideUp('fast'); } }

$(document).ready(function() {
  $(".associated").css({'display':'block'}).hide();
  $(".eventBrowser a.browse, .eventBrowser a.toggle").mouseover(
    function() {
      var menu = $(this).attr("title");
      $(".associated").hide();
      $(".associated." + menu).show();
    });
  /* $(".eventBrowser").mouseout( function() { assocTimerStart(); } ); */
  $(".eventBrowser").hover(
    function() { assocTimerOn(); },
    function() { assocTimerStart(); }
  );
  $(".associated").hover(
    function() { assocTimerOff(); $(this).show(); },
    function() { assocTimerOn(); $(this).slideUp('fast'); }
  );

  $("a.errorBubble").hover(
    function() {
      $("div.errorBox").hide().removeClass("on");
      errorID = $(this).parent().attr("for");
      errorBox = $("div#" + errorID);
      errorBox.addClass("on").show();
    },
    function() { $("div.errorBox").hide().removeClass("on"); });

  $("a.errorButton").click(
    function() {
      errorID = $(this).parent().attr("for");
      errorRow = $("tr#" + errorID);
      if ($(this).hasClass("on")) {
        $(this).removeClass("on");
        errorRow.removeClass("on").addClass("off");
        if ($("a.errorButton.on").length == 0) {
          $("th span.all").removeClass("on");
        }
      } else {
        $("th span.all").addClass("on");
        $(this).addClass("on");
        errorRow.removeClass("off").addClass("on");
      }});
  $("a.allBubble").click(
    function() {
      if ($(this).hasClass("on")) {
        $("th span.all").removeClass("on");
        $(this).removeClass("on");
        $("a.errorButton").removeClass("on");
        $("tr.errorRow").removeClass("on").addClass("off");
      } else {
        $("th span.all").addClass("on");
        $(this).addClass("on");
        $("a.errorButton").addClass("on");
        $("tr.errorRow").removeClass("off").addClass("on");
      }
    });
});
