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

$(document).ready(function(){
	$("#news-slider").codaSlider({dynamicArrows: false, dynamicTabs: false});
	$("#accordion-container > .first").children(".content").slideFadeToggle("medium");
	
	$(".featured-show-nav").click(function(){
		$(".tabs#select").removeAttr("id");
		if($(this).attr("id") == "next") {
			$("#accordion-container > li").children(".content:visible").slideFadeToggle("medium", function() {
				if($(this).parents("li").is(":last-child")) {
					$(this).parents("ul").children("li:first-child").children("h3").children("a.tabs").attr("id", "select");
					$(this).parents("ul").children("li:first-child").children(".content").slideFadeToggle("medium");
				} else {
					$(this).parents("li").next().children("h3").children("a.tabs").attr("id", "select");
					$(this).parents("li").next().children(".content").slideFadeToggle("medium");
				}
			});
		} else {
			$("#accordion-container > li").children(".content:visible").slideFadeToggle("medium", function() {
				if($(this).parents("li").is(":first-child")) {
					$(this).parents("ul").children("li:last-child").children("h3").children("a.tabs").attr("id", "select");
					$(this).parents("ul").children("li:last-child").children(".content").slideFadeToggle("medium");
				} else {
					$(this).parents("li").prev().children("h3").children("a.tabs").attr("id", "select");
					$(this).parents("li").prev().children(".content").slideFadeToggle("medium");
				}
			});
		}
		return false;	
	});
	
	$(".accordion").click(function(){
		if($(this).parents("h3").next(".content").css("display") == "none") {
			var clicked = $(this);
			$("#accordion-container > li").children(".content:visible").slideFadeToggle("medium", function() {
				clicked.parents("li").children(".content").slideFadeToggle("medium");
			});
		}
		return false;
	});
	
	$(".tabs").click(function(){
		$(".tabs#select").removeAttr("id");
		$(this).attr("id", "select");
		return false;
	});
	
	$("a.gall").lightBox();
	
	$(".show-more").click(function(){
		$(".show-more-reveal").slideFadeToggle("medium");
		return false;
	});
});
