(function($){

var ns = 'Navigator';

window[ns] = function () {
  this.root = $('#nav');  
  this.ajax_url = AJAX_BASE + "navigator";
  
  var filler = $('<div>').attr('id', 'filler');
  this.root.after(filler);
};

window[ns].prototype = {
  
  load: function () {
    this.root.load( this.ajax_url, $.proxy( this.done, this ) );
  },
  
  done: function () {
    /* categories */
    this.categories = this.root.find('.cat-button');

    /* portfolio */
    this.protfolio = $('#portfolio-link span');
    
    /* pages ( about & contact ) */
    this.pages = this.root.find('.page-button');
    
    
    site.loadComplete('navigator');
  },

  bind: function ( target, type, callback ) {
    if ( target == "category" ) {
      target = this.categories;
    } else if ( target == "portfolio" ) {
      target = this.protfolio;
    } else if ( target == "page" ) {
      target = this.pages;
    }
    
    target[type](callback);
  }
  
}

})(jQuery);
