
$(function(){
	
	// Main navigation dropdowns.
	// Adding a hover class for old browsers and a subtle transition effect
	$('#nav > li > ul, #nav > li > div.dropdown').hide();
	$('#nav > li').hover(function(){
		$(this).children('ul:first, div:first').fadeIn(200);
		$(this).addClass('hover');
	}, function(){
		$(this).children('ul:first, div:first').hide();
		$(this).removeClass('hover');
	});
	
	// Home page slideshow
	$('#banner-slides').cycle({
		timeout: 5000,
		pager:  '#banner-nav',
		pagerEvent: 'mouseover',
		allowPagerClickBubble: true,
		pauseOnPagerHover: true,
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#banner-nav li:eq(' + idx + ') a'; 
    }
	});
	
	// Page slideshows
	// Uses the Galleria plugin - http://galleria.aino.se/
	$('.slideshow').galleria({
		height: 360,
		width: 415,
		lightbox: true, // allow fullsize image to open in lightbox
		maxScaleRatio: 1 // don't upscale
	});
	
	// Open external links in a new window
	$("a[href^=http]").each(function() {
		if(this.href.indexOf(location.hostname.replace(/www./gi, "")) == -1) {
			$(this).click(function() { window.open(this.href, "_blank"); return false; });
		}
	});
	
	// Classroom subnav
	// Highlight the current page.
	// Identify the last li in each category
	$('.classroom #subnav li').find("a[href='"+window . location.href+"']").each(function(){$(this).parent().addClass("selected")});
	$('.classroom #subnav ul').each(function(){
    $(this).find('li:last-child').last().addClass('last');
  });

});
























