$(document).ready(function(){

$(".tab_search").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_search").fadeIn("slow");
});

$(".tab_tags").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_tags").fadeIn("slow");
});

$(".tab_help").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_help").fadeIn("slow");
});

$(".tab_browse").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_browse").fadeIn("slow");
});

$(".tab_submit").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_submit").fadeIn("slow");
});

$("#tab_all").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_all").fadeIn("slow");
});

$("#tab_alcohol").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_alcohol").fadeIn("slow");
});

$("#tab_drugs").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_drugs").fadeIn("slow");
});

$("#tab_nutrition").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_nutrition").fadeIn("slow");
});

$("#tab_parenting").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_parenting").fadeIn("slow");
});

$("#tab_tobacco").click(function() {
	$(".tab_opt").removeClass("active");
	$(this).addClass("active");
	$(".tab_content").hide();
	$("#content_tobacco").fadeIn("slow");
});

$(".gsc-input").focus(function() {
	$(".splash").hide();
});


// Tagging

$(".delicious-cloud").find("li").addClass("delicious-raindrop");
$(".delicious-raindrop").find("a[href]").each(function() {
	var deliRoot = "http://feeds.delicious.com/v2/rss/hchu_healthclasshelper/";
	var deliTag = this.href.replace("http://delicious.com/hchu_healthclasshelper/","");
	var deliFeed = deliRoot + deliTag;
	this.href= "#tagged_results";
	
	$(this).click(function() {
		$("#xml_parsed").html("<a class='feed' href=" +deliFeed+ ">" +deliTag+ "</a>");
		
		// Parse XML to #xml_parsed DIV
		$('a.feed').gFeed( { target: '#xml_parsed' } );
		$('a.feed').hide();
	});
});

$("#toggle_tags").click(function() {
	$(".delicious-cloud").toggle("slow");
});

$("#toggle_results").click(function() {
	$("#xml_parsed").toggle("slow");
});

// Browsing
// http://feeds.delicious.com/v2/rss/hchu_healthclasshelper

var browseRoot = "http://feeds.delicious.com/v2/rss/hchu_";
var browseAlcohol = browseRoot + "alcohol";
var browseDrugs = browseRoot + "drugs";
var browseNutrition = browseRoot + "nutrition";
var browseParenting = browseRoot + "parenting";
var browseTobacco = browseRoot + "tobacco";
var browsePhysical = browseRoot + "physical_activity";

$("#hchu_alcohol_toggle").click(function() {
	$("#hchu_alcohol").html("<a class='feed' href='" +browseAlcohol+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_alcohol' } );
	$(".browse_content").hide();
	$("#hchu_alcohol").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

$("#hchu_drugs_toggle").click(function() {
	$("#hchu_drugs").html("<a class='feed' href='" +browseDrugs+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_drugs' } );
	$(".browse_content").hide();
	$("#hchu_drugs").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

$("#hchu_nutrition_toggle").click(function() {
	$("#hchu_nutrition").html("<a class='feed' href='" +browseNutrition+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_nutrition' } );
	$(".browse_content").hide();
	$("#hchu_nutrition").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

$("#hchu_parenting_toggle").click(function() {
	$("#hchu_parenting").html("<a class='feed' href='" +browseParenting+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_parenting' } );
	$(".browse_content").hide();
	$("#hchu_parenting").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

$("#hchu_tobacco_toggle").click(function() {
	$("#hchu_tobacco").html("<a class='feed' href='" +browseTobacco+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_tobacco' } );
	$(".browse_content").hide();
	$("#hchu_tobacco").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

$("#hchu_physical_toggle").click(function() {
	$("#hchu_physical").html("<a class='feed' href='" +browsePhysical+ "'></a>");
	$('a.feed').gFeed( { target: '#hchu_physical' } );
	$(".browse_content").hide();
	$("#hchu_physical").show(500);
	$("#browse_menu").find("a").each(function() {
		$(this).removeClass("active");
	});
	$(this).addClass("active");
});

// setTimeout(function() { $('.county_logo').fadeOut(); }, 5000);

});
