// #####################################
// Funções feita por Diego Massarotte
// Contato: diego@apiceinternet.com.br
// #####################################

function verificaeap(id,status) {
	for (i = 2; i < 30; i++) {
			var div2 = "menusub" + i;
			divs2 = document.getElementById(div2);
			if (divs2) {
				if (divs2.style.visibility != "hidden") {
					divs2.style.visibility = "hidden";
				}
			} else {}
	}
	aparece_sub(id,status);
}

function aparece_sub(id,status) {
	if (id == "todas") {
		for (i = 1; i < 30; i++) {
			var div = "menusub" + i;
			divs = document.getElementById(div);
			if (divs) {
				divs.style.visibility = "hidden";
			}
		}
	}
	else {
		if (status != "aparece") {
			document.getElementById(id).style.visibility = "hidden";
		} else {
			document.getElementById(id).style.visibility = "visible";
		}
	}
}


function ajaxInit() {
	var xmlhttp ;
	try {
		xmlhttp = new XMLHttpRequest() ;
	} catch (ee) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			 xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	}
	return xmlhttp ;
}

function include(url,id,parametros) {
	mostra = document.getElementById(id) ? document.getElementById(id) : document.all[id];
	ajax = ajaxInit();
	if (ajax) {
		parametros = "?" + Math.ceil(Math.random() * 100000) + (parametros != null ? parametros : '');
		ajax.open('GET',url,true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto=unescape(ajax.responseText.replace(/\+/g," "));
					mostra.innerHTML = texto;
					extraiScript(texto);
				}
			}
		}
		ajax.send(null);
	}
}
function extraiScript(texto){   
    var ini, pos_src, fim, codigo;   
    var objScript = null;   
    ini = texto.indexOf('<script', 0)   
    while (ini!=-1){   
        var objScript = window.document.createElement("script");   
        pos_src = texto.indexOf(' src', ini)   
        ini = texto.indexOf('>', ini) + 1;   
        if (pos_src < ini && pos_src >=0){
            ini = pos_src + 4;    
            fim = texto.indexOf('.', ini)+4; 
            codigo = texto.substring(ini,fim);   
            codigo = codigo.replace("=","").replace(" ","").replace("\"","").replace("\"","").replace("\'","").replace("\'","").replace(">",""); 
            objScript.src = codigo;   
        }else{ 
            fim = texto.indexOf('</script>', ini);   
            codigo = texto.substring(ini,fim);    
            objScript.text = codigo;   
        }   
        window.document.body.appendChild(objScript);   
        ini = texto.indexOf('<script', fim);   
 
        objScript = null;   
    }   
}

function validateForm(form) {
	
	var formulario = document.getElementById(form);
	
	for (var i=0; i < formulario.length; i++) {
		if ((formulario.elements[i].value == "") && (formulario.elements[i].id != "fone") && (formulario.elements[i].id != "enviar") && (formulario.elements[i].id != "empresa") && (formulario.elements[i].id != "atuacao") && (formulario.elements[i].id != "outro_tipo")) {
			formulario.elements[i].focus();
			return false;	
		}
	}
	
	return true;
}

function validateForm2(form) {
	
	var formulario = document.getElementById(form);
	
	for (var i=0; i < formulario.length; i++) {
		if ((formulario.elements[i].value == "") && (formulario.elements[i].id != "enviar")) {
			formulario.elements[i].focus();
			return false;	
		}
	}
	
	return true;
}