$(document).ready(function(){
	
	$('.download-wrap a').css('opacity', '0.3');
	
	$('.download-wrap a ').click(function(e) {
		if(!$(this).hasClass('enabledDownload')) {
			e.preventDefault();
		}
	});

	var mycheckForm = setInterval( 
		function() {
			if($('.wpcf7-response-output').hasClass('wpcf7-mail-sent-ok')) {
				clearInterval( mycheckForm );
				enableDownload();
			}
		}, 500);
	
	function enableDownload() {
		$('.download-wrap a').css('opacity', '1').addClass('enabledDownload');
	}
	
	/* FAQ Page Toggle
	--------------------------------------------------------------------------------------- */
	$('.faq_post h2').click(function() {
	  $(this).toggleClass("faq_display");
	  $(this).next().toggle('fast');
	});

	/* Fancybox
	--------------------------------------------------------------------------------------- */
	$("a[rel='lightbox'], .gallery-item a").fancybox({
		'titleShow' : false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'autoDimensions'	: true,
		'scrolling'			: 'no',
		'centerOnScroll'	: true
	});
	
	$("#home-video").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
});

