
var Landing = new Class({
	
	/*------------------------------------------------------
		initialize()
	------------------------------------------------------*/
	initialize: function(){

		
		// Add other animations
		if($('kwicks')) this.parseKwicks();
		if($('showCampusBox') && $('box2') && $('mainHome')) this.locationsSlide();

	},
	
	/*------------------------------------------------------
		parseKwicks()
		Inspired by Mootools.net
	------------------------------------------------------*/
	parseKwicks: function(){
		var min = Settings.kwicks.min;
		var max = Settings.kwicks.max;
		var init = Settings.kwicks.init;
	
		var kwicks = $$('#kwicks .kwick');
		var fx = new Fx.Elements(kwicks, {wait: false, duration: Settings.kwicks.duration, transition: Fx.Transitions.Quad.easeOut});
		kwicks.each(function(kwick, i){
			kwick.addEvent('mouseenter', function(e){
				var obj = {};
				obj[i] = {
					'width': [kwick.getStyle('width').toInt(), max]
				};
				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != min) obj[j] = {'width': [w, min]};
					}
				});
				fx.start(obj);
			});
		});
		
		$('kwicks').addEvent('mouseleave', function(e){
			var obj = {};
			kwicks.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), init]};
			});
			fx.start(obj);
		});
	},
	
	/*------------------------------------------------------
		locationsSlide()
	------------------------------------------------------*/
	locationsSlide: function() {
		var locationsSlide = {
			fx: new Fx.Morph('box2', Settings.locationSelect),
			fx2: new Fx.Morph('mainHome', Settings.locationSelect),
			startHeight: Settings.locationsSelect.landingStart,
			state: 1,
			toggle: function() {
				this.fx.start({'height': ((this.state == 1) ? this.startHeight : 0)});
				this.state = ((this.state == 1) ? 0 : 1);
			},
			slideUp: function() {
				this.fx.start({'height': 0});
				this.fx2.start({'height': Settings.locationsSelect.landingOuterMin});
				this.state = 1;
			},
			slideDown: function() {
				this.fx.start({'height': this.startHeight});
				this.fx2.start({'height': Settings.locationsSelect.landingOuterMax});
				this.state = 1;
			},
			hide: function() {
				$('box2').setStyles({
					'height': 0,
					'display': 'block'
				});
				this.state = 1;
			}
		};

		// Start with it hidden
		locationsSlide.hide();

		// Add the event
		$('showCampusBox').addEvent('click', function(event) {
			event = new Event(event).stop();
			locationsSlide.slideDown();    
		}.bind(this));
		
		$('closeBox').addEvent('click', function(event) {
			event = new Event(event).stop();
			locationsSlide.slideUp();    
		}.bind(this));
	}
	
}); // End Landing Class

/*----------------------------------------------------------
	
	Initialize the class (which initializes the 
	any other used classes) when the DOM is ready.
	
----------------------------------------------------------*/
var landing;
window.addEvent('domready', function() {
    landing = new Landing();
});