$(document).ready(function(){
// Guess what this does...
$.preloadCssImages();

// Top Navigation dropdowns
$(function () {
	// On state for the top navigation
    	var pathname = window.location.pathname.split("/")[window.location.pathname.split("/").length - 2];
	$("#headingNav .tabs li a[name="+ pathname +"]").addClass("on");
	//$("#headingNav .dropdown li a[name="+ currentPage +"]").addClass("ontwo");
	$(".dropdown").each(function () {
		$(this).parent().eq(0).hoverIntent({
			timeout: 20,
			over: function () {
				var current = $(".dropdown:eq(0)", this);
				current.slideDown(150);
			},
			out: function () {
				var current = $(".dropdown:eq(0)", this);
				current.fadeOut(200);
			}
			});
		});
	$(".dropdown a").hover(function () {
		$(this).stop(true).animate({paddingLeft: "15px"}, {speed: 300, easing: "easeOutBack"});
	}, function () {
		$(this).stop(true).animate({paddingLeft: "10px"}, {speed: 300, easing: "easeOutBounce"});
});

if( $("#middleInner .middleNav").length ){
	// Hover effect for the right navigation
	$(".middleNav a").hover(function () {
		$(this).stop(true).animate({paddingLeft: "15px"}, {speed: 300, easing: "easeOutBack"});
	}, function () {
		$(this).stop(true).animate({paddingLeft: "10px"}, {speed: 300, easing: "easeOutBounce"});
	});
	// On state for the right navigation
	var currentPage = $.query.get('p');
	// Test to see if the link exists (this may be a landing or missing page)
	if ( $(".middleNav a[name="+currentPage+"]").length ){
		$(".middleNav a[name="+currentPage+"]").addClass("on");
	}else{
	// If not then add the on class to the first list item	
		$(".middleNav a").eq(0).addClass("on");
	}
}
if( $("#gallery").length ){
	// Gallery pages	
	$("#middleInner #gallery a:nth-child(3n+1)").css("margin-left", 0);
	// Homepage center boxes hover effect
	$("#gallery a").hover(function () {
		$(this).stop(true).fadeTo("fast", 1);
	}, function () {
		$(this).stop(true).fadeTo("fast", 0.8);
	});

	$('#gallery a').lightBox({
		overlayBgColor: '#0A5166',
		overlayOpacity: 0.4,
		imageLoading: '../images/template/loading.gif',
		imageBtnClose: '../images/template/close.gif',
		imageBtnPrev: '../images/template/prev.gif',
		imageBtnNext: '../images/template/next.gif',
		containerResizeSpeed: 350
   	});
}//end gallery

//social networking links
//$(".socialNetworkLinks a").hover(function () {
//	$(this).stop(true).animate({marginTop: "50px"}, {speed: 300, easing: "easeOutBack"});
//}, function () {
//	$(this).stop(true).animate({marginTop: "80px"}, {speed: 300, easing: "easeOutBounce"});
//});
});// end jQuery
});

