/* Author: 

*/

$(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)
	)
	
	// Supersized BG
	$.supersized({
		start_slide				:	0,		//Start slide (0 is random) //Requires multiple background images
		vertical_center         :   1,		//Vertically center background
		horizontal_center       :   1,		//Horizontally center background
		min_width		        :   320,	//Min width allowed (in pixels)
		min_height		        :   480,	//Min height allowed (in pixels)
		fit_portrait         	:   0,		//Portrait images will not exceed browser height
		fit_landscape			:   0,		//Landscape images will not exceed browser width
		image_protect			:	1,		//Disables image dragging and right click with Javascript
		slides					:   [ 		//Background image
									  		{image : '/_media/images/layout/bg-full-arm.jpg'},
											{image : '/_media/images/layout/bg-full-crowd.jpg'},
											{image : '/_media/images/layout/bg-full-drummer.jpg'},
											{image : '/_media/images/layout/bg-full-crayon.jpg'},
											{image : '/_media/images/layout/bg-full-toys.jpg'}
									]					
	});
	
	// Nav
	if (mobile) // We have to use .live events instead of hoverIntent
	{
		$('#nav li').live('mouseenter', function() {
			$(this).addClass('active');
			$('.panel', this).animate({opacity: 'show', top: '55'}, 250);
		}).live('mouseleave', function() {
			$(this).removeClass('active');
			$('.panel', this).animate({opacity: 'hide', top: '40'}, 100);	
		});
	}
	else
	{
		$('#nav li').hoverIntent(function() {
			$(this).addClass('active');
			$('.panel', this).animate({opacity: 'show', top: '55'}, 250);
		}, function() {
			$(this).removeClass('active');
			$('.panel', this).animate({opacity: 'hide', top: '40'}, 100);	
		});
	};

	
	//$('#nav li#nav-messages .panel').show();

	// Home Hero
	$('#hero ul').tabs('.panes > div', {
		event: 'click'
	});
	
	// Pause Auto Play on content area hover
	$('.panes > div').hover(function(){
		$('#hero .tabs').data('slideshow').pause();
	}, function() {
		$('#hero .tabs').data('slideshow').play();
	});
	
	// Input Hints
	$('input[title]').inputHints();
	
	// Add .last to all Paragraphs. Oh, IE
	$('.main-content p:last-child, .connecting-row').addClass('last');
	
	// Fancybox
	$('a.fancy').fancybox({
		hideOnContentClick: false,
		hideOnOverlayClick: false,
		'swf' :
		{
		    'wmode'				: 'transparent',
		    'allowfullscreen'	: 'true'
		}
	});
	
	// Live Form Validation
	$('.validate-text').validate({
		expression: 'if (VAL) return true; else return false;',
		message: 'Required field'
	});
	$('.validate-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'
	});
	
});





















