function mainReady() {
    
    // the essentials

    spotlight = new Spotlight();
    var mainNav = new MainNav();
    boxShift = new BoxShift();


    // This is for stopping the back button from firing when we go to an inner section
    wasInnerSection = false;

    boxShift.show();

    var sectionLoader = new SectionLoader(boxShift);
    sectionLoader.init();
    sectionLoader.loadAll();


    // Enable the browser's back + forward button.
    $(window).hashchange( function(){
        if(wasInnerSection != true) {
            var newLocation = location.hash;
            var boxLocation = '#/' + boxShift.curr_view;

            if(boxLocation != newLocation) {
                if(newLocation.substr(2) == ''){
                    var jump = boxShift.jump_calc('home');
                    boxShift.shift(jump.dir, jump.steps);           
                    return;            
                }

                var jump = boxShift.jump_calc(newLocation.substr(2));
                boxShift.shift(jump.dir, jump.steps);
            }            
        }
        else {
            wasInnerSection = false;
        }
    });


    $(document).keydown(function(e){
       // if the left arrow key is pressed
       if(e.keyCode == 37) {
           boxShift.shift('left', 1);
       }

       // if the right arrow key is pressed
       if(e.keyCode == 39) {
           boxShift.shift('right', 1);
       }
    });
    
    $('#clickBlockLeft').mouseover(function() {
        $('#pageLeftArrow').stop(true,true).fadeIn('slow');
    });
    
    $('#clickBlockLeft').mouseout(function() {
        $('#pageLeftArrow').stop(true,true).delay(100).fadeOut('slow');
    });
    
    $('#clickBlockRight').mouseover(function() {
        $('#pageRightArrow').stop(true,true).fadeIn('slow');
    });
    
    $('#clickBlockRight').mouseout(function() {
        $('#pageRightArrow').stop(true,true).delay(100).fadeOut('slow');
    });
    
    $('#pageLeftArrow').click(function() {
        boxShift.shift('left', 1);
        return false;
    });
    
    $('#pageRightArrow').click(function() {
        boxShift.shift('right', 1);
        return false;
    });

    $('#clickBlockLeft').click(function(){
      boxShift.shift('left', 1);
    });

    $('#clickBlockRight').click(function(){
      boxShift.shift('right', 1);
    });   


    // Make homepage zip input work with the iframed map
    $('#homeEnterZip').submit(function(){
        var jump = boxShift.jump_calc("location");
        boxShift.shift(jump.dir, jump.steps);

        window.frames['iframeMap'].location = 'http://hosted.where2getit.com/dennys/index-new.html?form=locator_search&Go=search&addressline=' + $(this).find('input[type=text]').val();
        $('#iframeMap').attr('src', 'http://hosted.where2getit.com/dennys/index-new.html?form=locator_search&Go=search&addressline=' + $(this).find('input[type=text]').val());

        return false;
    });

}

