HS = {
  highscores: function(url) {
    this.highscores_url = url;
    this.tab_html = '<a href="#" id="highscores_tab">highscores</a>';
    this.overlay_html = '<div id="highscores_overlay" style="display:none">' +
                          '<div id="highscores_container">' +
                            '<a href="#" onclick="HS.hide();return false" id="highscores_close"></a>' +
                            '<iframe src="" id="highscores_iframe" allowTransparency="true" scrolling="no" frameborder="0"></iframe>' +
                          '</div>' +
                          '<div id="highscores_screen"></div>' +
                        '</div>';
    document.write(this.tab_html);
    document.write(this.overlay_html);
    this.gId('highscores_tab').onclick = function() { HS.show(); return false; }
    this.gId('highscores_iframe').setAttribute("src", "");
  },
  set_position: function() {
    this.scroll_top = document.documentElement.scrollTop || document.body.scrollTop;
    
    this.scroll_height = document.documentElement.scrollHeight;
    this.client_height = window.innerHeight || document.documentElement.clientHeight;
    this.gId('highscores_screen').style.height = this.scroll_height+"px";
    this.gId('highscores_container').style.top = this.scroll_top+(this.client_height*0.1)+"px";

  },
  show: function() {
    if(this.gId('highscores_iframe').getAttribute("src") == "") {
      this.gId('highscores_iframe').setAttribute("src", this.highscores_url);
      if (this.gId('highscores_iframe').addEventListener) {
        this.gId('highscores_iframe').addEventListener("load", HS.loaded, false);
      } else if (this.gId('highscores_iframe').attachEvent) {
        this.gId('highscores_iframe').detachEvent("onload", HS.loaded);
        this.gId('highscores_iframe').attachEvent("onload", HS.loaded);
      }
    }
    
    this.set_position();
    this.gId('highscores_overlay').style.display = "block";
  },
  hide: function() {
    this.gId('highscores_overlay').style.display = "none";
  },
  loaded: function() {
    HS.gId('highscores_iframe').className = "loaded";
  },
  gId: function(id) {
    return document.getElementById(id);
  }
}