
$(document).ready(document_ready);

function document_ready()
{
    $(".item").each(
      function(){
        if(this.addEventListener){
          this.addEventListener("mouseover", handle_MOUSEOVER, false);
          this.addEventListener("mouseout", handle_MOUSEOUT, false);
          this.addEventListener("click", handle_CLICK, false);
        }else if(this.attachEvent){
          this.attachEvent("mouseover", handle_MOUSEOVER);
          this.attachEvent("mouseout", handle_MOUSEOUT);
          this.attachEvent("onclick", handle_CLICK);
        }
    });

    if(this.addEventListener){
      //loadGame();
    }
}

function handle_MOUSEOVER(event)
{
  $(this).find('.overlay').css('opacity', '.8');
}

function handle_MOUSEOUT(event)
{
  $(this).find('.overlay').css('opacity', '0');
}

function handle_CLICK(event)
{
  var target = event.target ? event.target : event.srcElement;

  if(target.getAttribute('rel')&&target.getAttribute('rel')!==""){
    window.open(target.getAttribute('rel'),'_newtab');
  }else if(target.attributes['name'].nodeValue!==""){
    window.open(target.attributes['name'].nodeValue);
  }
}

function loadGame ()
{
  $('#game').load("./rocketstar.html", handle_game_LOAD_COMPLETE);
}

function handle_game_LOAD_COMPLETE (event)
{
  var game = new RocketStarGame();
  game.init();
}

