/*
 * 	--- --- Tab Navigator --- ---
 */

function tab_Navigator_Show_Hide(box){
	var i=1;
	$("#"+box+" .boxTab").each(
		function () {
			if (!$(this).hasClass("boxTabAct")) {
				$("#trescTab"+i).hide();
			}else{
				$("#trescTab"+i).show();
			}
			i++;
		}
	);
}

function tab_Navigator_Init(box){
	tab_Navigator_Show_Hide(box);
	
	$("#"+box+" .boxTab").hover(
		function () {
			if (!$(this).hasClass("boxTabAct")) {
				$(this).addClass("boxTabHover");
			}
		},
		function () {
			if ($(this).hasClass("boxTabHover")) {
				$(this).removeClass("boxTabHover");
			}
		}
	);
	
	$("#"+box+" .boxTab").click(
		function () {
			if (!$(this).hasClass("boxTabAct")) {
				$("#"+box+" .boxTab").each(
					function () {
						if ($(this).hasClass("boxTabAct")) {
							$(this).removeClass("boxTabAct");
						}
					}
				);
				$(this).addClass("boxTabAct");
				tab_Navigator_Show_Hide(box);
			}
		}
	);
}


/*
 * 	--- --- Slide Navigator --- ---
 */
function animate_Slide_Box(box,kierunek){
	var szeBox=parseInt($("#"+box+" .containerSlideTxt").css("width").substring(0,($("#"+box+" .containerSlideTxt").css("width").length-2)));
	var marginLeft=parseInt($("#"+box+" .containerSlideTxt").css("margin-left").substring(0,($("#"+box+" .containerSlideTxt").css("margin-left").length-2)));
	var szePoj=parseInt($("#"+box+" .boxSlideTxt").css("width").substring(0,($("#"+box+" .boxSlideTxt").css("width").length-2)));
	
	if(marginLeft<0){marginLeft=marginLeft*(-1);}
	
	var n_odl=0;
	if (kierunek==1){
		if(szeBox-marginLeft==szePoj){
			n_odl=0;
		}else{
			n_odl=(marginLeft+szePoj);
		}
	}else{
		if(marginLeft==0){
			n_odl=(szeBox-szePoj);
		}else{
			n_odl=(marginLeft-szePoj);
		}
	}
	
	if(n_odl>0){n_odl=n_odl*(-1);}
	$("#"+box+" .containerSlideTxt").animate({marginLeft: n_odl+'px'},"slow");
}

function slide_Navigator_Init(box){
	$("#"+box+" .boxSlideNavL").hover(
		function () {
			$(this).addClass("boxSlideNavLHover");
		},
		function () {
			$(this).removeClass("boxSlideNavLHover");
		}
	);
	
	$("#"+box+" .boxSlideNavR").hover(
		function () {
			$(this).addClass("boxSlideNavRHover");
		},
		function () {
			$(this).removeClass("boxSlideNavRHover");
		}
	);
	
	$("#"+box+" .boxSlideNavL").click(
		function () {
			animate_Slide_Box(box,-1);
		}
	);
	
	$("#"+box+" .boxSlideNavR").click(
		function () {
			animate_Slide_Box(box,1);
		}
	);
}

/*
 * 	--- --- wywołanie funkcjonalności serwisu --- ---
 */
$().ready(function(){
	tab_Navigator_Init('box3');
	slide_Navigator_Init('box2');
	$('#TopLayer').click(
		function() {
			$('#TopLayer').hide();
		}
	);
	

	
	
});





