/*
 * 	--- --- Tab Navigator --- ---
 */

function tabNavigatorShowHide(box){
	var i=1;
	$("#"+box+" .boxTab").each(
		function () {
			if (!$(this).hasClass("boxTabAct")) {
				$("#trescTab"+i).hide();
			}else{
				$("#trescTab"+i).show();
			}
			i++;
		}
	);
}

function tabNavigatorInit(box){
	tabNavigatorShowHide(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");
				tabNavigatorShowHide(box);
			}
		}
	);
}


/*
 * 	--- --- Slide Navigator --- ---
 */
function animateSlideBox(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 slideNavigatorInit(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 () {
			animateSlideBox(box,-1);
		}
	);
	
	$("#"+box+" .boxSlideNavR").click(
		function () {
			animateSlideBox(box,1);
		}
	);
}


function closePopUp(box){
		$("#"+box).hide();
}

function hide_top_layer() {
	$("#TopLayer").hide();
	$("#TopLayer1").hide();
}; 

/*
 * 	--- --- wywołanie funkcjonalności serwisu --- ---
 */
$().ready(function(){
	tabNavigatorInit('box3');
	slideNavigatorInit('box2');
	
	//-- przesuwanie opcji w submenu
	
//	$("#menuBox .sm").each(
//		function () {
//			alert($(this).css("height"));
//		}
//	);
//	$("#menuBox .smA").each(
//		function () {
//			//
//		}
//	);
	
});


