
function SetCurCntr(id,subm,cur)
{
	var h = document.getElementById(id + "ct");
	if(h.value == cur)return false;
	if(subm)
	{ 
		h.value = cur;
		Submit();
		return true;
	}
	UnselectTab(id);
	h.value = cur;
	SelectTab(id);
	return false;
}

function UnselectTab(id)
{
	var h = document.getElementById(id + "ct");	
	if(h)
	{
		var OldBot = document.getElementById(id + "b" + h.value);	
		if(OldBot) OldBot.style.display = 'none';
	}
	var i = GetCurrentTd(id);
	var tabs = GetTabTr(id);
	tabs.cells[i].innerHTML = "<a href=\"#0\">" + tabs.cells[i].innerText + "</a>";
	tabs.cells[i].className = "tab_top_unsel_bg";
	tabs.cells[i].style.backgroundImage = "url(" + ImgDir + "unsel_bg.gif)";	
	if(i == 1)
	{
		tabs.cells[0].style.backgroundImage = "url(" + ImgDir + "beg_unsel.gif)";	
		tabs.cells[2].style.backgroundImage = "url(" + ImgDir + "unsel_unsel.gif)";
		tabs.cells[2].className = "tab_top_unsel_unsel";	
		tabs.cells[0].className = "tab_top_beg_unsel";		
	}
	else if(i > 1 && i < tabs.cells.length - 2)
	{
		tabs.cells[i + 1].style.backgroundImage = "url(" + ImgDir + "unsel_unsel.gif)";	
		tabs.cells[i - 1].style.backgroundImage = "url(" + ImgDir + "unsel_unsel.gif)";
		tabs.cells[i + 1].className = "tab_top_unsel_unsel";	
		tabs.cells[i - 1].className = "tab_top_unsel_unsel";		
	}
	else if(i == tabs.cells.length - 2)
	{
		tabs.cells[i - 1].style.backgroundImage = "url(" + ImgDir + "unsel_unsel.gif)";
		tabs.cells[i + 1].style.backgroundImage = "url(" + ImgDir + "unsel_end.gif)";
		tabs.cells[i + 1].className = "tab_top_unsel_end";
		tabs.cells[i - 1].className = "tab_top_unsel_unsel";		
	}
	
}

function SelectTab(id)
{
	var h = document.getElementById(id + "ct");
	if(h)
	{
		var NewBot = document.getElementById(id + "b" + h.value);
		if(NewBot) NewBot.style.display = 'inline';
	}
	var i = GetCurrentTd(id);
	var tabs = GetTabTr(id);
	tabs.cells[i].innerHTML = "<IMG border=\"0\" height=\"4\" width=\"7\" src=\"" + ImgArrow + "\">&nbsp;<B>" + tabs.cells[i].innerText.trim() + "</B>";
	tabs.cells[i].className = "tab_top_sel_bg";
	tabs.cells[i].style.backgroundImage = "url(" + ImgDir + "sel_bg.gif)";
	if(i == 1)
	{
		tabs.cells[0].style.backgroundImage = "url(" + ImgDir + "beg_sel.gif)";	
		tabs.cells[2].style.backgroundImage = "url(" + ImgDir + "unsel_sel.gif)";	
		tabs.cells[2].className = "tab_top_unsel_sel";	
		tabs.cells[0].className = "tab_top_beg_sel";
	}
	else if(i > 1 && i < tabs.cells.length - 2)
	{	
		tabs.cells[i + 1].style.backgroundImage = "url(" + ImgDir + "unsel_sel.gif)";	
		tabs.cells[i - 1].style.backgroundImage = "url(" + ImgDir + "sel_unsel.gif)";
		tabs.cells[i + 1].className = "tab_top_unsel_sel";	
		tabs.cells[i - 1].className = "tab_top_sel_unsel";	
	}
	else if(i == tabs.cells.length - 2)
	{
		tabs.cells[i - 1].style.backgroundImage = "url(" + ImgDir + "sel_unsel.gif)";			
		tabs.cells[i + 1].style.backgroundImage = "url(" + ImgDir + "end_sel.gif)";
		tabs.cells[i + 1].className = "tab_top_end_sel";		
		tabs.cells[i - 1].className = "tab_top_sel_unsel";
	}
}

function GetTabTr(id){return document.getElementById(id + "trTab");}

function Submit(){document.forms[0].submit();}

function GetCurrentTd(id)
{
	var h = document.getElementById(id + "ct")
	return parseInt(h.value) * 2 + 1;
}

