var reTabs = new RegExp(/^tab_(.*)$/);

var tabEvents = function () {
	var lis = document.getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		if (reTabs.test(lis[i].id)) {
			lis[i].onclick = function () {
				Tab.show(this.id);
			}
			lis[i].style.cursor = "pointer";
		}
	}
}

var Tab={
	show:function(id) {
		var li = document.getElementById(id);
		if (li != null) {
			var ul = li.parentNode;
			var container = ul.parentNode;
			//  oculta "hermanos"
			Tab.hideChildren(container);
			// muestra el que toca
			var box = Tab.getBox(id);
			if (box != null) {
				box.style.display = "block";
			}
		}
	},
	hideChildren:function(nodo) {
		// tabs "hermanos", los oculta
		var boxes = nodo.getElementsByTagName("DIV");		
		for (var i=0; i<boxes.length; i++) {
			if (boxes[i].className == 'tabcontent') {
				boxes[i].style.display = "none";
			}
		}
	},
	getBox:function(tab_id){
		if (reTabs.test(tab_id)) {
			var id = RegExp.$1;
			var box = document.getElementById("secc_"+id);
			if (box != null) {
				return box;
			}
		}
		return null;
	}
}
