jQuery(document).ready(function($) {
    
    /* Airport Title
     * ------------- */
    
    $('#airport .change').airport([ 'welcome.to.the.site', 'how.are.you.today?' ]);
    
    /* Home Page Sliding Panel
     * ----------------------- */
    
    var page = 0;
    var height = 0;
    var grid_list = $('.grid_list');
    var result_pages = grid_list.find('.result_page');
    
    height = result_pages.eq(page).height();
    grid_list.css('height', height);
    
    $('a#next_page').click(function(e) {
        e.preventDefault();
        if (!$(this).hasClass('bottom')) {
            var next_height = result_pages.eq(page+1).height();
            height += next_height;
            grid_list.animate({
                'height': height
            });
            $("html:not(:animated),body:not(:animated)").animate({
                scrollTop: $('body').scrollTop() + $('html').scrollTop() + next_height
            });
            if (++page == result_pages.length - 1) {
                $('#next_page').addClass('bottom');
            }
        }
    });
    
    /* Page Galleries
     * -------------- */
    
    $('.gallery_image a').click(function(e) {
        e.preventDefault();
        $('.article_image').html($(this).closest('.gallery_image').find('.full_version').html());
    });

	grid_motion();
});

function grid_motion() {
	/* Grid Motion
	 * -------------- */
	 
	jQuery('.cover1').mosaic({
		animation	:	'slide',	//fade or slide
		hover_x		:	'248px'		//Horizontal position on hover
	});
	
	jQuery('.cover2').mosaic({
		animation	:	'slide',	//fade or slide
		hover_x		:	'-248px'	//Horizontal position on hover
	});
	
	jQuery('.cover3').mosaic({
		animation	:	'slide',	//fade or slide
		hover_x		:	'248px',	//Horizontal position on hover
		hover_y		:	'-143px'	//Vertical position on hover
	});
}
