$(function() {
	Cufon.replace('.bbq');
	
	if($('input[name=accept-terms]').length > 0) {
		$('.add-to-cart-button').click(function(e) {
			if(!$('input[name=accept-terms]').is(':checked')) {
				e.preventDefault();
				$('#dialog-alert').html('Please check the box indicating you agree to the Terms and Conditions to proceed.').dialog({
					modal: true,
					title: 'Terms and Conditions'
				});
			}
		});
	}
	
	$('.bu-underline').find('a').underline({
		color: '#ef3f27',
		width: 3,
		duration: 250
	});
	
	if($('#bu-splash').length > 0) {
		$('#bu-splash').anythingSlider({
			autoPlay: true,
			autoPlayLocked: true,
			buildArrows: false,
			buildNavigation: false,
			buildStartStop: false,
			pauseOnHover: false,
			delay: 7000,
			resumeDelay: 0,
			delayBeforeAnimate: 250,
			onInitialized: function(e, slider) {
				$('#bu-mid-nav').find('.' + slider.$currentPage.attr('id')).css('backgroundPosition','50% 0px');		
			},
			onSlideInit: function(e, slider) {
				$('#bu-splash').parents('.anythingSlider').fadeTo(250, 0.33);
			},
			onSlideComplete: function(slider) {
				$('#bu-splash').parents('.anythingSlider').fadeTo(250, 1);
				$('#bu-mid-nav').find('.' + slider.$lastPage.attr('id')).css('backgroundPosition','50% -9999px');
				$('#bu-mid-nav').find('.' + slider.$currentPage.attr('id')).css('backgroundPosition','50% 0px');
			}
		});
	
		$('#bu-mid-nav a').click(function(e) {
			e.preventDefault();
			$('#bu-splash').anythingSlider('#' + $(this).parent().attr('class'));
		});
	
		$(window).bind('blur', function() {
			$('#bu-splash').data('AnythingSlider').startStop(false);
		});
		
		$(window).bind('focus', function() {
			$('#bu-splash').data('AnythingSlider').startStop(true);
		});
	}
	
	if($('#tweets').length > 0) {
		$("#tweets").tweet({
			avatar_size: 32,
			count: 10,
			username: "goblackumbrella",
			template: "{text}",
			loading_text: "Loading news feed..."
		}).bind("loaded",function(){$(this).find("a").attr("target","_blank");});
	}
	
	if($('.yt-holder').length > 0) {
		$(".yt-playlist").ytplaylist({
			addThumbs: true,
			autoPlay: false,
			showRelated: false,
			playerHeight: 315,
			playerWidth: 420
		});
		
		$("#yt-scroll").jCarouselLite({
			btnNext: ".yt-next",
			btnPrev: ".yt-prev"
		});
	}
});
