﻿var tab_current = false;
var tab_active_class = "tab-current";
var tab_class = "tab";

function switch_tab(obj){
	var id = obj ? obj.id : 0;
	if(!id)return true;
	if(tab_current){
		tab_hide(tab_current);
	}
	tab_show(id);
	return false;
}

function tab_hide(tab_id){
	var tab = document.getElementById(tab_id+"_tab");
	if(tab){
		tab.setAttribute("class", tab_class);
		tab.setAttribute("className", tab_class);
		tab = document.getElementById(tab_id+"_content");
		if(tab){
			tab.style['display'] = "none";
		}
	}
}

function tab_show(tab_id){
	var tab = document.getElementById(tab_id+"_tab");
	if(tab){
		tab.setAttribute("class", tab_active_class);
		tab.setAttribute("className", tab_active_class);
		tab = document.getElementById(tab_id+"_content");
		if(tab){
			tab.style['display'] = "block";
		}
		tab_current = tab_id;
	}else{
		tab_current = false;
	}
}

function switch_tab_id(id){
	return switch_tab(document.getElementById(id));
}

function init_tab(id){
	switch_tab_id(id);
}