var favourites = {
  nowshowing: 1,
  userid: null,
  
  show: function(type, page) {
    this.nowshowing = type;
    ajaxpost("/ajax/showuserfavourites", favourites.rh, [{name: "userid", value: this.userid}, {name: "type", value: type}, {name: "page", value: page}]);
  },

  rh: function(o) {
    if (o.xmlhttp.status == 200) {
      $j("#fcont").html(o.responseText);
      switch (favourites.nowshowing) {
        case 2: { $j(".favourites .title").html('favourite: <a href="#" onclick="favourites.show(1,1); return false;">songs</a> | <span>artists</span>'); break; }
        default: { $j(".favourites .title").html('favourite: <span>songs</span> | <a href="#" onclick="favourites.show(2,1); return false;">artists</a>'); break; };
      }
      favourites.init();
    }
  },
  
  init: function() {
    $j(".skip").focus(function() { this.value = ""; } );
    $j(".skip").blur(function() { this.value = "#"; } );
    $j(".skip").blur();
    $j(".favourites a").click( function() { this.blur() } );
  },
  
  kh: function(e, type) {
    e=e||window.event;
    var ch = e.which||e.keyCode;
    var el = e.target || e.srcElement;
    
    if (el && (ch == 13) && parseInt(el.value)) {
      try {
        favourites.show(type, parseInt(el.value));
      }
      catch (e) {
        // Swallow
      }
    }
  }
}

$j(document).ready(favourites.init);