jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function(){
	$('#tellfriend').hide();
	$('li a.email, #tellfriend a.close').click(function() {$("#tellfriend").fadeToggle('slow');});

	$('#email_pastor').hide();
	$('a.email, #email_pastor a.close').click(function() {$("#email_pastor").fadeToggle('slow');});


	$("#myController").jFlow({
		slides: "#slides",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		width: "760px",
		height: "433px",
		duration: 800,
		interval: 6400,
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	});

	//Link the series image to the promo vid
	$("a#promo_video").clone().appendTo(".medpic_bg");

	// Add brackets around text links
	$("p > a").not("p > a.no_brackets").prepend("[").append("]");
	$("li > a").not("#video_menu a").not("p.title > a").not("#weekly_calendar a").not("li > a.no_brackets").prepend("[").append("]");

	// Accordion Effect
	$(".accordion h3").eq(0).addClass("active");
	$(".accordion ul").eq(0).show();
	$(".accordion h3").click(function(){
		$(this).next("ul").slideToggle("slow")
		.siblings("ul:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

	//Side_nav Markup
	$(".accordion h4").eq(0).addClass("active");
	$(".accordion h4 > ul").eq(0).show();
	$(".accordion h4").click(function(){
	$(this).next("ul").slideToggle("slow")
	.siblings("ul:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h4").removeClass("active");
	});

	$("a.fancy").fancybox({
		'frameHeight': 221,
		'frameWidth': 456,
		'hideOnContentClick': false
	}); 
	$("a.fancy-event").fancybox({
		'frameHeight': 258,
		'frameWidth': 456,
		'hideOnContentClick': false
	}); 
	$("a.fancy640").fancybox({
		'frameHeight': 480,
		'frameWidth': 640,
		'hideOnContentClick': false
	}); 
	$("a.fancy-sermon").fancybox({
		'frameHeight': 185,
		'frameWidth': 425,
		'hideOnContentClick': false
	}); 
	$("a.fancy-vimeo").fancybox({
		'frameHeight': 220,
		'frameWidth': 400,
		'hideOnContentClick': false
	}); 
	$("a.fancy-youtube").fancybox({
		'frameHeight': 344,
		'frameWidth': 425,
		'hideOnContentClick': false
	});
	$("a.iframe").fancybox({
		'frameHeight': 205,
		'frameWidth': 445,
		'hideOnContentClick': false
	});
	$("a.fancy-fusion").fancybox({
		'frameHeight': 268,
		'frameWidth': 425,
		'hideOnContentClick': false
	});
	$("a.fancy-ar").fancybox({
		'frameHeight': 450,
		'frameWidth': 360,
		'hideOnContentClick': true
	});

	//Feedback Page
	$("#feedback #tabs h2").hide();

	//Tabs on the More page
	$("#more_about").tabs({ fx: { opacity: 'toggle' } });
	//Tabs on the Sermon Series page
	$("div#tabs").tabs();
//Sermon Series Page
	//remove additional headings
	$("body#series div#tabs h2").hide();

	//Videos - ajax functionality
	$("#video_menu li a").mouseup(function(){$("#video_player").load($(this).attr('class'));});
	
//FusionPage
	//remove additional headings
	$("body#fusion div#groups h3").hide();
	//remove scroll bar
	$("#additional_content").css('overflow','hidden');
	//Resource Tabs
	$("div#r_tabs").tabs();
	$("#mycarousel").jcarousel({
		scroll: 3
	});

//Pastor's Page
	//Email Pastor
	//Hides the email box
	$("#email_me").hide();
	//Show the email box
//	$("a#email_button").click(fuction(){
//		$("email_me").show("fast");
//	)};
	//Close the email box
//	$(".close").click(function(){
//		$("#email_me").hide("fast");
//	)};
	
});










