//tab effects

var TabbedContent = {
	init: function() {	
		$(".tab_item").mouseover(function() {
			this.style.color='#fff';
			this.style.textDecoration = 'none';
			
			
			var altroTab = this;
			
			if (this.id == 'tab1') {
				//altroTab = $(this).parent().getElementById("tab2"); //cerca tab 2
				altroTab = document.getElementById("tab2"); //cerca tab 2
			}
			else {
				altroTab = document.getElementById("tab1"); //cerca tab 1
			}
			
			altroTab.style.color = '#333';
			altroTab.style.textDecoration = 'underline';
			
			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(".slide_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();
});