
function onDocumentReady(){
	
	// measure the height of the navs
	var __aggregateNavHeight = $("nav").height();
	
	// set the height of the nav container
	$("#header_nav_container").css("height", __aggregateNavHeight + "px");
	
	// offset the nav element
	$("nav").css("margin-top", "-" + __aggregateNavHeight + "px");
	
	// program the nav links
	$("#work_link_opened").hide();
	$("#work_link_opened").click(hideNav);
	$("#work_link_closed").click(showNav);
	
	
	// program the galleries
	$(".image_rotator").each(
		function(){
			var __sizingElement = $(this).children().first().children().first();
			// create an aslImageRotator instance
			$(this).children().aslImageRotator({autoplay:true, autoplayInterval:3000, viewportWidth:__sizingElement.width(), viewportHeight:__sizingElement.height(), scrollIn:false, scrollOut:false, fadeIn:true, transitionDuration:1000});
		}
	);
	
	// program the back to top link
	$(".top_link").bind("click", onTopLinkClick);
	
	// program some custom index nav behavior
	$(".main_nav a").each(
		function(){
			$(this).bind("click", hideNav);
		}
	);
	
	// show the nav
	setTimeout(showNav, 1000);
	setTimeout(setBackgroundColor, 500);

}

function onTopLinkClick(e){
	$('html,body').animate({scrollTop: 0}, 500)
}

function showNav(){
	$("#work_link_opened").show();
	$("#work_link_closed").hide();
	$("#header_nav_container nav").animate({"margin-top":0}, 250);
}

function hideNav(){
	$("#work_link_opened").hide();
	$("#work_link_closed").show();
	$("#header_nav_container nav").animate({"margin-top":-($("nav").height())}, 250);
}

function setBackgroundColor(){
	// attempting to fix one of Safari 5's 850 bugs
	$("body").css("height", "100%");	
	$("body").css("background-color", "#121212");	
}

function initGalleries(){

	// for each index_work_thumbnails occurence
	$(".asl_gallery").each(
		function(){
			$(this).children().aslSimpleGallery({})
		}
	);
	
}
