var backgroundImages = [	"/resources/images/layout/bg_site01.jpg",
													"/resources/images/layout/bg_site02.jpg"];
var backgroundLinks = [		"/military",
													"/commercial"];

$(document).ready(function(){
	initTopNav();
	initMainNav();
	initSecondaryBuckets();
});

function initBackground() {
	var bgIndex = Math.floor(Math.random()*backgroundImages.length);
	$('body').css('background','#000000 url(' + backgroundImages[bgIndex] + ') top center no-repeat');
	$('#site-banner-space a:first').attr('href',backgroundLinks[bgIndex]);
}

function initTopNav() {
	$('div#site-header-top > ul > li').hover(
		function(){
			$(this).addClass('over');
		},
		function(){
			$(this).removeClass('over');
		}
	);
}

function initMainNav() {
	//over
	$('div#site-header-nav > ul > li').each(function(){
		$(this).find('img').fadeTo(0,0);
		
		$(this).hover(
			function(){
				$(this).find('img').fadeTo(100,1);
			},
			function(){
				$(this).find('img').fadeTo(250,0);
			}
		);
		
	});
}

function initSecondaryBuckets() {
	$('div#secondary-buckets > div').each(function(){
		$(this).children('img:first').fadeTo(0,0);
		$(this).hover(function(){
			$(this).children('img:first').fadeTo(300,1);
		},
		function(){
			$(this).children('img:first').fadeTo(150,0);
		})
	});
}

function initGallery() {
	$('#content-gallery > a').attr('rel','gallery360');
	$('#content-gallery > a > img').each(function(){
		$(this).fadeTo(0,.5);
	});
	$('#content-gallery > a').hover(function(){
		$(this).find('img').stop().fadeTo(250,1);
	},
	function(){
		$(this).find('img').stop().fadeTo(250,.5);
	});
	$('#content-gallery > a').fancybox({
		'padding'       :	5,
		'overlayOpacity':	.8,
		'zoomOpacity'		: true,
		'zoomSpeedIn'		: 500,
		'zoomSpeedOut'	: 500
	});
}