/*
@@ Tab switch function.
@@ Author: Jin Ya Jun
@@ Date:   2009/12/14 16:04
*/

function Tab(_tabItems, _tabCots){
	this.tabItems = _tabItems;
	this.tabCots = _tabCots;
	this.tabItemOvCss = "defOv";
	this.tabItemSeCss = "defSe";
	this.forTabEle = "fortab";
	this.isChgItemCss = true;
	this.tabGrpEle = "";
}
Tab.prototype.Init = function(){
	var allItems = this.tabItems;
	var allCots = this.tabCots;
	var seCss = this.tabItemSeCss;
	var fortabEle = this.forTabEle;
	var isChgItemCss = this.isChgItemCss;
	this.tabItems.click(function(){
		var curitem = $(this);
		if(isChgItemCss){
			allItems.each(function(i, n){
				if($(n).parent().parent().attr(fortabEle) == curitem.parent().parent().attr(fortabEle)){
					n.id == curitem[0].id ? $(n).toggleClass(seCss, true) : $(n).toggleClass(seCss, false);
				}
			});
		}
		allCots.each(function(i, n){
			if($(n).parent().attr(fortabEle) == curitem.parent().parent().attr(fortabEle)){
				$(n).attr(fortabEle) == curitem[0].id ? $(n).show() : $(n).hide(); 
			}
		});
	});
}
Tab.prototype.ShowFormUrl = function(fidx, sidx){
	var fNav = $("div[fidx]");
	var sNav = $("div[fidx='" + fidx + "']").find("div[sidx]");
	var seCss = this.tabItemSeCss;
	fNav.each(function(){
		$(this).attr("fidx") == fidx ? $(this).show() : $(this).hide();
	});
	sNav.each(function(){
		if($(this).attr("sidx") == sidx){
			var currTit = $(this).parent().find("a[sidx]");
			currTit.toggleClass(seCss, false);
			currTit.prevObject.find("a[sidx='" + sidx + "']").toggleClass(seCss, true);
			$(this).show();
		}
		else{
			$(this).hide();
		}
	});
}
