// JavaScript Document

	/* ----------------------------  SUMÁRIO DAS FUNÇÕES  -------------------------------//
	01. FormataData(Data): dd/mm/aaaa -> aaaammdd ou aaaammdd -> dd/mm/aaaa
	02. SoNum(): Só permite a digitação de números no campo
	03. ValorIndevido(FormCampo, Valor, Alert): Critica entradas invalidas
	04. currencyFormat(fld, milSep, decSep, e): Mascara valores monetários
	05. FormataNumero: Converte de XX.XXX.XXX,XX para XXXXXXXX.XX e vice-versa
	06. DateFormat(vDateName, vDateValue, e, dateCheck, dateType): faz a validação de datas
	/------------------------------------------------------------------------------------*/

	

	/*--------------  Função de formatação de data  ----------------
01.
	Esta função Recebe como parâmetros uma data. Esta data pode ser 
	passada de duas maneiras. Quando passada no formato AAAAMMDD, a 
	função a converte para DD/MM/AAAA. Já na outra situação, onde a 
	função recebe a data no formato DD/MM/AAAA, a data é convertida
	para o formato AAAAMMDD.
	Para chamar a função, use varDataFormatada = FormataData(varData)
	onde varDataFormatada é a varíavel que receberá a data formatada
	e varData é a variável que contém a data a ser formatada.      */
	function FormataData(Data){
		Data = Data.toString();
		(Data.indexOf("/")!=-1)?Data = Data.slice(6,10) + Data.slice(3,5) + Data.slice(0,2):Data = Data.slice(6,8) + "/" + Data.slice(4,6) + "/" + Data.slice(0,4);
		return Data;
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	/*------  Funções que só permite a digitação de números  --------
02.
	Esta função verifica os valores digitados para entrada no campo. 
	Só permite a digitação de números  
	Para chamar a função use o método onKeyPress do campo HTML.
	Ex.<input name="SomenteNum" type="text" onkeypress="SoNum();">  */
	function SoNum(){
	   if((event.keyCode < 48) || (event.keyCode > 57))event.returnValue = false; 
	}
	//-------------------------------------------------------------//

	
	/*------ Funções que verifica se está certo ou não o valor no campo -----
09.	
	Estas funções fazem a validação de diversos valores como email, cep, cpf, cnpj, rg
	****************************************************************************** */
	function EmailInvalido(form) {
		if(!validaemail(form.value)) {
			alert("Email Inválido!\nInforme um email válido e tente novamente.");
			form.focus();
			return true;
		}else{
			return false;
		}
	}
	// Testa um email no formato teste@testando. + com.br (3.2) ou + .com (3) ou + .br (2) //
	// NÃO podem comecar com numeros. Antes da @ podem contar numeros letras, pontos e undescore //
	// O Dominio pode conter caracteres e numeros porem os seus sufixos apenas caracteres //
	function validaemail(email) {
		var objRegExp  = /^[A-Za-z]([\w\.]*)@([A-Za-z0-9\.]*)\.(([A-Za-z]{3}\.[A-Za-z]{2}$)|([A-Za-z]{3}$)|([a-z]{2}$))/i ;
		return objRegExp.test(email);
	}
	
	function ValidaSenha(senha,cSenha){
		if(ValorIndevido(senha,"","Digite sua senha!"))return true;
		if(form.cSenha.value != form.senha.value){
			alert("A senha não confere com a confirmação!\nDigite novamente senha e confirmação.");
			cSenha.value = "";
			senha.value = "";
			senha.focus();
			return true;
		}
		return false
	}
		
	function ValidaCpf(campo) {
		cpf = campo.value;
		while(cpf.indexOf(".") >= 0){
			cpf = cpf.replace(".","");
		}
		if(cpf.indexOf("-") >= 0){
			cpf = cpf.replace("-","");
		}
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF!\n"; 
			var nonNumbers = /\D/;
			if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!\n"; 
			if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!\n"
			}
			var a = [];
			var b = new Number;
			var c = 11;
			for (i=0; i<11; i++){
				a[i] = cpf.charAt(i);
				if (i < 9) b += (a[i] * --c);
			}
			if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x 
		}
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] * c--); 
			if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
			if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro +="Digito verificador com problema!\n";
		}
		if (erro.length > 0){
			alert("CPF inválido!\n"+erro+"Digite novamente!");
			campo.value = ""
			campo.focus();
			return true;
		}
		return false;
	}

	/*- Funcão que atribui um ou vários valores especificados para o select -/
10.
	********************************************************************
	Esta função carrega em select os valores especificados em um array.
	Quando se tem um select multivaloravel está função é capaz de 
	selecionar diversos valores especificados em uma array.
	Esta função recebe dois parametros:
		lista - é objeto select que receberá os valores.
		valores - recebe um array com os valores.
	Exemplo de como chamar a função:
		function carregar(){
			generos = ("1","2","3");
			carregarSelect(form.gnr,valores)
		}
	********************************************************************/
	function carregarSelect(lista,valores){
		for(i=0;i<=lista.length;i++){
			if(i <= valores.length){
				var t = 0;
				while(valores[i] != lista.options[t].value){
					t++;
				}
				lista.options[t].selected = true;	 	
			}else{break;}	 	
		}
	}
	
	/*-  Funções que verifica se o valor de determinado campo é X  -/
03.
	Esta função verifica se o valor digitado pelo usuário em um campo
	é INVÁLIDO. Caso o valor seja inválido digitado, a função emite
	um alert com a mensagem de erro, dá o foco no campo com valor 
	inválido e retorna true se for um valor indevido, caso contrário
	a função retorna false.
	Esta função deve ser chamada dentro de outra função. Essa outra
	função fará a validação do envio de um formulário com base no
	teste na função ValorIndevido(FormCampo, Valor, Alert).
	Esta função recebe 3 parâmetros. São eles:
		* FormCampo: Recebe o endereço do campo do formulário a ser
		  validado.
		* Valor: Recebe o valor do campo a ser validade.
		* Alert: Recebe a mensagem de erro que deve ser emitida caso
		  o valor digitado seja inválido
		  
	Exemplo de chamda da função dentro do HTML:
	********  Código HTML principal (fora deste arquivo)  **********	
	function Valida(){
		if(ValorIndevido(Form.Nome, "", "O campo Nome não pode ser deixado em branco!"))return false;
		return true;
	}
	***********************************************************	 */
	function ValorIndevido(FormCampo, Valor, Alert){
		if(FormCampo.value==Valor){
			alert(Alert);
			FormCampo.focus();
			return true;
		}
		return false;
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	/*---  Função que cria uma Máscara para valores monetários  -----
04.
	Esta função formata os valores digitados inserindo pontos e vírgula
	automaticamente no valor digitado.
	Para chamar a função use o método onKeyPress do campo HTML.  Ex.:
	<input name="Valor" type="text" value="0,00" onKeyPress="return(currencyFormat(this,'.',',',event))" onFocus="if(this.value=='0,00')this.value=''" onBlur="if(this.value=='')this.value='0,00';">  */
	function currencyFormat(fld, milSep, decSep, e){
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		
		if (whichCode == 13) return true;  // Enter
		key = String.fromCharCode(whichCode);  // Get key value from key code		
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key		
		len = fld.value.length;		
		for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;		
		aux = '';		
		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
		aux += key;
		len = aux.length;
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		if (len > 2){
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--){
				if (j == 3){
					aux2 += milSep;
					j = 0;
				}
				aux2 += aux.charAt(i);
				j++;
			}
			fld.value = '';
			len2 = aux2.length;
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
			fld.value += decSep + aux.substr(len - 2, len);
		}
		return false;
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	/*------  Funções de conversão de valores "Mascarados" para -----/
	//------------  valores numéricos, e vice-versa -----------------/
05.
	Esta função recebe como parâmetro um valor e analisa se ela identifica
	o tipo de valor passado, se é uma string(X.XXX.XXX,XX) ou se é um
	número (XXXXXXX.XX). Se for uma string passada pela função acima
	<function currencyFormat(fld, milSep, decSep, e)>, é feita a conversão
	desse valor "mascarado" para um valor numérico, caso contrário, ele 
	converte um valor numérico para um valor "mascarado"
	*************************************************************	 */
	function FormataNumero(Valor){
		if(Valor.indexOf(",") != -1){ //Se for uma string, transformaem número		
			var Num; //String -> Número (X.XXX.XXX,XX -> XXXXXXX.XX)
			Num = (Valor.length - 3)/4;
			for(i=0;i<Num;i++){
				Valor = Valor.replace(".", ""); // retirando todos os pontos
			}
			Valor = Valor.replace(",", "."); // trocando a vírgula por ponto
			Valor = parseFloat(Valor);
			return Valor;
		}else{ //Se for um número (XXXXXXX.XX), transforma em string (X.XXX.XXX,XX)	
			var QtdPontos, antes, depois, TamNum, inc, cents;
			cents = Math.round((Valor - parseInt(Valor)) *100)/100;
			Valor = Valor.toString();		
			Valor = Valor.replace(".", ","); // trocando o ponto por vírgula
			(Valor.indexOf(",") == -1) ? TamNum = Valor.length : TamNum = Valor.indexOf(",");
			QtdPontos = parseInt((TamNum - 1) / 3);
			inc = 0; //incremento
			
			if(QtdPontos==0){
				Valor = parseInt(Valor);
			}else{
				for(i=0; i<QtdPontos; i++){	
					depois = Valor.slice(((TamNum-3)-inc), TamNum);
					antes = Valor.slice(0,((TamNum-3)-inc));	
					Valor = antes + "." + depois;			
					inc = inc + 4;
					TamNum = Valor.length;
				}
			}
			cents = cents.toString();
			cents = cents.slice(2,(cents.length));
			(cents==0)?cents="00":(cents.length==1)?cents = cents+"0":cents=cents;
			return (Valor + "," + cents);
		}
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	
	
	
	/*---------------  Função de validação de data  -----------------
06.
	Esta função verifica a data digitada e emite um alerta caso a 
	data digitada não seja válida. Já possui uma máscara para entrada
	das barras de separação. O formato da data de entrada é dd/mm/aaaa.
	É interessante usar esta função em conjunto com a função soNum(), 
	visando, dessa forma, impedir que o usuário entre com valores diferentes
	de números.
	Para chamar a função use o método onKeyPress do campo HTML.  Ex.:
	<input name="Data" type="text" onfocus="javascript:vDateType='3'" onblur="DateFormat(this,this.value,event,true,'3')" onkeypress="SoNum();DateFormat(this,this.value,event,false,'3');" maxLength="10">  */
	var isNav4 = false, isNav5 = false, isIE4 = false
	var strSeperator = "/"; 
	var vDateType = 3; 
	var vYearType = 4;
	var vYearLength = 2; 
	var err = 0; 
	if(navigator.appName == "Netscape"){
		if (navigator.appVersion < "5"){
			isNav4 = true;
			isNav5 = false;
		}else{
			if (navigator.appVersion > "4") {
				isNav4 = false;
				isNav5 = true;
			}
		}
	}else{
		isIE4 = true;
	}
	
	function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
		vDateType = dateType;
		if (vDateValue == "~") {
			alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
			vDateName.value = "";
			vDateName.focus();
			return true;
		}
		var whichCode = (window.Event) ? e.which : e.keyCode;
		if (vDateValue.length > 8 && isNav4) {
			if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1)) return true;
		}
		var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
		if (alphaCheck.indexOf(vDateValue) >= 1) {
			if (isNav4) {
				vDateName.value = "";
				vDateName.focus();
				vDateName.select();
				return false;
			}else{
				vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
				return false;
			}
		}
		if (whichCode == 8) 
			return false;
		else{
			var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
			if (strCheck.indexOf(whichCode) != -1) {
				if (isNav4) {
					if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
						alert("A data informada é inválida!!");
						vDateName.value = "";
						vDateName.focus();
						vDateName.select();
						return false;
					}
					if (vDateValue.length == 6 && dateCheck) {
						var mDay = vDateName.value.substr(2,2);
						var mMonth = vDateName.value.substr(0,2);
						var mYear = vDateName.value.substr(4,4)
						if (mYear.length == 2 && vYearType == 4) {
							var mToday = new Date();
							var checkYear = mToday.getFullYear() + 30; 
							var mCheckYear = '20' + mYear;
							if (mCheckYear >= checkYear)
								mYear = '19' + mYear;
							else
								mYear = '20' + mYear;
						}
						var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
						if (!dateValid(vDateValueCheck)) {
							alert(" A data informada é inválida");
							vDateName.value = "";
							vDateName.focus();
							vDateName.select();
							return false;
						}
						return true;
					}else{
						if (vDateValue.length >= 8 && dateCheck) {
							if (vDateType == 1){
								var mDay = vDateName.value.substr(2,2);
								var mMonth = vDateName.value.substr(0,2);
								var mYear = vDateName.value.substr(4,4)
								vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
							}
							if (vDateType == 2){
								var mYear = vDateName.value.substr(0,4)
								var mMonth = vDateName.value.substr(4,2);
								var mDay = vDateName.value.substr(6,2);
								vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
							}
							if (vDateType == 3){
								var mMonth = vDateName.value.substr(2,2);
								var mDay = vDateName.value.substr(0,2);
								var mYear = vDateName.value.substr(4,4)
								vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
							}
							var vDateTypeTemp = vDateType;
							vDateType = 1;
							var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
							if (!dateValid(vDateValueCheck)) {
								alert("A data informada é inválida!!");
								vDateType = vDateTypeTemp;
								vDateName.value = "";
								vDateName.focus();
								vDateName.select();
							return false;
							}
							vDateType = vDateTypeTemp;
							return true;
						}else{
							if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
								alert("A data informada é inválida!!");
								vDateName.value = "";
								vDateName.focus();
								vDateName.select();
								return false;
							}
						}
					}
				}else{
					if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
						alert("A data informada é inválida!!");
						vDateName.value = "";
						vDateName.focus();
						return true;
					}
					if (vDateValue.length >= 8 && dateCheck) {
						if (vDateType == 1){
							var mMonth = vDateName.value.substr(0,2);
							var mDay = vDateName.value.substr(3,2);
							var mYear = vDateName.value.substr(6,4)
						}
						if (vDateType == 2){
							var mYear = vDateName.value.substr(0,4)
							var mMonth = vDateName.value.substr(5,2);
							var mDay = vDateName.value.substr(8,2);
						}
						if (vDateType == 3){
							var mDay = vDateName.value.substr(0,2);
							var mMonth = vDateName.value.substr(3,2);
							var mYear = vDateName.value.substr(6,4)
						}
						if (vYearLength == 4) {
							if (mYear.length < 4) {
								alert("A data informada é inválida!!");
								vDateName.value = "";
								vDateName.focus();
								return true;
							}
						}
						var vDateTypeTemp = vDateType;
						vDateType = 1;
						var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
						if (mYear.length == 2 && vYearType == 4 && dateCheck) {
							var mToday = new Date();
							var checkYear = mToday.getFullYear() + 30; 
							var mCheckYear = '20' + mYear;
							if (mCheckYear >= checkYear)mYear = '19' + mYear;
							else mYear = '20' + mYear;
							vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
							if (vDateTypeTemp == 1)vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
							if (vDateTypeTemp == 3)vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
						}
						if (!dateValid(vDateValueCheck)) {
							alert("A data informada é inválida!!");
							vDateType = vDateTypeTemp;
							vDateName.value = "";
							vDateName.focus();
							return true;
						}
						vDateType = vDateTypeTemp;
						return true;
					}else{
						if (vDateType == 1) {
							if (vDateValue.length == 2)vDateName.value = vDateValue+strSeperator;
							if (vDateValue.length == 5)vDateName.value = vDateValue+strSeperator;
						}
						if (vDateType == 2) {
							if (vDateValue.length == 4)vDateName.value = vDateValue+strSeperator;
							if (vDateValue.length == 7)vDateName.value = vDateValue+strSeperator;
						} 
						if (vDateType == 3) {
							if (vDateValue.length == 2)vDateName.value = vDateValue+strSeperator;
							if (vDateValue.length == 5)vDateName.value = vDateValue+strSeperator;
						}
						return true;
					}
				}
				if (vDateValue.length == 10&& dateCheck) {
					if (!dateValid(vDateName)) {
						alert("A data informada é inválida!!");
						vDateName.focus();
						vDateName.select();
					}
				}
				return false;
			}else{
				if (isNav4) {
					vDateName.value = "";
					vDateName.focus();
					vDateName.select();
					return false;
				}else{
					vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
					return false;
				}
			}
		}
	}
	
	function dateValid(objName) {
		var strDate;
		var strDateArray;
		var strDay;
		var strMonth;
		var strYear;
		var intday;
		var intMonth;
		var intYear;
		var booFound = false;
		var datefield = objName;
		var strSeparatorArray = new Array("-"," ","/",".");
		var intElementNr;
		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
		strMonthArray[1] = "Feb";
		strMonthArray[2] = "Mar";
		strMonthArray[3] = "Apr";
		strMonthArray[4] = "May";
		strMonthArray[5] = "Jun";
		strMonthArray[6] = "Jul";
		strMonthArray[7] = "Aug";
		strMonthArray[8] = "Sep";
		strMonthArray[9] = "Oct";
		strMonthArray[10] = "Nov";
		strMonthArray[11] = "Dec";
		strDate = objName;
		if (strDate.length < 1) {
			return true;
		}
		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++){
			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1){
				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3){
					err = 1;
					return false;
				}else{
					strDay = strDateArray[0];
					strMonth = strDateArray[1];
					strYear = strDateArray[2];
				}
				booFound = true;
			}
		}
		if (booFound == false){
			if (strDate.length>5){
				strDay = strDate.substr(0, 2);
				strMonth = strDate.substr(2, 2);
				strYear = strDate.substr(4);
			}
		}
		if (strYear.length == 2) {
			strYear = '20' + strYear;
		}
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
		intday = parseInt(strDay, 10);
		if (isNaN(intday)) {
			err = 2;
			return false;
		}
		intMonth = parseInt(strMonth, 10);
		if (isNaN(intMonth)) {
			for (i = 0;i<12;i++) {
				if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
					intMonth = i+1;
					strMonth = strMonthArray[i];
					i = 12;
				}
			}
			if (isNaN(intMonth)) {
				err = 3;
				return false;
			}
		}
		intYear = parseInt(strYear, 10);
		if (isNaN(intYear)) {
			err = 4;
			return false;
		}
		if (intMonth>12 || intMonth<1) {
			err = 5;
			return false;
		}
		if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)){
			err = 6;
			return false;
		}
		if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
			err = 7;
			return false;
		}
		if (intMonth == 2) {
			if (intday < 1) {
				err = 8;
				return false;
			}
			if (LeapYear(intYear) == true) {
				if (intday > 29) {
					err = 9;
					return false;
				}
			}else{
				if (intday > 28) {
					err = 10;
					return false;
				}
			}
		}
		return true;
	}

	function LeapYear(intYear) {
		if (intYear % 100 == 0) {
			if (intYear % 400 == 0) { return true; }
		}else{
			if ((intYear % 4) == 0) { return true; }
		}
		return false;
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/*---------------------------  Tooltip ------------------------------/
07.
	Exibe um tooltip no link.
	Para usar a função deve-se observar alguns códigos que vão devem ser
	implementados fora do escopo da função descrita.
	1. Incluir uma chamada no <body> do html -> <body onmousemove="overhere()">
	2. Criar um div logo após o <body onmouseover="overhere()"> -> <div id="ToolTip"></div>
	3. Definir no .CSS do documento as classes a seguir:
		.tooltiptitle{COLOR: #FFFFFF; TEXT-DECORATION: none; CURSOR: Default; font-family: arial; font-weight: bold; font-size: 8pt}
		.tooltipcontent{COLOR: #000000; TEXT-DECORATION: none; CURSOR: Default; font-family: arial; font-size: 8pt}
		#ToolTip{position:absolute; width: 100px; top: 0px; left: 0px; z-index:4; visibility:hidden;}
	Para chamar a função utilize:
		<a href="#" onMouseover="EnterContent('ToolTip','Título:','Texto descritivo'); Activate();" onMouseout="deActivate()">Link</a>
	*********************************************************************/
	var ie = document.all ? 1 : 0
	var ns = document.layers ? 1 : 0

	if(ns){doc = "document."; sty = ""}
	if(ie){doc = "document.all."; sty = ".style"}
	var initialize = 0
	var Ex, Ey, topColor, subColor, ContentInfo
	if(ie){
		Ex = "event.x"
		Ey = "event.y"
		topColor = "#6C94BF" //altera a cor do fundo do título
		subColor = "#F7F7F7" //altera a cor do fundo do conteúdo
	}
	if(ns){
		Ex = "e.pageX"
		Ey = "e.pageY"
		window.captureEvents(Event.MOUSEMOVE)
		window.onmousemove=overhere
		topColor = "#008DC2" //altera a cor do fundo do título
		subColor = "#F7F7F7" //altera a cor do fundo do conteúdo
	}

	function MoveToolTip(layerName, FromTop, FromLeft, e){
		FromTop = eval(FromTop) - 7 //altera a posição Y do Tooltip
		if(ie){eval(doc + layerName + sty + ".top = "  + (eval(FromTop) + document.body.scrollTop))}
		if(ns){
			eval(doc + layerName + sty + ".top = "  +  eval(FromTop))
		}
		eval(doc + layerName + sty + ".left = " + (eval(FromLeft) - 185))  //Altera a posição X do ToolTip
	}

	function ReplaceContent(layerName){
		if(ie){document.all[layerName].innerHTML = ContentInfo}
		if(ns){
			with(document.layers[layerName].document) 
			{ 
				open(); 
				write(ContentInfo); 
				close(); 
			}
		}
	}

	function Activate(){initialize=1}
	function deActivate(){initialize=0}
	function overhere(e){
		if(initialize){
			MoveToolTip("ToolTip", Ey, Ex, e)
			eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
		}else{
			MoveToolTip("ToolTip", 0, 0)
			eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
		}
	}
	
	function EnterContent(layerName, TTitle, TContent){
		ContentInfo = '<table border="0" width="175" cellspacing="0" cellpadding="0" class="borda">'+
		'<tr><td width="100%" bgcolor="#004762">'+
		'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
		'<tr><td width="100%" bgcolor='+topColor+'>'+
		'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+
		'<tr><td width="100%">'+
		'<font class="tooltiptitle">'+TTitle+'</font>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'<tr><td width="100%" bgcolor='+subColor+'>'+
		'<table border="0" width="90%" cellpadding="0" cellspacing="1" align="center">'+
		'<tr><td width="100%">'+
		'<font class="tooltipcontent">'+TContent+'</font>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'</table>';
		ReplaceContent(layerName)
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	/*---------------------------  Restringe entrada de valores  ------------------------------/
08.
	Para chamar a função utilize insira OnKeyPress="return NomeDaFunção();" no input 
	que ser quer restringir a entrada de valores
	*********************************************************************/
	function AreaTexto(){   //     OnKeyPress="return AreaTexto();"
		var tecla = event.keyCode; 
		if(tecla > 64 && tecla < 91) return true;  //LETRAS MAIUSCULAS 
		else if(tecla > 96 && tecla < 123) return true;  //LETRAS MINUSCULAS 
		else if(tecla > 47 && tecla < 58) return true; // numeros de 0 a 9
		else if(tecla == 32) return true; //	(< >)	espaço
		else if(tecla == 33) return true; //	( ! )	exclamação
		else if(tecla == 36) return true; //	( $ )	cifrão
		else if(tecla == 37) return true; //	( % )	percente
		else if(tecla == 38) return true; //	( & ) 	e comercial
		else if(tecla == 42) return true; // 	( * ) 	asterísco
		else if(tecla == 43) return true; // 	( + ) 	soma
		else if(tecla == 44) return true; // 	( , ) 	vírgula
		else if(tecla == 45) return true; // 	( - ) 	hífen
		else if(tecla == 46) return true; // 	( . )	ponto
		else if(tecla == 47) return true; // 	( / ) 	barra
		else if(tecla == 58) return true; // 	( ; ) 	dois pontos
		else if(tecla == 59) return true; // 	( ; ) 	ponto e vírgula
		else if(tecla == 61) return true; // 	( = ) 	igualdade
		else if(tecla == 63) return true; // 	( ? )	interrogação
		else if(tecla == 64) return true; // 	( @ )	arroba
		else if(tecla == 92) return true; // 	( \ )	barra invertida
		else if(tecla == 95) return true; // 	( _ )	underscore
		else if(tecla == 40 || tecla == 41) return true; // (abre e fecha parênteses)
		else if(tecla == 91 || tecla == 93) return true; // (abre e fecha colchetes)
		else if(tecla == 123 || tecla == 125) return true; // (abre e fecha chaves)
		else if(tecla == 231 || tecla == 199) return true; // (ç) ou (Ç)
		else if(tecla == 225 || tecla == 193) return true; // (á) ou (Á)		
		else if(tecla == 227 || tecla == 195) return true; // (ã) ou (Ã)
		else if(tecla == 226 || tecla == 194) return true; // (â) ou (Â)				
		else if(tecla == 233 || tecla == 201) return true; // (é) ou (É)		
		else if(tecla == 224 || tecla == 202) return true; // (ê) ou (Ê)		
		else if(tecla == 237 || tecla == 205) return true; // (í) ou (Í)
		else if(tecla == 243 || tecla == 211) return true; // (ó) ou (Ó)		
		else if(tecla == 244 || tecla == 212) return true; // (ô) ou (Ô)
		else if(tecla == 245 || tecla == 213) return true; // (õ) ou (Õ)
		else if(tecla == 250 || tecla == 218) return true; // (ú) ou (Ú)
		else if(tecla == 252 || tecla == 220) return true; // (ü) ou (Ü)	
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false;  // backspace 				
			else return true; 				
		} 
	}
	
	function FoneFax() {    //     OnKeyPress="return FoneFax();"
		var tecla = event.keyCode; 
		if(tecla > 47 && tecla < 58) return true; // numeros de 0 a 9
		else if(tecla == 32) return true; //	( ! )	espaço
		else if(tecla == 45) return true; // 	( - ) 	hífen
		else if(tecla == 40 || tecla == 41) return true; // (abre e fecha parênteses)
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false;  // backspace 				
			else return true; 				
		} 
	}
	
	function Letras() {     //     OnKeyPress="return Letras();"
		var tecla = event.keyCode; 
		if(tecla > 64 && tecla < 91) return true;  //LETRAS MAIUSCULAS 
		else if(tecla > 96 && tecla < 123) return true;  //LETRAS MINUSCULAS
		else if(tecla == 231 || tecla == 199) return true; // (ç) ou (Ç)
		else if(tecla == 225 || tecla == 193) return true; // (á) ou (Á)		
		else if(tecla == 227 || tecla == 195) return true; // (ã) ou (Ã)
		else if(tecla == 226 || tecla == 194) return true; // (â) ou (Â)				
		else if(tecla == 233 || tecla == 201) return true; // (é) ou (É)		
		else if(tecla == 234 || tecla == 202) return true; // (ê) ou (Ê)		
		else if(tecla == 237 || tecla == 205) return true; // (í) ou (Í)
		else if(tecla == 243 || tecla == 211) return true; // (ó) ou (Ó)		
		else if(tecla == 244 || tecla == 212) return true; // (ô) ou (Ô)
		else if(tecla == 245 || tecla == 213) return true; // (õ) ou (Õ)
		else if(tecla == 250 || tecla == 218) return true; // (ú) ou (Ú)
		else if(tecla == 252 || tecla == 220) return true; // (ü) ou (Ü)
		else if(tecla == 32) return true; //	( ! )	espaço
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false;  // backspace 				
			else return true; 				
		} 
	}
	
	function Alpha() {     //     OnKeyPress="return Alpha();"
		var tecla = event.keyCode; 
		if(tecla > 64 && tecla < 91) return true;  //LETRAS MAIUSCULAS 
		else if(tecla > 96 && tecla < 123) return true;  //LETRAS MINUSCULAS 
		else if(tecla > 47 && tecla < 58) return true; // numeros de 0 a 9
		else if(tecla == 231 || tecla == 199) return true; // (ç) ou (Ç)
		else if(tecla == 225 || tecla == 193) return true; // (á) ou (Á)		
		else if(tecla == 227 || tecla == 195) return true; // (ã) ou (Ã)
		else if(tecla == 226 || tecla == 194) return true; // (â) ou (Â)				
		else if(tecla == 233 || tecla == 201) return true; // (é) ou (É)		
		else if(tecla == 224 || tecla == 202) return true; // (ê) ou (Ê)		
		else if(tecla == 237 || tecla == 205) return true; // (í) ou (Í)
		else if(tecla == 243 || tecla == 211) return true; // (ó) ou (Ó)		
		else if(tecla == 244 || tecla == 212) return true; // (ô) ou (Ô)
		else if(tecla == 245 || tecla == 213) return true; // (õ) ou (Õ)
		else if(tecla == 250 || tecla == 218) return true; // (ú) ou (Ú)
		else if(tecla == 252 || tecla == 220) return true; // (ü) ou (Ü)
		else if(tecla == 32) return true; //	( ! )	espaço
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false;  // backspace 				
			else return true; 				
		} 
	}
	
	function fncEmail() {     //     OnKeyPress="return fncEmail();"
		var tecla = event.keyCode; 
		if(tecla > 96 && tecla < 123) return true;  //LETRAS MINUSCULAS 
		else if(tecla > 47 && tecla < 58) return true; // numeros de 0 a 9
		else if(tecla == 45) return true; // 	( - ) 	hífen
		else if(tecla == 46) return true; // 	( . )	ponto
		else if(tecla == 64) return true; // 	(@ )	arroba
		else if(tecla == 95) return true; // 	( _ )	underscore
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false;  // backspace 				
			else return true; 				
		} 
	}
	
	function fncURL() {     //     OnKeyPress="return fncURL();"
		var tecla = event.keyCode; 
		if(tecla > 96 && tecla < 123) return true;  //LETRAS MINUSCULAS 
		else if(tecla > 47 && tecla < 58) return true; // numeros de 0 a 9
		else if(tecla == 32) return true; //	( ! )	espaço
		else if(tecla == 38) return true; //	( & ) 	e comercial
		else if(tecla == 43) return true; // 	( + ) 	soma
		else if(tecla == 44) return true; // 	( , ) 	vírgula
		else if(tecla == 45) return true; // 	( - ) 	hífen
		else if(tecla == 46) return true; // 	( . )	ponto
		else if(tecla == 47) return true; // 	( / ) 	barra
		else if(tecla == 58) return true; // 	( : ) 	dois pontos
		else if(tecla == 59) return true; // 	( ; ) 	ponto e vírgula
		else if(tecla == 61) return true; // 	( = ) 	igualdade
		else if(tecla == 63) return true; // 	( ? )	interrogação
		else if(tecla == 95) return true; // 	( _ )	underscore
		else if(tecla == 13) return true; //	<ENTER>
		else{ 
			if (tecla != 8) return false; // 	(<--)	backspace 				
			else return true; 				
		} 
	}
	//-------------------------------------------------------------//
	
	
	
	
	
	
	
	
	
	// JavaScript Document
	function addItem(obj,strText,strValue,blSel,intPos){ 
		var newOpt,i,ArTemp,selIndex; 
		selIndex = (blSel)?intPos:obj.selectedIndex; 
		newOpt = new Option(strText,strValue); 
		Len = obj.options.length+1 
		if (intPos > Len) return 
		obj.options.length = Len 
		if (intPos != Len) { 
			ArTemp = new Array(); 
			for(i=intPos;i<obj.options.length-1;i++) ArTemp[i] = Array(obj.options[i].text,obj.options[i].value); 
			for(i=intPos+1;i<Len;i++) obj.options[i] = new Option(ArTemp[i-1][0],ArTemp[i-1][1]); 
		} 
		obj.options[intPos] = newOpt; 
		if (selIndex > intPos) obj.selectedIndex = selIndex+1; 
		else if (selIndex == intPos) obj.selectedIndex = intPos; 
	}
	
	
	
	
	
	
	
	/*** 
	* Descrição.: formata um campo do formulário de 
	* acordo com a máscara informada... 
	* Parâmetros: - objForm (o Objeto Form) 
	* - strField (string contendo o nome 
	* do textbox) 
	* - sMask (mascara que define o 
	* formato que o dado será apresentado, 
	* usando o algarismo "9" para 
	* definir números e o símbolo "!" para 
	* qualquer caracter... 
	* - evtKeyPress (evento) 
	* 
	* Uso.......: <input type="textbox" 
	* name="xxx"..... 
	* onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);" autocomplete="off"> 
	* Observação: As máscaras podem ser representadas como os exemplos abaixo: 
	* CEP -> 99.999-999 
	* CPF -> 999.999.999-99 
	* CNPJ -> 99.999.999/9999-99 
	* Data -> 99/99/9999 
	* Tel Resid -> (99) 999-9999 
	* Tel Cel -> (99) 9999-9999 
	* Processo -> 99.999999999/999-99 
	* C/C -> 999999-! 
	* E por aí vai... 
	***/ 

	function txtBoxFormat(objForm, strField, sMask, evtKeyPress) { 
		var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 

		if(document.all) { // Internet Explorer 
			nTecla = evtKeyPress.keyCode; } 
		else if(document.layers) { // Nestcape 
			nTecla = evtKeyPress.which; 
		} 

		sValue = objForm[strField].value; 

		// Limpa todos os caracteres de formatação que 
		// já estiverem no campo. 
		sValue = sValue.toString().replace( "-", "" ); 
		sValue = sValue.toString().replace( "-", "" ); 
		sValue = sValue.toString().replace( ".", "" ); 
		sValue = sValue.toString().replace( ".", "" ); 
		sValue = sValue.toString().replace( "/", "" ); 
		sValue = sValue.toString().replace( "/", "" ); 
		sValue = sValue.toString().replace( "(", "" ); 
		sValue = sValue.toString().replace( "(", "" ); 
		sValue = sValue.toString().replace( ")", "" ); 
		sValue = sValue.toString().replace( ")", "" ); 
		sValue = sValue.toString().replace( " ", "" ); 
		sValue = sValue.toString().replace( " ", "" ); 
		fldLen = sValue.length; 
		mskLen = sMask.length; 

		i = 0; 
		nCount = 0; 
		sCod = ""; 
		mskLen = fldLen; 

		while (i <= mskLen) { 
			bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")) 
			bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) 

			if (bolMask) { 
				sCod += sMask.charAt(i); 
				mskLen++; } 
			else { 
				sCod += sValue.charAt(nCount); 
				nCount++; 
			} 

			i++; 
		} 

		objForm[strField].value = sCod; 

		if (nTecla != 8) { // backspace 
			if (sMask.charAt(i-1) == "9") { // apenas números... 
				return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9 
			else { // qualquer caracter... 
				return true; 
			} 
		} else return true;  
	} 
	
	
	function LoginInvalido(login){
		Login = login.value.toUpperCase();
		if(login.value.length < 4){
			alert("Seu login deve conter pelo menos 4 dígitos.\nFavor informar seu login novamente");
			login.value = "";
			login.focus();
			return true;
		}
		if(Login == "ADMIN" || Login == "ADMINISTRADOR" || Login == "ADMINISTRATOR" || Login == "LOKEMCASA"){
			alert("Você não pode usar "+Login+" como seu login.\nFavor tentar outro login.");
			login.value = "";
			login.focus();
			return true;
		}
		return false;
	}
	
	function SenhasInvalidas(senha,cSenha){
		if(senha.value.length < 4){
			alert("Sua senha deve conter pelo menos 4 dígitos.\nFavor informar sua senha novamente");
			cSenha.value = "";
			senha.value = "";
			senha.focus();
			return true;
		}
		if(senha.value != cSenha.value){
			alert("A senha não confere com a confirmação!\nDigite novamente senha e confirmação.");
			cSenha.value = "";
			senha.value = "";
			senha.focus();
			return true;
		}
		return false;
	}
	
	function AlteracaoDeSenhasInvalidas(senha,cSenha){
		if(senha.value.length < 4){
			alert("Sua nova senha deve conter pelo menos 4 dígitos. Favor informa-lá novamente");
			cSenha.value = "";
			senha.value = "";
			senha.focus();
			return true;
		}
		if(senha.value != cSenha.value){
			alert("A nova senha não confere com a confirmação!\nDigite novamente a nova senha e confirmação.");
			cSenha.value = "";
			senha.value = "";
			senha.focus();
			return true;
		}
		return false;
	}
	
	// Marca/Desmarca todos
	// Para chamar deve-se usar para o checkbox que marca todas:
	// <input type="checkbox" onClick="SelAll(NOMEDOFORMULÁRIO);" name="Todos">    e para os demais checkboxes
	// <input type="checkbox" name="NOMEDOCAMPO" value="<%=RECORDSET("CAMPO_TAB")%>" onClick="Limpa_SellAll(NOMEDOFORMULÁRIO);">
	function SelAll(objForm){
		if(objForm.Todos.checked == true){  //Marca todos
			for (i=0; i < objForm.elements.length; i++){
				objForm.elements[i].checked=true;
			}
		}else{  //Desmarca todos
			for (i=0; i < objForm.elements.length; i++){
				objForm.elements[i].checked=false;
			}
		}
	}
	
	function Limpa_SellAll(objForm){
		for (i=1; i < objForm.elements.length; i++){
			if(objForm.elements[i].checked==false)objForm.Todos.checked=false;
		}
	}
	
	
	
	function DestacaCelula(Over,td){
		if(Over){
			document.getElementById(td).style.backgroundColor = '606075';
		}else{
			document.getElementById(td).style.backgroundColor = 'C9C9D3';
		}
	}
	
	
	
	function filter(phrase, _id, cellNr){
		var suche = phrase.value.toLowerCase();
		var table = document.getElementById(_id);
		var ele;
		for (var r = 1; r < table.rows.length; r++){
			ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g,"");
			(ele.toLowerCase().indexOf(suche)>=0 )?table.rows[r].style.display = '':table.rows[r].style.display = 'none';
		}
	}
	
	
	
/*	DDD <input type="text" name="first" size=4 onKeyup="autotab(this, document.NOMEDOFORM.PROXIMOCAMPO)" maxlength=3> 
	 -  <input type="text" name="second" size=4 onKeyup="autotab(this, document.NOMEDOFORM.PROXIMOCAMPO)" maxlength=4> 
		<input type="text" name="third" size=5 maxlength=4>													 */	
	function autotab(original,destination){ 
		if(original.getAttribute&&original.value.length==original.getAttribute("maxlength"))destination.focus() 
	}
	
		
	
	
	
	
	
	//<a href="#" onClick="move(Form.Mantidas,Form.MantidasEscolhidas);"><img src="../imgs/Coordenadores/BtnIncluir.gif" alt="Clique para incluir" width="140" height="17" border="0"></a>
	//<a href="#" onClick="move(Form.MantidasEscolhidas,Form.Mantidas);"><img src="../imgs/Coordenadores/BtnExcluir.gif" width="140" height="17" border="0"></a>
	function move(fbox, tbox) {
		var arrFbox = new Array();
		var arrTbox = new Array();
		var arrLookup = new Array();
		var i;
		for (i = 0; i < tbox.options.length; i++) {
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		var fLength = 0;
		var tLength = arrTbox.length;
		for(i = 0; i < fbox.options.length; i++) {
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			} else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
		   }
		}
		arrFbox.sort();
		arrTbox.sort();
		fbox.length = 0;
		tbox.length = 0;
		var c;
		for(c = 0; c < arrFbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}
		for(c = 0; c < arrTbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrTbox[c]];
			no.text = arrTbox[c];
			tbox[c] = no;
		}
	}
	
	//Para usar esta função usa-se:     Oculta("ID_do_elemento");     para ocultar
	//e     Mostra("ID_do_elemento");     para mostrar
	function Oculta(campo){
		document.getElementById(campo).style.display = "none";
	}
	function Mostra(campo){
		document.getElementById(campo).style.display = "";
	}
	function MostraOculta(campo){
		document.getElementById(campo).style.display = (document.getElementById(campo).style.display == "none")? "" : "none";
		void(0);
	}
	
	
	function ReplaceBreakLine(str){
		var re = /<br>/g;
		return(str.replace(re, String.fromCharCode(13))); 
	}
	
	
	function Ctrl_Abas(AbaClicada){/* 
		Todos os <td>'s referentes as abas devem ser identificados como "td_Aba_XXXXXXX" onde 
		"XXXXXXX" é o assunto abordado pela aba específica. Os <div>'s que serão exibidos quando 
		as abas forem clicadas devem ser identificados como "div_ConteudoAba_XXXXXXX" onde "XXXXXXX" 
		é exatamente o mesmo "XXXXXXX" usado para identificar os <td>'s das abas clicáveis. Após
		identificação de todos os <td>'s e <div>'s, deve-se preencher o array abaixo ("Abas") com
		os sufixos ("XXXXXXX") de cada um deles. Lembre-se que o parâmetro passado para esta função
		sempre deverá ser somente o sufixo da aba clicada e não sua identificação completa		 
		
		Na página a ser usada esta função deve haver uma variável chamada arrAbas no escopo principal 
		das tags de	scrip, e ela será preenchida com os sufixos das abas e dos divs a serem ativados.
		Ex.: arrAbas = new Array("Adm", "Gst", "Dap");												*/
		
		for(i=0; i<arrAbas.length; i++){
			if(arrAbas[i]==AbaClicada){
				document.getElementById("td_Aba_"+arrAbas[i]).className = 'Aba_Ativa';
				Mostra("div_ConteudoAba_"+arrAbas[i]);
			}else{
				document.getElementById("td_Aba_"+arrAbas[i]).className = 'Aba_Inativa';
				Oculta("div_ConteudoAba_"+arrAbas[i]);
			}
		}
	}/*
	-- HTML das Abas e dos conteúdos a serem ativados no click da aba -----------------------------
		<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
		  <td width="8" height="23" class="Aba_LinhaDeFora">&nbsp;</td>
		  <td align="center" class="Aba_Ativa" id="td_Aba_Adm"><a href="#" class="LinkAba" onClick="Ctrl_Abas('Adm');">Administração de IES</a></td>
		  <td width="8" class="Aba_LinhaDeFora">&nbsp;</td>
		  <td align="center" class="Aba_Inativa" id="td_Aba_Gst"><a href="#" class="LinkAba" onClick="Ctrl_Abas('Gst');">Gestão Empresarial </a></td>
		  <td width="8" class="Aba_LinhaDeFora">&nbsp;</td>
		  <td align="center" class="Aba_Inativa" id="td_Aba_Dap"><a href="#" class="LinkAba" onClick="Ctrl_Abas('Dap');">Desempenho na área política</a></td>
		  <td width="8" class="Aba_LinhaDeFora">&nbsp;</td>
		</tr></table>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="Aba_Conteudo">
		  <tr><td height="15" width="15"></td><td></td><td width="15"></td></tr><tr><td>&nbsp;</td><td>
			  <div id="div_ConteudoAba_Adm">Div referente a ativação da primeira aba </div>
			  <div id="div_ConteudoAba_Gst">Div referente a ativação da segunda aba </div><script>Oculta("div_ConteudoAba_Gst");</script>
			  <div id="div_ConteudoAba_Dap">Div referente a ativação da terceira aba </div><script>Oculta("div_ConteudoAba_Dap");</script>                                        
		</td><td>&nbsp;</td></tr><tr><td height="15"></td><td></td><td></td></tr></table>
	-----------------------------------------------------------------------------------------------
	
	-- Classes CSS a serem definidas para as Abas e o conteúdo ------------------------------------
	Segue aqui comentado as classes CSS que deverão acompanhar ser definidas para a tabela com conterá as abas:
	.Aba_LinhaDeFora{border-bottom-color: #CBC9B1;border-bottom-width: 1px;border-bottom-style: solid;}
	.Aba_Ativa{border-top-color: #CBC9B1;border-right-color: #CBC9B1;border-left-color: #CBC9B1;border-bottom-color: #FFFFFF;
		background-color: #FFFFFF;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;
		border-top-style: solid;border-right-style: solid;border-bottom-style: solid;border-left-style: solid;}
	.Aba_Inativa{border: 1px solid #CBC9B1;background-color: #F7F4E8;}
	.Aba_Conteudo{background-color: #FFFFFF;border-top-width: 0px;border-right-width: 1px;border-bottom-width: 1px;
		border-left-width: 1px;border-top-style: none;border-right-style: solid;border-bottom-style: solid;
		border-left-style: solid;border-top-color: #FFFFFF;border-right-color: #CBC9B1;border-bottom-color: #CBC9B1;
		border-left-color: #CBC9B1;}
	
	-----------------------------------------------------------------------------------------------*/
	
	
	
	
	
	
	
	function Contador(CampoTxt, Contador, LimiteMax){
		objCampoTxt = document.all(CampoTxt);
		objContador = document.all(Contador);
      	if (LimiteMax !=0) {
         	if (objCampoTxt.value.length > LimiteMax)  {
            	objCampoTxt.value = objCampoTxt.value.substring(0, LimiteMax);
            }
      	}
      	objContador.value = objCampoTxt.value.length + '/'+LimiteMax;
   	}
	
	
	
	
	
	function impressao(url){
		url += "?url=" + document.location;
		document.href = url;
		open(url, "Imprimir");
	}
	
	
	//#### Funções criadas pelo dreamweaver para habilitar os arquivos .swf das páginas no novo IE  ##########
	//########################################################################################################
	function AC_AddExtension(src, ext){
		if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); 
		else return src + ext;
	}
	
	function AC_Generateobj(objAttrs, params, embedAttrs) { 
		var str = '<object ';
		for (var i in objAttrs) str += i + '="' + objAttrs[i] + '" ';
		str += '>';
		for (var i in params) str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		str += '<embed ';
		for (var i in embedAttrs) str += i + '="' + embedAttrs[i] + '" ';
		str += ' ></embed></object>';
		document.write(str);
	}
	
	function AC_FL_RunContent(){
		var ret = AC_GetArgs(arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
		AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
	
	function AC_SW_RunContent(){
		var ret = AC_GetArgs(arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null);
		AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
	
	function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
		var ret = new Object();
		ret.embedAttrs = new Object();
		ret.params = new Object();
		ret.objAttrs = new Object();
		for (var i=0; i < args.length; i=i+2){
			var currArg = args[i].toLowerCase();
			switch (currArg){
				case "classid":
					break;
				case "pluginspage":
					ret.embedAttrs[args[i]] = args[i+1];
					break;
				case "src":
				case "movie":
					args[i+1] = AC_AddExtension(args[i+1], ext);
					ret.embedAttrs["src"] = args[i+1];
					ret.params[srcParamName] = args[i+1];
					break;
				case "onafterupdate":
				case "onbeforeupdate":
				case "onblur":
				case "oncellchange":
				case "onclick":
				case "ondblClick":
				case "ondrag":
				case "ondragend":
				case "ondragenter":
				case "ondragleave":
				case "ondragover":
				case "ondrop":
				case "onfinish":
				case "onfocus":
				case "onhelp":
				case "onmousedown":
				case "onmouseup":
				case "onmouseover":
				case "onmousemove":
				case "onmouseout":
				case "onkeypress":
				case "onkeydown":
				case "onkeyup":
				case "onload":
				case "onlosecapture":
				case "onpropertychange":
				case "onreadystatechange":
				case "onrowsdelete":
				case "onrowenter":
				case "onrowexit":
				case "onrowsinserted":
				case "onstart":
				case "onscroll":
				case "onbeforeeditfocus":
				case "onactivate":
				case "onbeforedeactivate":
				case "ondeactivate":
				case "type":
				case "codebase":
					ret.objAttrs[args[i]] = args[i+1];
					break;
				case "width":
				case "height":
				case "align":
				case "vspace": 
				case "hspace":
				case "class":
				case "title":
				case "accesskey":
				case "name":
				case "id":
				case "tabindex":
					ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
					break;
		  		default:
					ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
			}
	  	}
	  	ret.objAttrs["classid"] = classid;
	  	if (mimeType) ret.embedAttrs["type"] = mimeType;
	  	return ret;
	}
	//########################################################################################################
	//--------------------------------------------------------------------------------------------------------
	
	
	//Função AJAX usada para carregar arquivos XML
	function ajaxLoad(URL, fncLoad, fncProcessXML, fncErro){
		var ajax;
		
		//verifica se o browser tem suporte a ajax
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(ex) {
				try {
					ajax = new XMLHttpRequest();
				} catch(exc) {
					alert("Esse browser não tem recursos para uso do Ajax");
					ajax = null;
				}
			}
		}
			
		
		//se tiver suporte ajax
		if(ajax) {
			ajax.open("GET", URL, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
			ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
			ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
			ajax.setRequestHeader("Pragma", "no-cache");				 
						
			ajax.onreadystatechange = function() {
				//enquanto estiver processando...exibe a msg de carregando
				if(ajax.readyState == 1) {
					eval(fncLoad); //Chama a função que exibe a mensagem de "Carregando..."
				}
				
				//após ser processado - chama função processXML que vai varrer os dados
				if(ajax.readyState == 4 ) {
					if(ajax.responseXML) {
						fncProcessXML = fncProcessXML.substring(0,fncProcessXML.length-1)+"ajax.responseXML);";
						eval(fncProcessXML);
					} else {
						//caso o retorno não seja um arquivo XML válido, exibe a mensagem abaixo
						fncErro = fncErro.substring(0,fncErro.length-1)+"ERRO: ajax.responseXML = "+ajax.responseXML+");";
						eval(fncErro);
					}
				}
			}			
			ajax.send(null);
		}
	}

	
	
	//Retorna o objeto especificado pelo ID passado como parâmetro
	function getObjeto(ID){
		return document.getElementById(ID);
	}
	function getValor(ID){
		if (typeof(ID) == 'string') ID = document.getElementById(ID);
		return ID.value;
	}
	function setValor(ID, valor){
		if (typeof(ID) == 'string') ID = document.getElementById(ID);
		ID.value = valor;
	}
	function setHTML(ID, html){
		document.getElementById(ID).innerHTML = html;
	}
	
	function getLen(ID){//Retorna o tamanho da string
		if (typeof(ID) == 'string') ID = document.getElementById(ID);
		return ID.value.length;
	}