//tab effects

var TabbedContent = {
	init: function() {	
		$(".tab_item").mousedown(function(e) {
		/*$(".tab_item").mouseover(function(e) {*/
			var background = $(this).parent().find(".moving_bg");
			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 700
			});
			//alert(e.target.name);
			var tempTargetDivName="'#"+e.target.name+"'";
//			$(tempTargetDivName).scrollTop(0);
			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(
		{opacity: 0.2, marginLeft: margin},
		1100,
		 function() {
			//if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i))) {
			//alert('ok');
			TabbedContent.showConten($(this));
			//}
		}
		);
	},
	
	showConten:function(obj){
		setTimeout(function () {								
			$(obj).parent().parent().find(".tabslider").stop().animate(
			{opacity: 1},1500
			);
		}, 400);
	}

}

$(document).ready(function() {
	TabbedContent.init();
});
