var contentLayers=["program","voluntary","donations","we"]
var selectedLayer = "";

function showContent(layer){
	selectedLayer = layer;
	$("#background").show();
	$("#"+layer+"_layer").slideDown("slow");
	$("#show_"+layer).removeClass("selected")
	$("#show_"+layer).addClass(layer+"_color");
	jQuery.each(contentLayers, function(i,contentLayer){
		$(".initial").removeClass("initial")
		if(contentLayer!=layer){
			$("#"+contentLayer+"_layer").hide();
			$("#show_"+contentLayer).addClass("selected");
			$("#show_"+contentLayer).removeClass(contentLayer + "_color");
		}
	});
	if(parseFloat($(document).scrollTop())<300){$('html,body').animate({scrollTop:$("#nav").offset().top},150);}
	else if(parseFloat($(document).scrollTop())>$("#nav").offset().top){$('html,body').animate({scrollTop:$("#nav").offset().top},0);}
}

function switchColor(layer) {
	jQuery.each(contentLayers, function(i,contentLayer){
		if (contentLayer != selectedLayer) {
		 $("#show_"+contentLayer).removeClass(contentLayer + "_color");
		}
	});
	$("#show_" + layer).addClass(layer + "_color");
}

function removeColor(layer) {
	jQuery.each(contentLayers, function(i,contentLayer){
	if (layer != selectedLayer) {
		$("#show_" + layer).removeClass(layer + "_color");
	}
	});
}

$(document).ready(function(){
	jQuery.each(contentLayers,function(i,contentLayer){
		$("#show_"+contentLayer).click(function(){ showContent(contentLayer);});
	});

	jQuery.each(contentLayers,function(i,contentLayer){
                $("#show_"+contentLayer).mouseover(function(){ switchColor(contentLayer);});
        });

	 jQuery.each(contentLayers,function(i,contentLayer){  
                $("#show_"+contentLayer).mouseout(function(){ removeColor(contentLayer);});
        });

});	


