$(document).ready(function(){
	
	//######################
	//General site scripting
	
	//set height of main window to fill screen
	$('#stage').css({'height': $(document).height()});
	
	//set external links to open in a new window
	$('div.content a[href^="http"]').attr({target:"_blank"});
	
	//animate page background design in all browsers except IE 6 and lower
	if (!$.browser.msie || ($.browser.msie && parseInt(jQuery.browser.version)>=7)) {
		$("#accessibility small").animate({left: '-46500px'}, 2000000, "linear");
	}
	
	//###############################
	//Home page feature functionality
	
	//colors for bottom of menu bar, and the top glow of feature box
	//set dynamically on feature menu click
	barColors = ['#4a9fbd','#9700bf','#bf005a','#00bf99','#e6c800','#e66700'];
	topGlowPosition = ['0 0','-912px 0','-1824px 0','-2736px 0','-3648px 0','-4560px 0'];
	
	
	//Use the jQuery Tools plugin for scrollable content 
	//includes a navigation set up and browser history
	var api = $("#home-content").scrollable({
		//set the ID of the DOM element that contains the scrollable items
		items: '#home-features',
		//when we click to go to a featured item
		//set the color bar at bottom and glow color at top
		onBeforeSeek: function(event, i) {
			$('#home').css('background-position', topGlowPosition[i]);
			$('#home-menu-footer').css('background-color', barColors[i]);
		}
	// use the navigator plugin
	}).navigator({
	// set the ID of the DOM element that contains the menu items
		navi: "#home-menu",

		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',

		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current',
		
		//turn on the functionality for having the back/foward broswer buttons function 
		//requires the feature menu 'a' tags to have a hash name as the href
		history: true

	
	}).data("scrollable");
			
			
	// this callback does the special handling of the "intro page" (main feature)
	api.onBeforeSeek(function(e, i) {
	
		// when on the first item: hide the intro
		if (i) {
			$("#home-main").fadeOut("slow");
	
			// dirty hack for IE7-. cannot explain
			if ($.browser.msie && $.browser.version < 8) {
				$("#home-main").hide();
			}
	
		// otherwise show the intro
		} else {
			$("#home-main").fadeIn(1000);
		}
	
		// toggle activity for the intro thumbnail
		$("#t0").toggleClass("current", i == 0);
	});
	
	// a dedicated click event for the intro thumbnail
	$("#t0").click(function() {
	
		// seek to the beginning (the hidden first item)
		$("#home-content").scrollable().begin();
	
	});
	
	
});
			
