// #####################################
// 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;
}




var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();
