//GLOBAL FUNCTIONS
function useAnchor(startPage) {
	var localAnchor = window.location.hash.substring(1);
	
	
	if(localAnchor === '') {
		$(startPage + 'C').setStyle('display','block');
		$(startPage).setStyle('color','#396fa9');
	}
	else{
		$(localAnchor + 'C').setStyle('display','block');
		$(localAnchor).setStyle('color','#396fa9');
	}
}

window.addEvent('domready', function() {

	//VARS & LOCAL FUNCTIONS
	var fadeFx = new Fx.Tween($('fadediv'), {transition: 'sine:in:out'});

    var fallspringSlide = new Fx.Slide('navfallspring', {link: 'cancel', mode: 'vertical', transition: 'expo:in:out', duration: 'short'}).hide();
    var summerSlide = new Fx.Slide('navsummer', {link: 'cancel', mode: 'vertical', transition: 'expo:in:out', duration: 'short'}).hide();
    
	function contentFade(displayDiv) {
		
		fadeFx.cancel();
	
		fadeFx.start('opacity', 0).chain(function() {
			this.callChain();
			}).chain(function() {
				$$('.hidden').setStyle('display', 'none');
				$(displayDiv + 'C').setStyle('display', 'block');
				$$('.jslink').tween('color', '#919191');
				$(displayDiv).tween('color', '#396fa9');
				this.callChain();
			}).chain(function() {
				fadeFx.start('opacity', 1);
		});
	
	}
    
    //EVENTS
/*
    $('fallspring_toggle').addEvent('mouseenter', function(event){
        event.stop();
        fallspringSlide.slideIn();
        summerSlide.slideOut();
    });
*/

    $('summer_toggle').addEvent('mouseenter', function(event){
        event.stop();
        summerSlide.slideIn();
        fallspringSlide.slideOut();
    });

    $$('.nav').addEvent('mouseleave', function(event){
        event.stop();
        fallspringSlide.slideOut();
        summerSlide.slideOut();
    });
    
    $$('.nosub').addEvent('mouseenter', function(event){
        event.stop();
        fallspringSlide.slideOut();
        summerSlide.slideOut();
    });
    
	$$('.jslink').each(function(item){
		var spanName = $(item).get('id');
		item.addEvent('click', function(){ contentFade(spanName); });
	});
	
	Shadowbox.init({overlayOpacity: 0.9});
	
});
