function mainReady() {
    var self = this;
    // the essentials

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

    // 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();

    this.test = function () {
        console.log('test');
    }


    // 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
    $('#homeSubmitMap').click(function () {
        var jump = boxShift.jump_calc("location");
        boxShift.shift(jump.dir, jump.steps);

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

        return false;
    });
	
	// scroll enabled is controlled in boxshift
	$('#aboutClick ul, #locationClick ul, #homeClick ul, #menuClick ul, #specialsClick ul, #mediaClick ul').css('display','none').css('overflow','hidden');
	$('#aboutClick, #locationClick, #homeClick, #menuClick, #specialsClick, #mediaClick').hoverIntent(function() {
		//show its submenu
		//if( scroll_enabled) {
			$(this).addClass('drop');
			$('.drop ul').slideDown('slow').css('display', 'inline-block');
		//}
	}, function () {
		//hide its submenu
		//if( scroll_enabled) {
			$('.drop ul').slideUp("slow");
			$(this).removeClass('drop');
		//}
	});
}
