/*----------------------------------------------------------
	
	Class Campus
	Author: Sam Soffes
	Date: 01-24-08
	Description:
		This class controlls all of the Ajax elements on
		the campus pages.	
	
----------------------------------------------------------*/

var Campus = new Class({

	/*------------------------------------------------------
		initialize()
		
		This method loads all of the various animations and
		AJAX requests that are used on the campus site.
	------------------------------------------------------*/
	initialize: function() {
		
		// Campus home animation
		if($('centerNav') && $('contentRight')) this.centerNav();
				
		// Load the BlackBar if it's there
		if($('topblackbar_button')) {
			var blackBar = {
				fx: new Fx.Morph('topblackbar', {duration: Settings.blackBar.duration, transition: Fx.Transitions.Quint.easeInOut}),
				maxHeight: function() {
					if($('largeTop')) return Settings.blackBar.maxHeight;
					else return Settings.blackBar.maxHeightSmall;
				},
				hide: function() {
					$('topblackbar').style.height = this.minHeight+'px';
					this.state = 1;
				}
			};
			
			// Start hidden
			blackBar.hide();
			
			// Add the BlackBar Event
			$('topblackbar_button').addEvent('click', function(event) {
				event = new Event(event).stop();
				blackBar.swap();			
			});
		}
		
		
	},
	
	/*------------------------------------------------------
		centerNav()
	------------------------------------------------------*/
	centerNav: function() {
		var faq = new Accordion('div#centerNav li div.center', 'div#contentRight div.content', {
			opacity: 1,
			fixedWidth: '311px',
			fixedHeight: '285px',
			
			onActive: function(toggler, element){
			
				var arrow = toggler.getParent().getElement('.arrow');
				var icon = toggler.getElement('.icon');
				var header = toggler.getElement('h3');
								
				new Fx.Morph(toggler, Settings.centerNav.options).start(Settings.centerNav.active.nav);
				new Fx.Morph(header, Settings.centerNav.options).start(Settings.centerNav.active.header);
				new Fx.Morph(arrow, Settings.centerNav.options).start(Settings.centerNav.active.arrow);
				new Fx.Morph(icon, Settings.centerNav.options).start(Settings.centerNav.active.icon);
			},
			
			onBackground: function(toggler, element){
				var arrow = toggler.getParent().getElement('.arrow');
				var icon = toggler.getElement('.icon');
				var header = toggler.getElement('h3');
								
				new Fx.Morph(toggler, Settings.centerNav.options).start(Settings.centerNav.background.nav);
				new Fx.Morph(header, Settings.centerNav.options).start(Settings.centerNav.background.header);
				new Fx.Morph(arrow, Settings.centerNav.options).start(Settings.centerNav.background.arrow);
				new Fx.Morph(icon, Settings.centerNav.options).start(Settings.centerNav.background.icon);
			}
		}, $('centerNav'));
	}		
}); // End Campus Class

/*----------------------------------------------------------
	
	Initialize the class (which initializes the 
	any other used classes) when the DOM is ready.
	
----------------------------------------------------------*/
var campus;
window.addEvent('domready', function() {
    campus = new Campus();
});
/*----------------------------------------------------------
	
	Class Shared
	Author: Sam Soffes
	Date: 02-13-08
	Description:
		This class contains all of the shared ajax for all
		of the pages across all of the applications.
					
----------------------------------------------------------*/
var Shared = new Class({
	
	/*------------------------------------------------------
		genericAccordion()
		
		This is used for any of the accordions anywhere
		(besides the frontpage one).
	------------------------------------------------------*/
	genericAccordion: function(togglers, elements, container, settings) {
		var accordion = new Accordion(togglers, elements, {
			onActive: function(toggler, element) {
				toggler.setStyle('borderBottomColor', '#d8dde3');
				new Fx.Morph(toggler, settings.options).start(settings.active.toggler);
				new Fx.Morph(element, settings.options).start(settings.active.element);
			},
			onBackground: function(toggler, element) {
				new Fx.Morph(toggler, settings.options).start(settings.background.toggler);
				new Fx.Morph(element, settings.options).start(settings.background.element);
			}
		}, $(container));
	}
	
});

/*----------------------------------------------------------
	
	Object Settings
	Author: Sam Soffes
	Date: 01-30-08
	Description:
		This class contains all of the variables such as
		styles and sizes for all of the classes for easy
		access by people who don't know javascript like
		the Ninja.
			
----------------------------------------------------------*/
var Settings = {

	// Center Nav
	centerNav: {
		options: {
			duration: 300,
			'wait': false,
			transition: Fx.Transitions.Quad.easeInOut
		},
		active: {
			nav: { height: 76, color: '#2f334a' },
			header: { color: '#ffffff' },
			arrow: { opacity: 1 },
			icon: { top: 17 }
		},
		background: {
			nav: { height: 45, color: '#9cbdcc' },
			header: { color: '#cad6db' },
			arrow: { opacity: 0 },
			icon: { top: 0}
		}
	},
	
	// Generic Accordion
	genericAccordion: {
		options: {
			duration: 200,
			'wait': false,
			transition: Fx.Transitions.Quad.easeInOut,
			openClose: true
		},
		active: {
			toggler: { backgroundImage: 'url()' },
			element: { 'padding': '17px' }
		},
		background: {
			toggler: {  borderBottomColor: '#b3c1cb', backgroundImage: 'url()' },
			element: { 'padding': 0 }
		}
	}
	
}; // End Settings Object

