	var __TABS = new Array();

	function removeSpace(r) {
		var ar = r.getElementsByTagName("*");
		var obj = r.firstChild;

		while (obj) {
			if (obj.nodeType == 3 && !obj.nodeValue.replace(/[ \t\r\n]+/g, "")) {
				obj.parentNode.removeChild(obj);
				obj = r.firstChild;
				continue;
			}
			else
			if (obj.hasChildNodes())
				removeSpace(obj);

			obj = obj.nextSibling;
		}

		return r;
	}

	function setTab(index, id) {
		for (var x = 0; x < __TABS.length; x++) {
			var tabId = "tab-box_" + index;
			
			if (__TABS[x].id == tabId) {
				for (y = 0; y < __TABS[x].count; y++) {
					var tab_box = document.getElementById(tabId + "_" + y + "_0");
					var tab_body = document.getElementById(tabId + "_" + y + "_1");

					if (y == 0) {
						tab_box.style.borderLeftWidth = '1px';
						tab_box.style.borderLeftStyle = "solid";
					}
					
					if (tabId + "_" + y == id) {
						tab_body.style.display = 'block';
						tab_box.className = "tab-box-ativo";
					}
					else {
						tab_body.style.display = 'none';
						tab_box.className = "tab-box-inativo";
					}
				}
			}
		}
	}

	function init_tab() {
		var arD = document.getElementsByTagName("div");

		for (var x = 0; x < arD.length; x++) {
			if (arD[x].getAttribute("classname") == "tab-box" || arD[x].getAttribute("class") == "tab-box") {
				if (!arD[x].getAttribute("id"))
					arD[x].setAttribute("id", "tab-box_" + x);

				var r = __TABS[__TABS.length] = {id:"tab-box_" + x, count:0};
				//arD[x].innerHTML = arD[x].innerHTML.replace(/[\n\r]/g, "").replace(/>[\W\t]+</g, "><");
				removeSpace(arD[x]);

				var obj = arD[x].getElementsByTagName("div")[0];
				var i = -1;
				var html_tabs = "";
				var div_conteudo = document.createElement("div");
				var __call = "";

				while (obj) {
					i++;

					r.count = i+1;

					var tabId = arD[x].getAttribute("id") + "_" + i;

					var active = obj.getAttribute("onactive") ? "__func = function(){"+
						obj.getAttribute("onactive")+"}" : "__func = function(){return true;}";
					
					html_tabs += "<td width=\"10%\" nowrap><div id=\"" + tabId + "_0\" onactive=\"" + 
						active + "\" onclick=\"this.ret = eval(unescape('"+escape(active)+"')); this.ret = this.ret(); if (!ret && (typeof ret != 'undefined')){return false;} setTab("+x+", '" + tabId + "')\">" + obj.firstChild.nodeValue + "</div></td>";

					if (!__call || (obj.getAttribute("active") == "true"))
						__call = "setTab("+x+", '" + tabId + "')";

					obj.firstChild.nextSibling.setAttribute("id", tabId + "_1");

					div_conteudo.appendChild(obj.firstChild.nextSibling);

					obj = obj.nextSibling;
				}
				
				arD[x].innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td>"+
					"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>" + html_tabs + "<td class=\"tab-box-td\" style=\"border-top-width: 0px; border-right-width: 0px\">&nbsp;</td></tr></table></td></tr><tr><td class=\"tab-body\">" + div_conteudo.innerHTML + "</td></tr></table>";
				eval(__call);
				arD[x].style.display = "block";
			}
		}
	}