$(document).ready(function() 
{
  document.getElementById("entiredocument").style.display = "block";
  document.getElementById("javascriptloaded").style.display = "none";

  //give all anchor tags class anchor so that you can attach a context menu
  $("a:not(.thumb):not(.trackTitle)").addClass("anchor");

  SimpleContextMenu.setup({'preventDefault':true, 'preventForms':false});
  SimpleContextMenu.attach('container', 'CM1');

  SimpleContextMenu.setup({'preventDefault':true, 'preventForms':false});
  SimpleContextMenu.attach('anchor', 'CMa');

  SimpleContextMenu.setup({'preventDefault':true, 'preventForms':false});
  SimpleContextMenu.attach('thumb', 'CMthumb');

  setInterval( "flicker()", 30000 );
  
  $("bodyX").keypress(function(e) 
  {
    alert(e.which); 
  });


  $(".thumb").fancybox({

    'overlayShow':true,
    'overlayOpacity':0.9,
    'centerOnScroll' :true
  });


  $(".trackTitle").fancybox({

    'overlayShow':true,
    'overlayOpacity':0.9,
    'centerOnScroll' :true
  });


  $(".allseeing").click(function () 
  {
    invert();
  });


  $(".clipboard").click(function () 
  {
    var msg = $(this).children("span:hidden").text();
    writeToClip(msg);
  });


  $(".calCopy").click(function () 
  {
    var elem = $(this).children("span:hidden");
    var msg = elem.text();
    alert("Copy the following:\n\n" + msg);
    writeToClip(msg);
  });

  $(".openNewTab").click(function()
  {
    var href = SimpleContextMenu._attachedElement.href;
    this.href = href;
  });

  $(".saveImg").click(function()
  {
    var elem = SimpleContextMenu._attachedElement;
    this.href = "/download.php?file=" + elem.href + ".save";
  });

});
