$(document).ready(function() {
	if($('nav').length > 0) { megaMenu(); }
	if($('#content img').length > 0) { addShadowWrap(); }
	if($('.faqs').length > 0) { addAccordion(); }
});
// Function to fade in/out mega menu items
function megaMenu() {
	// Hide all dropdown menus to prevent snapping on the first show
	$('nav .mega').animate({opacity:0}, 1);
	// When we hover over the top level "Kits" link, show the first DIV (or .kits)
	$('nav > ul > li').hoverIntent(function() {
		if($('.mega',this).hasClass('alignRight'))
			$('.mega',this).stop().css({'right':'0'}).show().animate({opacity:1},400);
		else
			$('.mega',this).stop().css({'left':'0'}).show().animate({opacity:1},400);
	},function(){
		$('.mega',this).stop().animate({opacity:0},400,function(){
			if($(this).hasClass('alignRight'))
				$(this).css({'right':'-9999px'});
			else
				$(this).css({'left':'-9999px'});
		})
	});
}
// Function to wrap images in a div tag for curved shadow purposes
function addShadowWrap() {
	var design = 'lifted';	// lifted = Lifted corners
									// curled = Curled corners
									// perspective = Shadows appears on the ground, picture looks like it's standing on end
									// raised = Raised box
									// curved-vt-1 = Single vertical curve on left only
									// curved-vt-2 = Verticle curves on left and right
									// curved-hz-1 = Single horizontal curve on bottom only
									// curved-hz-2 = Horizontal curves on top and bottom
	$('#content img').each(function() {
		var doIt = -1;
		if($(this).parent().attr('id'))
			doIt = $(this).parent().attr('id').indexOf('recaptcha');
		if(doIt == -1 && !$(this).hasClass('noshadow')) {
			var classTxt = $(this).attr('class')+' drop-shadow '+design;
			$(this).wrap('<div></div>');
			$(this).parent().addClass(classTxt);
			$(this).removeClass(classTxt);
		}
	});
}
// Function to add accordion to FAQs
function addAccordion() {
	$('.accordion ul li').each(function() {
		if($(this).is(':first-child')) {
			$(this).addClass('acbutton').click(function() {
				$('.accontent').slideUp();
				$(this).siblings().slideDown();
			});
		}else {
			$(this).addClass('accontent');
		}
	});
	$('.accontent').hide();
}
