var TabbedContent = {
	init: function() {
		$(".tab_item1").click(function() {
			$(".tab_item1").add("span.tab_item1").css("color", "");
			$(this).add("span").css("color", "#000000");
			var background = $(this).parent().find(".moving_bg");

			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});

			TabbedContent.slideContent($(this));

		});

		$(".tab_item2").click(function() {
			$(".tab_item2").add("span.tab_item2").css("color", "");
			$(this).add("span").css("color", "#000000");
			var background = $(this).parent().find(".moving_bg");

			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});

			TabbedContent.slideContent($(this));

		});

		$(".tab_item3").click(function() {
			$(".tab_item3").add("span.tab_item3").css("color", "");
			$(this).add("span").css("color", "#000000");
			var background = $(this).parent().find(".moving_bg");

			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});

			TabbedContent.slideContent($(this));

		});
	},

	slideContent: function(obj) {

		var margin = $(obj).parent().parent().find(".content").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;

		$(obj).parent().parent().find(".tabslider").stop().animate({
			marginLeft: margin + "px"
		}, {
			duration: 300
		});
	}
}

$(document).ready(function() {
	TabbedContent.init();
	$("span.tab_item1:first").css('color','#000000');
	$("span.tab_item2:first").css('color','#000000');
	$("span.tab_item3:first").css('color','#000000');
});
;

