jQuery(function() {
  // Init categories list
  var catListRootObject = jQuery('#dropdown-menu');
  var catListModel = new OMVC.CatListModel();
  var catListView = new OMVC.CatListView(catListModel, catListRootObject);
  var catListController = new OMVC.CatListController(catListModel, catListView);

  var processHash = function() {
    var hash = document.location.hash.substr(1);
    var command = hash.substr(0, 1);
    var index =  parseInt(hash.substr(1));
    var rootObject = jQuery('#woolf-content').html('');
    if(rootObject.length == 0 && hash != '') {
      window.location = jQuery('a.dropdown').attr('href') + '#' + hash;
    }
    if (command === 'c' ) {               // Category view
      var shoeListModel = new OMVC.ShoeListModel();
      var shoeListView = new OMVC.ShoeListView(shoeListModel, rootObject);
      var shoeListController = new OMVC.ShoeListController(shoeListModel, shoeListView, index, 0);
      jQuery('.wrapper').attr('id', 'page-product-category');
    } else if (command === 's' ) {        // Season view
      var shoeListModel = new OMVC.ShoeListModel();
      var shoeListView = new OMVC.ShoeListView(shoeListModel, rootObject);
      var shoeListController = new OMVC.ShoeListController(shoeListModel, shoeListView, 0, index);
      jQuery('.wrapper').attr('id', 'page-product-category');
    } else if (command === 'p') {         // Product view
      var shoeModel = new OMVC.ShoeModel();
      var shoeView = new OMVC.ShoeView(shoeModel, rootObject);
      var shoeController = new OMVC.ShoeController(shoeModel, shoeView, index);
      jQuery('.wrapper').attr('id', 'page-product-detail');
    } else {                              // Filter view
      if(rootObject.length) {
        var shoeListModel = new OMVC.ShoeListModel();
        var shoeListView = new OMVC.ShoeListView(shoeListModel, rootObject);
        var shoeListController = new OMVC.ShoeListController(shoeListModel, shoeListView, 0, 0);
        jQuery('.wrapper').attr('id', 'page-product-list');
      }
    }
  };

  processHash();

  jQuery(window).bind('hashchange', processHash);

  var fpListModel = new OMVC.FPListModel();
  var fpListView = new OMVC.FPListView(fpListModel, jQuery('.main-foot .products-list'));
  var fpListController = new OMVC.FPListController(fpListModel, fpListView, [28, 33, 36, 38]);


});
