$(document).ready(function(){
	
	var mobile =
	(
		navigator.userAgent.match(/Android/i) ||
		navigator.userAgent.match(/webOS/i) ||
		navigator.userAgent.match(/iPhone/i) ||
		navigator.userAgent.match(/iPod/i) ||
		navigator.userAgent.match(/iPad/i)
	)
	
	//Homepage Hero
	$('#hero.home #announcements .wrapper').orbit({
		animation: 'horizontal-push',                  // fade, horizontal-slide, vertical-slide, horizontal-push
		animationSpeed: 300,                // how fast animtions are
		timer: true, 			 // true or false to have the timer
		advanceSpeed: 6000, 		 // if timer is enabled, time between transitions 
		pauseOnHover: true, 		 // if you hover pauses the slider
		startClockOnMouseOut: true, 	 // if clock should start on MouseOut
		startClockOnMouseOutAfter: 500, 	 // how long after MouseOut should the timer start again
		directionalNav: true, 		 // manual advancing directional navs
		captions: false, 			 // do you want captions?
		captionAnimation: 'fade', 		 // fade, slideOpen, none
		captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		bullets: true,			 // true or false to activate the bullet navigation
		bulletThumbs: false,		 // thumbnails for the bullets
		bulletThumbLocation: '',		 // location from this file where thumbs will be
		afterSlideChange: function(){} 	 // empty function 
	});
	
	// Hero Nav
	if ( ! mobile )
	{
		$('#nav li.parent').hover(function() {
			$(this).addClass('active');
			$('.panel', this).fadeIn('fast');
		}, function() {
			$(this).removeClass('active');
			$('.panel', this).fadeOut('fast');	
		});
	};	
	
	// Disable Certain top-level links in main nav
	if ( ! mobile )
	{
		$('#nav li.parent:eq(1) > a, #nav li.parent:eq(2) > a, #nav li.parent:eq(3) > a, #nav li.parent:eq(5) > a').click(function(e) {
			e.preventDefault();
		});
	};	
	
	// Pop-up windows
	$('a[rel="pop"]').popupWindow({
		height:315, 
		width:415, 
		top:50, 
		left:50 
	});	
	
	// Fancy Box
	$('a.fancy').fancybox();
	
	// Style Google Translate
	$('.goog-te-banner-frame').removeAttr('style');
	
	// Accordion
	$('#accordion-wrap').accordion({
		header: 'h3',
		autoHeight: false
	});
	
	// Live Form Validation
	$('.val-text').validate({
		expression: 'if (VAL) return true; else return false;',
		message: 'Required field'
	});
	$('.val-email').validate({
		expression: 'if (VAL.match(/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;',
		message: 'Valid email required'
	});
	
	// Uniform
	$('.uniform select, .uniform input:checkbox, .uniform input:radio, .uniform input:file').uniform();
	
});
