function WandekoPipoca(mensagem) {
	var confirma;
	confirma = false;
	confirma = confirm(mensagem);
	return (confirma);
} 

function Vai_Para(pagina){
	document.form_pag.pagina.value = pagina;
	document.form_pag.submit();
}

// Início - Funções de nova janela (Rever todas para otimizar)
function nova_janela_param(meuURL, minhaLargura, minhaAltura, meuAlvo)	{
	var localX = (screen.width - minhaLargura) /3;
	var localY = (screen.height - minhaAltura) /4;		
	
	propriedades='width='+minhaLargura+',height='+minhaAltura+',left='+localX+',top='+localY+', scrollbars=yes, status=yes';
	
	window.open(meuURL, meuAlvo, propriedades)
}

function nova_janela(meuURL, minhaLargura, minhaAltura)	{
	var localX = (screen.width - minhaLargura) /3;
	var localY = (screen.height - minhaAltura) /4;		
	
	propriedades='width='+minhaLargura+',height='+minhaAltura+',left='+localX+',top='+localY+'';
	
	window.open(meuURL, "_blank", propriedades)
}

function nova_janela_resize(meuURL, minhaLargura, minhaAltura)	{
	var localX = (screen.width - minhaLargura) /3;
	var localY = (screen.height - minhaAltura) /4;		
	
	propriedades='width='+minhaLargura+',height='+minhaAltura+',left='+localX+',top='+localY+', resizable=yes'+'';
	
	window.open(meuURL, "_blank", propriedades)
}

function nova_janela_teste(meuURL, minhaLargura, minhaAltura)	{
	var localX = (screen.width - minhaLargura) /3;
	var localY = (screen.height - minhaAltura) /4;		
	
	propriedades='width='+minhaLargura+',height='+minhaAltura+',left='+localX+',top='+localY+'';
	
	window.open(meuURL, "_blank", propriedades)
}

function nova_aval(meuURL, minhaLargura, minhaAltura, meuAlvo)	{
	var localX = (screen.width - minhaLargura) /3;
	var localY = (screen.height - minhaAltura) /4;								
	propriedades='width='+minhaLargura+',height='+minhaAltura+',left='+localX+',top='+localY+', scrollbars=yes, status=yes, resizable=yes';
	
	avaliacao = window.open(meuURL, meuAlvo, propriedades)
}
// Fim - Funções de nova janela

function exit(minhaURL) {
	parent.opener.location.href=minhaURL;
	parent.close();
}

function menu_over(src, cursor) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = cursor;
		src.bgColor = '#FFFFdd';
	}
}

function menu_out(src) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = '#FFFFFF';
	}
}

function MM_jumpMenu(targ,selObj,restore){
	buh = selObj.options[selObj.selectedIndex].value.replace('^-^', '');
	eval(targ+".location='"+buh+"'");
	if (restore) selObj.selectedIndex=0;
}
	
var radio="";
function valradio(){
	erro = true;
	if (radio == ""){
		alert('Selecione um equipamento antes de prosseguir');
	}
	else{
		erro = false;
	}
	return !(erro);
}

function setFocus(nform, ncampo) {
	if(eval(document.forms[nform])){
		document.forms[nform].elements[ncampo].focus();
	}
}

function maskdate(txt){ 
	if (txt.value.length == 2){
		txt.value = txt.value +'/';
	}
	if (txt.value.length == 5){
		txt.value = txt.value + '/';
	}
}

function ano_bi(ano){
	if(ano % 100 == 0){
		if(ano % 400 == 0)
			return true;
	}
	else {
		if((ano % 4) == 0)
			return true;
	}	
	return false;
}

function valida_data(data){
	var datapartes = /^(\d{1,2})(\/|-|.)(\d{1,2})\2(\d{4})$/;
	var dividedata = data.match(datapartes);

	if(dividedata==null){
		return false;
	}
	else{
		var dia = dividedata[1];
		var mes = dividedata[3];
		var ano = dividedata[4];

		if((dia<1 || dia>31 || mes <1 || mes>12 || ano<1900 || ano > 2100)||
		((mes==4 || mes==6 || mes==9 || mes==11)&& dia >30) ||
		(mes==2 && dia>29) || (mes==2 && dia==29 && !ano_bi(ano))){
			return false;
		}
	}
	return true;
}

function dateToInt(data){

	var datapartes = /^(\d{1,2})(\/|-|.)(\d{1,2})\2(\d{4})$/;
	var dividedata = data.match(datapartes);

	var dia = dividedata[1];
	var mes = dividedata[3];
	var ano = dividedata[4];

	var dataint = ano+mes+dia;

	return dataint;

}

function RetiraAcentosBusca(valor){
	valorLength = valor.length;
	var caracteres_inv = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÃÕÇ";
	var caracteres_val = "AEIOUAEIOUAEIOUAEIOUAOC";
	var retorno  = "";

	for(i=0; i<caracteres_inv.length; i++)
	   {
	   for(j=0; j<valorLength; j++)
		  {
		  retorno = valor.replace(caracteres_inv.substr(i,1),caracteres_val.substr(i,1));
		  valor = retorno;
		  }
	   }
	return valor;
}

function BuscaCombo(in_sFormName, in_sInputName, in_sSelectName){
	sSearchString = document.forms[in_sFormName].elements[in_sInputName].value.toUpperCase();
	sSearchString = RetiraAcentosBusca(sSearchString);
	iSearchTextLength = sSearchString.length;

	for (j=0; j < document.forms[in_sFormName].elements[in_sSelectName].options.length; j++){
		sOptionText = document.forms[in_sFormName].elements[in_sSelectName].options[j].text;
		sOptionComp = sOptionText.substr(0, iSearchTextLength).toUpperCase();

		if(sSearchString == sOptionComp){
			document.forms[in_sFormName].elements[in_sSelectName].selectedIndex = j;
			break;
		}
	}
}

function soNumeros(){
	if ((event.keyCode > 0 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 255)){ 
		event.returnValue = false;
	}
	if (event.keyCode == 13){
		event.returnValue = true;	
	}
}

function Mascarar_CEP(keypress, objeto){
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 5 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '-';
		}
	}
}

function Mascarar_Data(keypress, objeto){
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
		if (campo.value.length == 5 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
	}
}

function Valida_CNPJ(cnpj) {
	var erro = true; 
	var aux_cnpj = "";	
	var cnpj1=0,cnpj2=0;
	for(j=0;j<cnpj.length;j++)
		if(cnpj.substr(j,1)>="0" && cnpj.substr(j,1)<="9")
			aux_cnpj += cnpj.substr(j,1);
	if(aux_cnpj.length!=14 || aux_cnpj == "00000000000000")
		erro = false;
	else {
		cnpj1 = aux_cnpj.substr(0,12);
		cnpj2 = aux_cnpj.substr(aux_cnpj.length-2,2);
		fator = "543298765432";
		controle = "";
		for(j=0;j<2;j++) {
			soma = 0;
			for(i=0;i<12;i++) 
				soma += cnpj1.substr(i,1) * fator.substr(i,1);
			if(j==1) soma += digito * 2;
			digito = (soma * 10) % 11;
			if(digito==10) digito = 0;
			controle += digito;
			fator = "654329876543";
		} 
		if(controle!=cnpj2)
			erro = false;
	} 
	return erro;
}

/*
function validaCPF() {
	cpf = document.validacao.cpfID.value;
	erro = new String;
	if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\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!"
	}
	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!";
	}
	if (erro.length > 0){
		 alert(erro);
		 return false;
	}
	return true;
}
*/

function validaCPF (CPF) {
    if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
		CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
		CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
		CPF == "88888888888" || CPF == "99999999999")
		return false;
	soma = 0;
	for (i=0; i < 9; i ++)
		soma += parseInt(CPF.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(9)))
		return false;
	soma = 0;
	for (i = 0; i < 10; i ++)
		soma += parseInt(CPF.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(10)))
		return false;
    return true;
}


function PulaCampo(objeto1, objeto2, tamanho){
	if(objeto1.value.length == tamanho){
		objeto2.focus();
	}
}

function filtra_numero(campo) {
	texto = campo.value;
	tam = texto.length;
	var numeros = '';
	for(i = 0; i < tam; i++) {
		str = texto.substr(i,1);
		if (str == '0') {
			numeros += str;
		}
		else {
			if (parseInt(str)) {
				numeros += str;
			}
		}
	}
	campo.value = numeros;
}

function isCxAlta(caracteres) {
	var validos = "ABCD"

	for (var i=0; i < caracteres.length; i++) {
		var temp = "" + caracteres.substring(i, i+1);
		if (validos.indexOf(temp) == "-1") 
			return false;
	}
	return true;
}

function Executar(alvo, var01){
	document.form_param.action = alvo;
	document.form_param[0].value = var01;
	/* 
	Verifica se foram passados argumentos adicionais
	e faz um loop pra montar o form. Os campos devem
	ser definidos em um formulario de nome form_param.
	O nome dos campos é indiferente.
	*/
	var numArgs = parseInt(Executar.arguments.length - 1);
	
	if(numArgs > 1){
		for(i=1; i < numArgs; i++){
			var j = parseInt(i+1);
			document.form_param[i].value = Executar.arguments[j];
			//alert(numArgs+' '+document.form_param[i].value);
		}			
	}
	document.form_param.submit();
}

function Move(fbox, tbox) {
	/* 
	Função para se usada em dois combos "select" de múltipla escolha;
	Para fazer uso desta função com PHP é necessário que o nome dos combos seja da 
	seguinte forma: "exemplo[]" o PHP já le este nome como um array enquanto no JS 
	deve ser passado para a função assim: "this.form.elements['exemplo[]']";
	No botão de envio deve ter um onClick chamando afunção selectAll que vai 
	selecionar todos os valores do segundo combo para ser enviado.
	*/
	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;
   }
}

function Move_Limit(formulario, fbox, tbox, nmax, qtdini, qtddir_ini, ncombo) {

	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;

	fbox = formulario.elements[fbox];
	tbox = formulario.elements[tbox];

	// Verifica quantos tem selecionados	
		
	if(ncombo == 1){
		// Se o clique vier do combo 1 então o total da direita é o tbox
		qtddir = 0;
		for(i=0; i < fbox.options.length; i++) {
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				qtddir++;				
			}
		}
		qtddir = qtddir + tbox.options.length;
	}
	else{
		// Se o clique vier do combo 2 então o total da direita é o tbox
		qtddir = 0;
		for(i=0; i < fbox.options.length; i++) {
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				qtddir++;		
			}
		}
		qtddir = fbox.options.length - qtddir;	
	}

	if(qtddir >= qtddir_ini){
		diferenca = qtddir - qtddir_ini;
		total = qtdini + diferenca;
	}
	else{
		diferenca = qtddir_ini - qtddir;
		total = qtdini - diferenca;
	}
	selectedLength = total;

	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}		

	if(selectedLength > nmax){
		//
		qtddir_passou = 0;
		for(i=0; i < fbox.options.length; i++) {
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				qtddir_passou++;				
			}
		}
		selectedLength = selectedLength - qtddir_passou;
		//
		alert('Esta sala suporta apenas '+nmax+' alunos');

	}
	else{
		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;
	    }
	}

	if(selectedLength == 0){
		valorLength = fLength;
	}
	else{
		valorLength = selectedLength;
	}

	//alert(valorLength);

	formulario.elements['tot_array'].value=valorLength;
	//alert(selectedLength);
	
}



function Move_Limit_backup(formulario, fbox, tbox, nmax, qtdini, qtddir, ncombo) {
	/* 
	Função para se usada em dois combos "select" de múltipla escolha;
	Para fazer uso desta função com PHP é necessário que o nome dos combos seja da 
	seguinte forma: "exemplo[]" o PHP já le este nome como um array enquanto no JS 
	deve ser passado para a função assim: "this.form.elements['exemplo[]']";
	No botão de envio deve ter um onClick chamando afunção selectAll que vai 
	selecionar todos os valores do segundo combo para ser enviado.
	*/
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;

	fbox = formulario.elements[fbox];
	tbox = formulario.elements[tbox];

	// Verifica quantos tem selecionados	
	selectedLength = qtdini;
	if(ncombo == 1){
		for(i = 0; i < fbox.options.length; i++) {
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				selectedLength++;				
			}
		}
		selectedLength = selectedLength + tbox.options.length;
	}
	// Fim

	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}	

	if(selectedLength > nmax){
		// Zera a quantidade e conta somente os que tem no campo a direita
		selectedLength = qtdini;
		/*
		for(i = 0; i < tbox.options.length; i++) {			
				selectedLength++;				
		}
		*/
		//
		alert('Esta sala suporta apenas '+nmax+' alunos');
	}
	else{
		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;
	    }
	}

	if(selectedLength == 0){
		valorLength = fLength;
	}
	else{
		valorLength = selectedLength;
	}

	//alert(valorLength);

	formulario.elements['tot_array'].value=valorLength;
	//alert(selectedLength);
	
}

function SelectAll(box) {
	/*
	Seleciona todos os elementos de um campo múltiplo
	*/
    var opt, a, i;
    i = 0;
    if (box.type == 'select-multiple'){
		while (opt = box[i++]){
			opt.selected = true;
		}
	}
}

function soNumeroReal(){
	if ((event.keyCode == 46) || (event.keyCode >= 48 && event.keyCode <= 57)) {
	    event.returnValue = true;
	} else {
	    event.returnValue = false;
	}
}

function checkKPress() {
	// 78 - N
	// 67 - C
	// 17 - ctrl
	if (event.ctrlKey)
	if ((event.keyCode == 78) 
		|| (event.keyCode == 67)
		|| (event.keyCode == 17)
		|| (event.keyCode == 104))
		event.returnValue = false;
}

function FormataValor(tecla, objeto, tammax) {

	campo = eval(objeto);

	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if(tam < tammax && tecla != 8){ 
		tam = vr.length + 1 ; 
	}
	if(tecla == 8){	
		tam = tam - 1 ; 
	}		
	if(tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105){
		if( tam <= 2 ){ 
	 		campo.value = vr ; 
		}
	 	if((tam > 2) && (tam <= 5)){
	 		campo.value = vr.substr(0, tam - 2) + ',' + vr.substr(tam - 2, tam);
		}
	 	if((tam >= 6) && (tam <= 8)){
	 		campo.value = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
		}
	 	if((tam >= 9) && (tam <= 11)){
	 		campo.value = vr.substr(0, tam - 8) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam); 
		}
	 	if((tam >= 12) && (tam <= 14)){
	 		campo.value = vr.substr(0, tam - 11) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam); 
		}
	 	if((tam >= 15) && (tam <= 17)){
	 		campo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
		}
	}
}

function number_format(valor, dec) {
	valor = valor.toString();
	ponto = valor.indexOf(".");
	if(dec == 0) {
		return parseInt(valor);
	}

	if(ponto == -1) {
		valor += ".";
		for(i = 1; i <= dec; i++) {
			valor += "0";
		}
		resultado = valor;
	}
	else {
		numdec = valor.length - ponto - 1;
		if(numdec == dec) {
			resultado = valor;
		}
		else if(numdec > dec) {
			parte1 = valor.substring(0, ponto);
			parte2 = valor.substring(ponto + 1, valor.length);
			parte2 = parte2.substring(0, dec);
			resultado = parte1 + '.' + parte2;
		}
		else if(numdec < dec) {
			parte1 = valor.substring(0, ponto);
			parte2 = valor.substring(ponto + 1, valor.length);

			for(i = parte2.length; i < dec; i++) {
				parte2 += "0";
			}
			resultado = parte1 + '.' + parte2;
		}
	}
	return resultado;
}

function valida_char(campo) {
	var validos = "abcdefghijklmnopqrstuvwxyz0123456789_-"
	var retorno = true;
	var temp;
	for (var i=0; i< campo.length; i++) {
		temp = "" + campo.substring(i, i+1);
		if (validos.indexOf(temp) == "-1"){
			retorno = false;
		}
	}
	return retorno;
}

function Mascarar_Hora(keypress, objeto){
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + ':';
		}
	}
}

function max_jan(){ //função para maximizar a janela
    var window_height = window.screen.availHeight; 
	var window_width = window.screen.availWidth; 
	window.resizeTo(window_width,window_height); 
	var left_point = 0; 
	var top_point = 0; 
	window.moveTo(left_point, top_point); 
}

function textCounter(form, campo, campo_contador) {
	
	var qtd_caracteres = campo.value.length;
	var max_caracteres = campo.getAttribute ? parseInt(campo.getAttribute("maxlength")) : "";
	var contador = document.getElementById(campo_contador);

	if (campo.getAttribute){

		if (qtd_caracteres > max_caracteres){
			campo.value = campo.value.substring(0, max_caracteres);
		}
		
		if (contador){
			contador.value = max_caracteres - campo.value.length;
		}
		
		if (qtd_caracteres != campo.value.length){
			alert('A quantidade máxima é de '+max_caracteres+' caracteres');
			return false;
		}
	}
}

function submitSelf(form_name){
	form_name.target='_self';
	form_name.submit();
}


function marca_checkbox(formulario){

	f = document.forms[formulario];

	for (i=0; i<f.length; i++){
		if (f.elements[i].type == "checkbox"){
			if (f.elements[i].checked == false){
				f.elements[i].checked = true;
			}
			else{
				f.elements[i].checked = false;
			}
		}
	}
}

function marcades_checkbox(formulario, tipo){

	f = document.forms[formulario];

	for (i=0; i<f.length; i++){
		if (f.elements[i].type == "checkbox"){
			if (tipo == 'marcar'){
				f.elements[i].checked = true;
			}
			else{
				f.elements[i].checked = false;
			}
		}
	}
}

function carregaFlash(caminho,largura,altura){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+caminho+'">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="'+caminho+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'"></embed>');
	document.write('</object>');
}

function validaAno(ano){
	var valida_ano = /^[0-9][0-9][0-9][0-9]$/;
	if (valida_ano.test(ano)) {
		return true;
	}
	else{
		return false;
	}
}

function validaSemestre(semestre){
	var valida_semestre = /^[0-9][0-9][0-9][0-9][/][1-2]$/;
	if(valida_semestre.test(semestre)){
		return true;
	}
	else{
		return false;
	}
}

function validaEmail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    
	if(typeof(mail) == "string"){
        if(er.test(mail)){ 
			return true; 
		}
    }
	else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
			return true;
        }
    }
	else{
        return false;
    }
}

function LimpaComboNsem(nform){
    if(eval(document.forms[nform])){
        document.forms[nform].elements['turs_nsem'].value = '';
    }
}

/** */