// hide/show controls
    $('#hide_show_controls').toggle(
        function() {
            $(this).html('Show All Panels');
            com.hive.worldpop.layout.hideControls();
        },
        function() {
            $(this).html('Hide All Panels');
            com.hive.worldpop.layout.showControls();
        }
    );

// gallery title image swap
    var swipeFlag = false;
    var swipeGalleryTitle = function(s) {
        var y = s ? 50 : 0;
        var z = s ? 0 : 50;
        $('#gallery_title').css({backgroundPosition: '0px '+z+'px'}).stop().animate({backgroundPosition:'(0px '+y+'px)'},{duration:1000});
    };
    swipeGalleryTitle(true);
    window.setInterval(function() {
        swipeGalleryTitle(swipeFlag);
        swipeFlag = !swipeFlag;
    }, 10000);


/** Document initialization **/
$(document).ready(function() {
    /**
	$.preloadCssImages();
    com.hive.worldpop.services.preloadImages(
        //'images/world-map-background.jpg',
        //'images/color_sq_km.png'
    );
	**/
    $('.menu_item').hover(function() {
        var id = $(this).attr('id');
        $('.menu_item').removeClass('menu_item_selected');
        $(this).addClass('menu_item_selected');
        $('.menu_content').addClass('invisible');
        $('#'+id+'_content').removeClass('invisible');
    });
    $('#app_info').click(function() {
        var opts = 'scrollbars=yes,width=581,height=610';
        window.open('readaboutit/itunes.html', 'About The World Population Application', opts);
    });
});
