var AMO = AMO || {};


AMO.Home = {

 init : function() {

  var $home_box_content = $("#home-box-content"),
      $tab_lis          = $('#home-box-links li'),
      $scroll_boxes     = $('.scroll'),
      first_onload      = true;
  
  // hashchange function to scroll through menu options
  $(window).bind( 'hashchange', function(e) {

    var hash    = $.param.fragment(),
        $tab    = false,
        $tab_li = false,
        valids  = ['online','mobile','ipad','paper'],
        order   = 1;

    if ( !hash || $.inArray( hash, valids ) === -1 ) {
      hash = 'online';
    }
    
    $tab    = $('#tab-' + hash );
    
    order   = parseInt( $tab.attr('order'), 10 );
    $tab_li = $tab.closest('li');
    
    $tab_lis.removeClass('active-home-link');
    $tab_li.addClass('active-home-link');

    if( first_onload ) {
      $scroll_boxes.filter(':visible').hide();
      $('#scroll-' + hash ).show();
      first_onload = false;
    }
    else {
      $scroll_boxes.filter(':visible').fadeOut('fast');
      $('#scroll-' + hash ).fadeIn('fast');
    }
    
  }); // init
  
  $(window).trigger('hashchange'); // hashchange changes menu option selected
  
}};



$(document).ready(function() {

  AMO.Home.init();
  
})
