function switchTab(obj, cTabId){
	var isHolder = obj.getAttribute('holder') ? true : false;
	cTabId = cTabId || obj.getAttribute('holder');
	var parent = obj;

	var activeSubpanels = {};
	activeSubpanels[cTabId] = true;

	while(parent && !parent.getAttribute('block')){
		if(parent.getAttribute('subpanel')){
			activeSubpanels[parent.getAttribute('subpanel')] = true;
		}
		parent = parent.parentNode;
	}
	var block = document.getElementById(parent.getAttribute('block'));


	var oinput = parent.getElementsByTagName('INPUT');
	oinput = oinput.length > 0 && oinput[0].name == 'activetab' ? oinput[0] : false;
	
	if(oinput){
		oinput.value = cTabId;
	}

	function f1(o){
		var children = o.childNodes;
		for(var i = 0; i < children.length; i++){
			var child = children[i];
			try{
				if(child.getAttribute('tab')){
					if(child.id == cTabId){
						child.style.display = '';
					}else{
						child.style.display = 'none';
					}
				}else{
					f1(child);
				}
			}catch(error){}
		}
	}
	f1(block);

	function f2(o){
		var children = o.childNodes;
		for(var i = 0; i < children.length; i++){
			var child = children[i];
			try{
				if(child.getAttribute('holder')){
					child.className = null;
				}else{
					if(child.getAttribute('subpanel')){
						child.style.display = activeSubpanels[child.getAttribute('subpanel')] ? '' : 'none';
					}
					f2(child);
				}
			}catch(error){}
		}
	}

	if(isHolder){
		f2(parent);
		obj.className = 'selected';
	}
}
