/*################################################################################
# GIEd - Gerenciador de Informação Educacional - Versão 2.0    	                 #
# Escola Nacional de Advocacia - ENA   OAB Conselho Federal    	                 #
# Atualizado em: 2008-03-06														 #
################################################################################*/

arrfunctions=new Array();

function fiadc(valor,trimt,vtag1,vtag2,vtag3,campo1){
	try{
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex){
			try{
				ajax = new XMLHttpRequest();
			}
			catch(exc) {
				alert("Esse navegador não tem recursos para uso desta página");
				ajax = null;
			}
		}
	}
	if(ajax) {
		idOpcao		= document.getElementById(vtag1);
		idOpcao0	= document.getElementById(vtag2);
		idOpcao1	= document.getElementById(vtag3);
		ajax.open("POST", "fscripts.php?t="+trimt+"&c1="+campo1, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
				idOpcao.innerHTML = "Carregando...";
			}
			if(ajax.readyState == 4 ) {
				var temp = new Array();
				temp = unescape(ajax.responseText).split("|",2);
				if (temp[0]!="&nbsp;") idOpcao.style.display='';
				if(temp[1]==1){
					history.back();
				} else if(temp[1]=='login'){
					window.location.href='../conteudo';
				} else {
					if(vtag1=='imsgaviso' || temp[1]=='msg'){
						if((temp[1]).substring(0,5)=="campo"){
							document.getElementById(temp[1]).attributes["class"].value='campodestaque';
							document.getElementById('l'+temp[1]).style.backgroundColor='#fdf8ab';
							document.getElementById(temp[1]).focus();
						}
						idOpcao.innerHTML = '';
						/*idOpcao.innerHTML = 
						'<br style="clear:both; line-height:30px;" />'
						+"<span style='font-size:11px; color:#777777;'>"+temp[0]+"</span>";*/
						vredirect='';
						if(document.getElementById('btbuscar')){
							if(document.getElementById('btbuscar').value != 'Todos'){
								vredirect=setTimeout("window.location.reload();",12000);
							}
						}
						idOpcao = document.getElementById('imsgaviso');
						idOpcao.style.display='block';
						idOpcao.innerHTML = temp[0] + '<br><img src="../imagens/ok0.gif" ' + 
						'align="middle" id="ok" onMouseOver="style.cursor=\'pointer\';fimgon(this,this.id);" ' +
						'onMouseOut="fimgoff(this,this.id)" ' +
						'alt="Fechar Mensagem!" ' +
						'onClick="idOpcao.style.display=\'none\';'+
						'if(vredirect)clearTimeout(vredirect);" onLoad="ftimeout(\'imsgaviso\');"> ' + 
						'&nbsp;&nbsp;&nbsp;&nbsp;';
					} else {
						idOpcao.innerHTML = temp[0];
					}
				}
				if(arrfunctions.length > 0){
					setTimeout(arrfunctions.shift(),500);
				}
			}
		}
		var params = "vdados="+valor;
		ajax.send(params);
	}
}

function fexecute(funcao){
	if(arrfunctions.length == 0){
		eval(funcao);
	} else {
		if ((arrfunctions.toString()).indexOf(funcao)==-1)
		arrfunctions.push(funcao);
	}
}

function FormataNumero(e){
	var keynum;
	var keychar;
	var numcheck;

	if(window.event){ // IE
		keynum = e.keyCode;
	} else if(e.which){ // Netscape/Firefox/Opera
		keynum = e.which;
	}
	
    if (keynum < 48 && keynum !=8 || keynum > 57){
		return false;
	} else {
		return true;
	}
}
