fbBase.extend({

	init: function(){
		this.PrimaryNav();
		new this.Carousel('hero');
	},
	
	 /**
	  * @method PrimaryNav
	  *
	  * Primary Navigation events and FX
	  */

	
	PrimaryNav: function(){
		document.id('nav-primary').getElements('a').set('morph', {
			duration: 500
		}).addEvents({
			'mouseenter': function(){
				this.morph('.nav-primary-hover');
			},

			'mouseleave': function(){
				this.morph('.nav-primary-std');
			}
		});
	},
	
	
	 /**
	  * @class Carousel
	  */
	
	
	Carousel: Class.refactor(fbBase.Carousel, {
		Navigation: function(){
			this.previous();
			
			this.left.set('tween', {
				duration: 250
			});
			
			this.right.set('tween', {
				duration: 250
			});
			
			this.left.addEvents({
				'mouseenter': function(){
					this.tween('margin-left', -5);
				},
				'mouseleave': function(){
					this.tween('margin-left', 0);
				}
			});
			
			this.right.addEvents({
				'mouseenter': function(){
					this.tween('margin-right', -5);
				},
				'mouseleave': function(){
					this.tween('margin-right', 0);
				}
			});
		}
	})
});


fbBase.Forms.extend({
	init: function(){
		this.setupApplyForm();
		this.setupContactForm();
	},
		
	setupApplyForm: function(){
		var frm = document.id('frmApply');
		if(!frm) return;
		
		new Form.Validator.Inline(frm, {
			errorPrefix: '',
			warningPrefix: '',
			scrollFxOptions: {
				offset: {
					x: 0,
					y: -70
				}
			}
		});
	},
	
	setupContactForm: function(){
		var frm = document.id('frmContact');
		if(!frm) return;
		
		frm.addEvent('submit', function (e) {
			e.stop();
		});
		
		new Form.Validator.Inline(frm, {
			errorPrefix: '',
			warningPrefix: '',
			scrollFxOptions: {
				offset: {
					x: 0,
					y: -70
				}
			},
			onFormValidate: function(pass,frm,fn){
				if(pass){
					frm.set('action','/contact/send');
					new Form.Request(frm, frm).send();
				}
			}
		});
	}
});

window.addEvent('domready', function() {
	fbBase.initialize();
});
