$(document).ready(function() {
	runCufon();		
	// Initialize placeholder for the sign-up form
	$(":input[placeholder]").placeholder();

	activateFancyBox();	
    activateTabs();
    activateCarousel();	  
});

// Cufon replacement
function runCufon() {
	//REPLACE THE LOGO FONT
	Cufon.replace('h1', {
		color: '-linear-gradient(#DDD, 0.45=#FFF, 0.46=#EEE, #FFF)'
    });
	//REPLACE THE PHONE NUMBER FONT
	Cufon.replace('#call-number', {
		color: '-linear-gradient(#DDD, 0.45=#FFF, 0.46=#EEE, #FFF)'
	});
	//REPLACE THE CALL FONT
	Cufon.replace('#call-text', {
		color: '-linear-gradient(#AAA, 0.45=#BBB, 0.46=#AAA, #CCC)'
	});
	Cufon.replace('h2', {
	});
	Cufon.replace('h3', {
	});
	Cufon.replace('button', {
        color: '-linear-gradient(#DDD, 0.45=#FFF, 0.46=#EEE, #FFF)'
	});
	Cufon.replace('#buy-now-caption p', {

	});
}

function activateTabs(){
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});	
}

function activateCarousel(){	
		$(".carousel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible: 6,
			scroll:3,
			beforeStart: activateFancyBox
		});	
	
}

function activateFancyBox(){
		$("#gallery a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});	
	$(".fancy-vimeo").click(function() {
        $.fancybox({
            'padding'        : 0,
            'autoScale'        : false,
            'transitionIn'    : 'elastic',
            'transitionOut'    : 'elastic',
            'title'            : this.title,
            'width'            : 400,
            'height'        : 265,
            'href'            : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
            'type'            : 'swf'
        });

        return false;
    });
	$(".fancy-youtube").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;
	});
}
