function BoxShift() {
    // controlling the containers
    // requires jquery (obviously)
    var self = this;
    
    // about, location, home, menu, specialss, media
    this.curr_view = "home";
    var curr = $('#home');
    
    var siteOrder = new Array("about", "location", "home", "menu", "specials", "media");
    
    var currLocNum = 2; 	// since we're starting off at home
    
    var shifting = new Boolean(false);    
	    
    this.show = function() {
        
        $(curr).stop(true, true).animate({ opacity: 1 }, 800, function() {
            curr.appendTo('#focus');
        });

    }


    this.openAccordianByID = function (id) {
       
        if ($(id + ' .innerBox').is(":hidden")) {
            //show the selected submenu

            $(id + ' .innerBox').slideDown('slow', function () {
                // change text to show closed

                $(id + ' .openClosePrompt').text("click to close");
                $(id + ' .openClosePrompt').addClass("closeAccordian");
                $('html,body').animate({ scrollTop: $(id).offset().top - 150 }, 500);
                return false;
            });
        } else if ($(id).hasClass('menu')) {

            if ($(id).find('div.innerBox').length == 0 || id == '#menuCalculator') {
                $(id).trigger('click');
                $('html,body').animate({ scrollTop: $(id).offset().top - 150 }, 500);

            }


        }
    }
   


    this.scrollShift = function (id) {
       
        if ($(id).length) {
            // this gets passed an ID with the # symbol
            
            $('html,body').animate({ scrollTop: $(p_scrollSection).offset().top - 150 }, 400, function () {

                if ($(id + ' .innerBox').is(":hidden")) {
                    //show the selected submenu
                    $(id + ' .innerBox').slideDown('slow', function () {
                        /*var currentPage = $('#focus:nth-child(2)').attr('id');
                        window.location.hash = '/' + currentPage + '/' + id.replace("#", "");*/
                        // change text to show closed
                        $(id + ' .openClosePrompt').text("click to close");
                        $(id + ' .openClosePrompt').addClass("closeAccordian");
                        $('html,body').delay(500).animate({ scrollTop: $(id).offset().top - 150 }, 500);
                        return false;
                    });
                }
            });
        }
    }

    this.scrollSection = function (p_scrollSection) {

        // If there actually is a section of the given id...
        if ($(p_scrollSection).length) {
            wasInnerSection = true;
            // this gets passed an ID with the # symbol
            
            $('html,body').animate({ scrollTop: $(p_scrollSection).offset().top - 150 }, 500, function () { self.openAccordianByID(p_scrollSection); });
            /* openAccordianByID(p_scrollSection); */
        }
    }

   
    this.old_shift = function (p_dir, p_steps, p_scrollSection) {

        var next_view;
        var pixel_shift;
        var mini_shift


        scrollUp();
        scroll_enabled = false;
        
        if (p_dir == 'left') {
            next_view = view_handler(self.curr_view, 'left', p_steps);
            pixel_shift = '+=' + (920 * p_steps);
            mini_shift = '+=' + (50 * p_steps);
        }

        if (p_dir == 'right') {
            next_view = view_handler(self.curr_view, 'right', p_steps);
            pixel_shift = '-=' + (920 * p_steps);
            mini_shift = '-=' + (50 * p_steps);
        }

        

        /* determine if crossing the abnormally long "restaurant viewer */
        var i = 0;
        var crosses_location = false;
        for (i = 1; i < p_steps; i++) {
            if (p_dir == 'left') {
                if (view_handler(self.curr_view, 'left', i).string === "location") {
                    crosses_location = true;
                }

            }

            if (p_dir == 'right') {
                if (view_handler(self.curr_view, 'right', i).string === "location") {
                    crosses_location = true;
                }

            }
        }
        /* determin if left "denny's finder" */
        var left_location = false;
        if (self.curr_view === "location") { left_location = true; }
        /* determin if arrived at "denny's finder */
        var arrive_location = false;
        if (next_view.string === "location") { arrive_location = true; }


        /* calculate shift for navigation bar (navigation_bar) */
        if (p_dir == 'left') {
            var p_dist = 126 * p_steps;
            if (crosses_location) { p_dist += 140; }
            bar_shift = '-=' + p_dist;
        }

        if (p_dir == 'right') {
            var p_dist = 126 * p_steps;
            if (crosses_location) { p_dist += 140; }
            bar_shift = '+=' + p_dist;
        }


        if (next_view.string != self.curr_view) {

            var j = $(curr).queue("fx");
            var r = $(next_view.obj).queue("fx");
            var n = $('#wide_container').queue("fx");
            try {
                var total_queue = j.length + r.length + n.length;
            } catch (err) {
                var total_queue = 0;
            }

            // is there anything in the fx queue?
            if (total_queue == 0 && shifting == false) {

                shifting = true;

                // version 2.0 rewrite
                $('html, body').animate({ scrollTop: 0 }, 500);
                $(curr).animate({ opacity: 0.50 }, 800, function () {
                    $(this).appendTo('#wide_container');

                    $('#dynamic_background').animate({ left: mini_shift }, 700);
                    $('#dynamic_header_background').animate({ left: mini_shift }, 700);
                    $('#dynamic_footer_background').animate({ left: mini_shift }, 700);
                    $('#navigation_bar').animate({ left: bar_shift }, 700);
                    $('#wide_container').animate({ left: pixel_shift }, 700, function () {
                        /* shift width of content*/
                        if (left_location && (p_dir == 'left')) {
                            $('#navigation_bar').animate({ width: 126 }, 500);
                        }
                        else if (left_location && (p_dir == 'right')) {
                            $('#navigation_bar').animate({ width: 126, left: '+=140' }, 500);
                        }
                        else if (arrive_location && (p_dir == 'right')) {
                            $('#navigation_bar').animate({ width: 266 }, 500);
                        }
                        else if (arrive_location && (p_dir == 'left')) {
                            $('#navigation_bar').animate({ width: 266, left: '-=140' }, 500);
                        }
                        $(next_view.obj).delay(100).animate({ opacity: 1 }, 500, function () {
                            $(this).appendTo('#focus');

                            self.curr_view = next_view.string;
                            curr = next_view.obj;
                            currLocNum = siteOrder.findIndex(self.curr_view);

                            // track a spotlight analytics event for the page view
                            var spotlight = new Spotlight();
                            spotlight.track(self.curr_view);

                            // If the passed url is for the about or menu sections, and has a second 
                            // parameter, don't reset the location bar url.
                            // if (-1 != window.location.hash.indexOf('about/')) {
                            //     showModalContent(window.location.hash.substr(8), '/about');
                            // }

                            if (-1 != window.location.hash.indexOf('menu/')) {

                                showMenuContent(window.location.hash.substr(7));
                            }

                            //if the url has a second parameter use it
                            if (p_scrollSection != null) {
                                window.location.hash = '/' + self.curr_view + '/' + p_scrollSection.replace("#", "");
                            } else {
                                window.location.hash = '/' + self.curr_view;
                            }

                            // everything is done, we can animate again if we want
                            shifting = false;

                            // do we then want to scroll down to a specific section?
                            if (p_scrollSection != null) {

                                p_scrollSection = p_scrollSection.indexOf('#') == -1 ? '#' + p_scrollSection : p_scrollSection;
                                self.scrollSection(p_scrollSection);
                            }

                            // make any change to the map iframe so that it shows again in IE - this is really wierd.
                            $('#iframeMap').css('this_attribute', 'fixes_everything_in_ie');

                        });

                    });

                    // Make the current navigation item 'active'
                    $('#navMenu .active, #mainFootLinks .active').removeClass('active');

                    // Track a google analytics pageview
                    _gaq.push(['_trackPageview', '/#/' + next_view.string]);

                    switch (next_view.string) {
                        case 'about':
                            $('#aboutClick, #mainFootLinks .about').addClass('active');
                            break;

                        case 'location':
                            $('#locationClick, #mainFootLinks .restaurant').addClass('active');
                            break;

                        case 'home':
                            $('#homeClick,  #mainFootLinks .home').addClass('active');
                            break;

                        case 'menu':
                            $('#menuClick, #mainFootLinks .menu').addClass('active');
                            break;

                        case 'specials':
                            $('#specialsClick,  #mainFootLinks .specials').addClass('active');
                            break;
                        case 'media':
                            $('#mediaClick,  #mainFootLinks .media').addClass('active');
                            break;
                    }
                });

            } // end total_queue
        }

        scroll_enabled = true;

    }

    this.shift = function (p_dir, p_steps, p_scrollSection) {

        var next_view;
        var pixel_shift;
        var mini_shift


        scrollUp();
        scroll_enabled = false;


        if (p_dir == 'left') {
            next_view = view_handler(self.curr_view, 'left', p_steps);
            pixel_shift = '+=' + (920 * p_steps);
            mini_shift = '+=' + (50 * p_steps);
        }

        if (p_dir == 'right') {
            next_view = view_handler(self.curr_view, 'right', p_steps);
            pixel_shift = '-=' + (920 * p_steps);
            mini_shift = '-=' + (50 * p_steps);
        }


        /* determine if crossing the abnormally long "restaurant viewer */
        var i = 0;
        var crosses_location = false;
        for (i = 1; i < p_steps; i++) {
            if (p_dir == 'left') {
                if (view_handler(self.curr_view, 'left', i).string === "location") {
                    crosses_location = true;
                }

            }

            if (p_dir == 'right') {
                if (view_handler(self.curr_view, 'right', i).string === "location") {
                    crosses_location = true;
                }

            }
        }
        /* determin if left "denny's finder" */
        var left_location = false;
        if (self.curr_view === "location") { left_location = true; }
        /* determin if arrived at "denny's finder */
        var arrive_location = false;
        if (next_view.string === "location") { arrive_location = true; }


        var currLi = $('#navMenu li.active');
        var nextLi = $('#navMenu #' + next_view.string + 'Click');


        /* calculate shift for navigation bar (navigation_bar) */
        /*
        if (p_dir == 'left') {
            //var p_dist = 126 * p_steps;
            //if (crosses_location) { p_dist += 140; }
            p_dist = $('#navigation_bar').position().left - nextLi.position().left;
            bar_shift = '-=' + p_dist;
        }

        if (p_dir == 'right') {
            //var p_dist = 126 * p_steps;
            //if (crosses_location) { p_dist += 140; }
            p_dist = nextLi.position().left - $('#navigation_bar').position().left;
            bar_shift = '+=' + p_dist;
        }*/

        p_dist = nextLi.position().left;
        bar_shift = p_dist;
        bar_width = nextLi.css('width');


        if (next_view.string != self.curr_view) {

            var j = $(curr).queue("fx");
            var r = $(next_view.obj).queue("fx");
            var n = $('#wide_container').queue("fx");
            try {
                var total_queue = j.length + r.length + n.length;
            } catch (err) {
                var total_queue = 0;
            }

            // is there anything in the fx queue?
            if (total_queue == 0 && shifting == false) {

                shifting = true;

                // version 2.0 rewrite
                $('html, body').animate({ scrollTop: 0 }, 500);
                $(curr).animate({ opacity: 0.50 }, 800, function () {
                    $(this).appendTo('#wide_container');

                    $('#dynamic_background').animate({ left: mini_shift }, 700);
                    $('#dynamic_header_background').animate({ left: mini_shift }, 700);
                    $('#dynamic_footer_background').animate({ left: mini_shift }, 700);
                    $('#navigation_bar').animate({ left: bar_shift }, 700);
                    $('#wide_container').animate({ left: pixel_shift }, 700, function () {
                        /* shift width of content*/
                        /*
                        if (left_location && (p_dir == 'left')) {
                            $('#navigation_bar').animate({ width: 126 }, 500);
                        }
                        else if (left_location && (p_dir == 'right')) {
                            $('#navigation_bar').animate({ width: 126, left: '+=140' }, 500);
                        }
                        else if (arrive_location && (p_dir == 'right')) {
                            $('#navigation_bar').animate({ width: 266 }, 500);
                        }
                        else if (arrive_location && (p_dir == 'left')) {
                            $('#navigation_bar').animate({ width: 266, left: '-=140' }, 500);
                        }
                        */
                        $('#navigation_bar').animate({ width: bar_width }, 500);

                        $(next_view.obj).delay(100).animate({ opacity: 1 }, 500, function () {
                            $(this).appendTo('#focus');

                            self.curr_view = next_view.string;
                            curr = next_view.obj;
                            currLocNum = siteOrder.findIndex(self.curr_view);

                            // track a spotlight analytics event for the page view
                            var spotlight = new Spotlight();
                            spotlight.track(self.curr_view);

                            // If the passed url is for the about or menu sections, and has a second 
                            // parameter, don't reset the location bar url.
                            // if (-1 != window.location.hash.indexOf('about/')) {
                            //     showModalContent(window.location.hash.substr(8), '/about');
                            // }

                            if (-1 != window.location.hash.indexOf('menu/')) {

                                showMenuContent(window.location.hash.substr(7));
                            }

                            //if the url has a second parameter use it
                            if (p_scrollSection != null) {
                                window.location.hash = '/' + self.curr_view + '/' + p_scrollSection.replace("#", "");
                            } else {
                                window.location.hash = '/' + self.curr_view;
                            }

                            // everything is done, we can animate again if we want
                            shifting = false;

                            // do we then want to scroll down to a specific section?
                            if (p_scrollSection != null) {

                                p_scrollSection = p_scrollSection.indexOf('#') == -1 ? '#' + p_scrollSection : p_scrollSection;
                                self.scrollSection(p_scrollSection);
                            }

                            // make any change to the map iframe so that it shows again in IE - this is really wierd.
                            $('#iframeMap').css('this_attribute', 'fixes_everything_in_ie');

                        });

                    });

                    // Make the current navigation item 'active'
                    $('#navMenu .active, #mainFootLinks .active').removeClass('active');

                    // Track a google analytics pageview
                    _gaq.push(['_trackPageview', '/#/' + next_view.string]);

                    switch (next_view.string) {
                        case 'about':
                            $('#aboutClick, #mainFootLinks .about').addClass('active');
                            break;

                        case 'location':
                            $('#locationClick, #mainFootLinks .restaurant').addClass('active');
                            break;

                        case 'home':
                            $('#homeClick,  #mainFootLinks .home').addClass('active');
                            break;

                        case 'menu':
                            $('#menuClick, #mainFootLinks .menu').addClass('active');
                            break;

                        case 'specials':
                            $('#specialsClick,  #mainFootLinks .specials').addClass('active');
                            break;
                        case 'media':
                            $('#mediaClick,  #mainFootLinks .media').addClass('active');
                            break;
                    }
                });

            } // end total_queue
        }

        scroll_enabled = true;

    }

    
    view_handler = function(p_view, p_shift, p_steps) {
        // p_view is the current view
        // send this function which way it is shifting (ex. p_shift == 'left')
        // and it will return what the new view will be (ex. menu)
		
        var new_view;
        var new_html;
        
		if(p_shift == 'right') {
		    // check to see if we'll be off the edge
		    if((siteOrder.findIndex(p_view) + p_steps) >= siteOrder.length) {
		        new_view = p_view;
		    } else {
			    new_view = siteOrder[siteOrder.findIndex(p_view) + p_steps];
			}
		}
		
		if(p_shift == 'left') {	        
	        // check to see if we'll be off the edge
		    if((siteOrder.findIndex(p_view) - p_steps) < 0) {
		        new_view = p_view;
		    } else {
			    new_view = siteOrder[siteOrder.findIndex(p_view) - p_steps];
			}
		}
        

        // When a box gets shifted, stop all of the sliders. Don't worry, they get started again
        // below once we figure out what page we're going to.
        if(typeof(homeSlider) === 'object') {
            homeSlider.stop();
        }
        
        if(typeof(menuPromoSliderObj)  === 'object'){
            menuPromoSliderObj.stop();    
        }
        
        if(typeof(dumbSliderObj) === 'object'){
            dumbSliderObj.stop();
        }
        
        $('#clickBlockRight').css('display', 'block');
        $('#clickBlockLeft').css('display', 'block');
		

        switch(new_view) {
            
            case 'home':
                // We only start this home page slider because it gets loaded by when the site loads
                homeSlider.start();
                new_html = $('#home');
                break;
                
            case 'location':
                new_html = $('#location');
                break;
                
            case 'menu':
                new_html = $('#menu');

                // Load/start the slider when the page is navigated to
                if(typeof(menuPromoSliderObj) === 'undefined') {
                    menuPromoSliderObj = new MakeSlider('menuPromoSlider');
                } else {
                    menuPromoSliderObj.start();    
                }
                break;
                
            case 'about':
                new_html = $('#about');
                $('#clickBlockLeft').fadeOut(500, function() {
                    $('#clickBlockLeft').css('display', 'none');
                });
                
                break;
                
            case 'specials':
                new_html = $('#specials');
                
                // Load/start the slider when the page is navigated to
                if(typeof(dumbSliderObj) === 'undefined') {
                    dumbSliderObj = new MakeSlider('dumbSlider');
                } else {
                    dumbSliderObj.start();
                }
                break;
			case 'media':
                new_html = $('#media');
                $('#clickBlockRight').fadeOut(500, function() {
                    $('#clickBlockRight').css('display', 'none');
                });
                
                // Load/start the slider when the page is navigated to
                break;
        }
        
        return { 'string': new_view, 'obj': new_html };
        
    }
    
    this.jump_calc = function(p_section) {

    	// p_section is the name of the section we want to go to,
    	// this will calculate how many jumps we need to go in, and what direction
    	var direction = 'none';
    	
    	new_section_pos = siteOrder.findIndex(p_section);
    	num_steps = new_section_pos - currLocNum;
    	
    	if(num_steps > 0) {
    		direction = 'right';
    		num_steps = Math.abs(num_steps);
    	} else {
    		direction = 'left';
    		num_steps = Math.abs(num_steps);
    	}
    	
    	return { 'dir': direction, 'steps': num_steps };
    }    
    
}
