/**
 * nxsTabs functions
 * @author Mike Bertram
 * @copyright NEXUS Netsoft GmbH
 * @version 0.1
 */
$(document).ready(function(){	
	var $iCntTabSystems = 0;
	
	window.changeActivebox = function(actBox, tabId, oTab){
		$(".tsid__frm_"+tabId).attr('activeBox', actBox);
		$(".tsid__cnt_"+tabId+" .nxsTabBox").each(function (){
			$contId = $(this).attr('contid');
			if ($contId == $(".tsid__frm_"+tabId).attr('activeBox'))
				$(this).show();
			else	
				$(this).hide();
		});
		clearActives(oTab.attr("tsid"));
		oTab.addClass("active");
	}
	
	window.clearActives = function(tabId){
		$(".tsid__lks_"+tabId+" a").each(function (){
			if ($(this).hasClass("active"))
				$(this).removeClass("active");	
		});
	}
		
	$(".nxsTabFrame").each(function (){		
		$(this).addClass("tsid__frm_"+$iCntTabSystems);
		$(this).attr("tsid", $iCntTabSystems);
		$(".tsid__frm_"+$iCntTabSystems+" .nxsTabLinks").addClass("tsid__lks_"+$iCntTabSystems);
		$(".tsid__frm_"+$iCntTabSystems+" .nxsTabLinks").attr("tsid", $iCntTabSystems);
		$(".tsid__frm_"+$iCntTabSystems+" .nxsTabContent").addClass("tsid__cnt_"+$iCntTabSystems);
		$(".tsid__frm_"+$iCntTabSystems+" .nxsTabContent").attr("tsid", $iCntTabSystems);		
		$(".tsid__lks_"+$iCntTabSystems+" a").each(function (){
			$(this).css("cursor", "pointer");
			$(this).attr("tsid", $iCntTabSystems);
			if ($(this).hasClass("active"))
			{
				changeActivebox($(this).attr("contid"), $(this).attr("tsid"), $(this));
			}
		});	
		$(".tsid__lks_"+$iCntTabSystems+" a").click(function (){
			changeActivebox($(this).attr("contid"), $(this).attr("tsid"), $(this));			
		});
		$iCntTabSystems++;
	});
	
});