//tab effects

 
var TabbedContent = {
	init: function() {	
	
	$(".tab_item").mousedown(function() {
		
			var background = $(this).parent().find(".moving_bg");
			//var elementRight = $("#element").attr("right"); 
			


			$(background).stop().animate({
				//left: $(this).position()['left'] 
				  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
		});
	}
}

// Treatment slider code

var TabbedContent1 = {
	init: function() {	
		$(".tab_item_treat").mousedown(function() {
		
			var background = $(this).parent().find(".moving_bg_treat");

			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});
			
			TabbedContent1.slideContent($(this));
                        setCookie("treatment_consultant_cookie",$(this).attr("title"),600);
			//alert($(this).attr("title"));
		});
	},
	
	slideContent: function(obj) {
		
		var margin = $(obj).parent().parent().find(".slide_content_treat").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
		//var title = $(".tab_item_treat").attr("title");
		//var title= $(".TreatmentSearch").find("div > span").attr("title");
		//var title = $('.tab_item_treat').attr('title');
		//alert(title);
		//alert($(obj).parent().parent().index());

			  //$(".tab_item").mousedown());
		

		
		$(obj).parent().parent().find(".tabslider_treat").stop().animate({
			marginLeft: margin + "px"
		}, {
			
			duration: 300
		});
	}
}


// Treatment function end 

$(document).ready(function() {
	TabbedContent.init();
	TabbedContent1.init();
});
