
$(document).ready(function(jQuery){
	//runde Ecken
	//	$(".corner1Top").corner("6px, top");
});

var iTools = {
	slider:{
		MAX_VISIBLE_TABS:3,
		SLIDE_CHANGE_SPEED:"normal",
		TAB_MOVE_SPEED:"normal",
		currentActiveTabIndex:1,
		tabWidth:150,
		activeTabPos: 150,
		slider: null,
		slideDiv: null,
		isMoving:false,
		init: function (sliderTarget) {
			var sliderConfig = this;
			this.slider = $(sliderTarget);
			this.slideDiv = this.slider.parents('div.slideDiv');
			this.slider.css("margin:0");
			this.slider.children('li').children('a').click(sliderConfig.tabClickHandler, sliderConfig);
			this.slideDiv.find('img.slideLeft').parent("a").click(function (e){
				sliderConfig.moveTabs(-1);		
				return false;
			});	
			this.slideDiv.find('img.slideRight').parent("a").click(function (e){
				sliderConfig.moveTabs(1);				
				return false;
			});	
			
		},
		tabClickHandler:function (e, sliderConfig){
			var me = $(this);
			me.blur();
			// if already active nothing happens
			var meIndex = me.parent("li").prevAll("li").length; // position of clicked tab
			return false;
		},
		showDivWithNumber: function (index){
			var sliderConfig = this;
			$("div.singleStudy div.high").fadeOut(sliderConfig.SLIDE_CHANGE_SPEED,function (){
				$(this).removeClass("high");
				$("div.singleStudy div.case").eq(index).fadeIn(sliderConfig.SLIDE_CHANGE_SPEED,function (){
					$(this).addClass("high");
				});
			});
		},
		moveTabs: function(direction){
			if (this.isMoving){
				return;
			}
			var sliderConfig = this;
			var tabUL = this.slider;
			this.isMoving = true;
			if (direction > 0){
//				tabUL.find("li").eq(2).addClass("high");
//				tabUL.find("li").eq(1).removeClass("high");
				tabUL.animate({
					marginLeft:"-"+sliderConfig.tabWidth
				},sliderConfig.TAB_MOVE_SPEED,function (){
					tabUL.hide();
					var firstLi = tabUL.children("li").eq(0).appendTo(tabUL);
					tabUL.css("marginLeft",0);
					tabUL.show();
					sliderConfig.isMoving = false;
				});
			}else {
				tabUL.hide();
				tabUL.find("li").eq(0).addClass("high");
				tabUL.find("li").eq(1).removeClass("high");
				tabUL.css("marginLeft",-sliderConfig.tabWidth);
				tabUL.children("li:last").prependTo(sliderConfig.slider);
				tabUL.show();
				tabUL.animate({
					marginLeft:0
				},sliderConfig.TAB_MOVE_SPEED,function (){
					sliderConfig.isMoving = false;
				});	
			}
		}
	},
	
	contentNavigator: {
		 currentPage: -1,
  		 allNaviLinks:null,
	
		displayPage: function(numberOfPage){
			if (numberOfPage < 0){
				numberOfPage = 0;
			}
		}
		
	}
	
};

jQuery(document).ready(function ($){
	// case-study-tabslider
	$("ul.slider").each(function (numSlider) {
		$.extend({}, iTools.slider).init(this);
	});
});
