<!--



/* 

	Para formatação de data inserir no campo apropriado a seguinte string:

	onKeyup="FormataData(this.value,this.name)" onblur="vld_data(this.value,this.name)"

*/

/**

 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/

 *

 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:

 * http://www.opensource.org/licenses/mit-license.php

 *

 */	

 	function TeclaEnter(evt) {
		//CAPTURA A TECLA ENTER E EXECUTA A FUNÇÃO Enter()
		//o método Enter deve ser sobrescrito na página
		var keyCode;
		if (evt == null) evt = event;
		if (evt != null){
			keyCode = (evt.which) ? evt.which : evt.keyCode;
			if (keyCode==13) Enter();
		}
	}
	document.onkeypress = TeclaEnter;

	function Enter(){
		//Este método deve ser sobrescrito na página onde o ENTER terá alguma 
		//função específica
	}

 	function novo_pedido(){

		msg = "Deseja realmente finalizar o pedido atual e iniciar um novo pedido?";	

		if (confirm(msg)) window.location.href='novo_pedido.php';

		

	}

	

	function check_radio(form,campo,tipo){

		//Funcão que encontra o valor selecionado de um grupo de checkbox

		//tipo >> indica qual o tipo de retorno (int ou str)

		valor_sel = 0;

		if (tipo == 'str') valor_sel = '';

		tam = eval("document."+form+"."+campo+".length");

		//alert(tam);

		for(i=0;i<tam;i++){

			check = eval("document."+form+"."+campo+"[i].checked");			

			if (check) {

				valor_sel = eval("document."+form+"."+campo+"[i].value");

				break;

			}

		}

		//alert(valor_sel);

		return valor_sel;

	}

	

	function vld_cupom(form,id_rel_cupom,id_item){

			vl = eval("document."+form+".cupom_desc.value");

			tam = vl.length;

			//alert(vl);

			if (tam > 0 && tam <= 5){

				msg = "O código que você informou não é um cupom válido!\n";	

				msg += "Por favor, verifique o valor digitado e tente novamente.";

				alert(msg);

				with(eval("document."+form)){

					cupom_desc.focus();

					cupom_desc.select();					

				}

			} else {

				document.form_cupom.id_rel_cupom.value = id_rel_cupom;

				document.form_cupom.id_item.value = id_item;

				document.form_cupom.cupom.value = vl;

				document.form_cupom.submit();	

			}

	}

	

	function addSWF (URL, WIDTH, HEIGHT, TRANSPARENT){

		document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');

		document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');

		document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');

		document.write (' <param name="movie" value="'+ URL +'" />');

		document.write (' <param name="quality" value="high" />');

	

		if ( TRANSPARENT ) {

			document.write (' <param name="Wmode" value="Transparent" />'); 

		}

	

		document.write (' <embed src="'+ URL +'" quality="high" ');

	

		if ( TRANSPARENT ) {

			document.write (' Wmode = "transparent" ');

		}	

		document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');

		document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');

		document.write (' </object>');		

	}



	function submit_enter(myfield,e){

		//alert("pressionou Enter");

		var keycode;

		if (window.event) keycode = window.event.keyCode;

		else if (e) keycode = e.which;

		else return true;

	

		if (keycode == 13){

		   calc_cep();

		   return false;

		 } else {

		   return true;

		}

	}	

	

	function win_enderecos(){

		win_end = window.open('fs_enderecos.php','','width=300,height=400');

	}



	//onKeyPress="vld_insc_estadual(this.value,this.name,this.form.name)" no campo IE

	//onClick="vld_insc_estadual(this.value,this.name,this.form.name)" no checkbox Isento

	function vld_insc_estadual(vl,campo,form){

		//alert(campo);

		if (campo == 'inscricao_estadual'){

			//Campo IE foi preenchido

			if (vl.length > 0) eval("document."+form+".isento.checked = false");

		} else {

			//Checbox Isento foi clicado

			st = eval("document."+form+"."+campo+".checked");

			if (st) eval("document."+form+".inscricao_estadual.value=''"); //Limpa o campo IE

		}

	}







	//onKeyPress="muda_de_campo(this.name,this.value,this.form.name,'telefone_1',2)"

	function muda_de_campo(campo,valor,form,mudar_para,limite){

		//Muda automaticamente de campo após x caracteres	

		if (valor.length >= limite) {

			//muda para o próximo campo

			//eval("document."+form+"."+mudar_para+".focus()");

		}

	}

	

	//vld_telefone(this.value,this.name,this.form.name,7)

	function vld_telefone(valor,campo,form,minimo){

		//Valida a quantidade de caracteres

		tam = valor.length;

		if (tam > 0 && tam < minimo){

			alert("Atenção!\nA quantidade de caracteres que você digitou para este campo não é válida!");

			eval("document."+form+"."+campo+".select()");			

		}

	}

	

	function atendimento_online(){

		width = 400; height=400; nome = 'win_online';

	  var top; var left;

	  top = ( (screen.height/2) - (height/2) )

	  left = ( (screen.width/2) - (width/2) )

	  window.open('http://www.soluszip.com.br/solusvivo/interbits/usuario_entrar.asp',nome,'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);

	}

	

	function enviaemail(id,x){

		if (x != 1){

			//Usuário bloqueado

			msg = "Usuário bloqueado!\n";

			msg += "Para enviar os dados por e-mail é necessário liberar o acesso desse usuário.";

			alert(msg);

		} else {

			//Conta ativa

			msg = "ENVIO DE E-MAIL\n";

			msg += "Você está prestes a enviar os dados de acesso para o e-mail da conta atual.\n";

			msg += "Deseja continuar?";

			resp = confirm(msg);

			if (resp) {

				win_popup(id);

				//winemail = eval("window.open('envia_email.asp?id="+id+"','winemail','width=350,height=270')");

			}

		}

	}

	//onBlur="vld_tam_cnpj(this.form.name,this.name,this.value)"

	function vld_tam_cnpj(form,nome,vl){

		if(vl.length > 0 && vl.length < 18) {

			alert("Atenção/nO CNPJ não está completo.");

			eval("document."+form+"."+nome+".select()");

		}

	}



	//onKeyUp="maiusculas(this.form.name,this.name,this.value)"

	function maiusculas(form,cp,vl){

		eval("document."+form+"."+cp+".value='"+vl.toUpperCase()+"'");

	}

	

	//Converte o valor digitado em caixa alta

	//onkeyup="caixa(this.name)"

	function caixa(nome) {

		valor = "";

		valor = eval("document.form1."+nome+".value");

		if (valor != "") {

			//eval("document.form1." + nome + ".value.toUpperCase()");

			valor = valor.toUpperCase();

			//alert(valor);

			eval("document.form1."+nome+".value=\"" + valor + "\"");

		}

	}



	function limpaform(){

		resp = confirm("Tem certeza que deseja limpar os campos do formulário?");

		if (resp) document.forms[0].reset();

	}





	function testa_email(campo,form){

		var reEmail1 = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

		var reEmail2 = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

		var reEmail3 = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

		var reEmail = reEmail1;		

		str = eval("document."+form+"."+campo+".value");

		if (str.length > 0){

			//O campo de e-mail foi preenchido. Verificar!

			if (reEmail.test(str)) {

				//alert(str + " é um endereço de e-mail válido.");

			} else if (str != null && str != "") {

				//alert(str + " NÃO é um endereço de e-mail válido.");

				alert(str + " NÃO é um endereço de e-mail válido.\n Por favor, verifique a sintaxe e preencha o campo corretamente.");

				eval("document."+form+"."+campo+".select()");

			}

		}

	}

	

	//onblur="vld_email(this.name,this.form.name)"

	function vld_email(campo,form) {

		total_email = eval("document."+form+"."+campo+".value.length");			

		texto = eval("document."+form+"."+campo+".value");

	    if (total_email > 1) {

			arroba  = texto.indexOf("@");

			texto = texto.substring(arroba, total_email); 

			ponto = texto.indexOf(".");

			if (arroba == -1 || ponto == -1) {

		    	alert("O endereço de e-mail não é válido\n Por favor, verifique a sintaxe e preencha o campo corretamente.");

				eval("document."+form+"."+campo+".select()");

			}

			

		}



	}			

	

	//onblur="vld_site()"

	function vld_site(form,nome) {

	 	site = eval("document."+form+"."+nome+".value");

		total_site = eval("document."+form+"."+nome+".value.length");

		if (total_site > 1) {

			http = site.indexOf("http://")

			barras = site.indexOf("//")

			if (http != -1 || barras != -1) {

		    	alert("O URL do site não é válido.\n NÃO digite o protocolo \"http://\" no início do endereço.");						

				eval("document."+form+"."+nome+".select()");

			}

		

		}

	}

	

	

	//onblur="vld_numero(this.value, this.name,this.form.name)"

	function vld_numero(campo,nome,form) {

		str = "";

		//alert(nome);

		if (campo.length > 0){

			virgula = campo.indexOf(",");

			if (virgula > 0) {

				str = campo.substring(0,virgula) + "." + campo.substring(virgula + 1, campo.length);

			} else {

				str = campo;

			}

			

			if (isNaN(str)) {

				alert("Atenção!\n O valor desse campo deve ser numérico.");

				seleciona = "document."+form+"."+ nome +".select()";

				eval(seleciona);

			} else {

				eval("document."+form+"."+ nome +".value="+str);

			}			

		}

	}

	

	

	//no campo cep1 ...> onkeydown="foco(this.name, '6', 'cep2')"

	total = 0;			

	function foco(campo1, limite, campo2) {

		total++;

		if (total == limite) {

			total = 0;

			limpacampo = "document.form1."+ campo2 +".value=''";

			limpacampo = eval(limpacampo);

			vaipara = "document.form1."+ campo2 +".focus()";

			vaipara = eval(vaipara)

		}

	}



	function mostra_hoje(nome_campo) {

		dt_atual = new Date();

		dia = dt_atual.getDate();

		if (dia < 10) dia = "0" + dia;

		mes = dt_atual.getMonth() + 1;

		if (mes < 10) mes = "0" + mes;

		ano = dt_atual.getFullYear();

		dt_atual = dia + "/" + mes + "/" + ano;

		eval("document.form1." + nome_campo + ".value = dt_atual");

	}

		

	//onblur="vld_numero(this.value,this.name)"

	/*

	function vld_numero(valor,campo){

		if (isNaN(valor)) {

			alert("Atenção!\nO valor desse campo deve ser numérico!");

			eval("document.form1."+campo+".focus()");

			eval("document.form1."+campo+".select()");

		}

	}

	*/

	//onKeyup="FormataHora(this.value,this.name)" onblur="vld_hora(this.value,this.name)"

	vr_antigo = "";

	function FormataHora(valor,campo) {

		vr_atual = "";

		tam_atual = 0;

		tam_antigo = 0;

		vr_atual = eval("document.form1."+campo+".value");

		tam_atual = eval("document.form1."+campo+".value.length");		

		tam_antigo = vr_antigo.length;

		if (tam_atual == 2 && tam_antigo < tam_atual) eval("document.form1."+campo+".value='"+vr_atual + ":'");

		vr_antigo = vr_atual;

	}

	

	//onKeyup="FormataHora(this.value,this.name)" onblur="vld_hora(this.value,this.name)"

	function vld_hora(valor,campo) {

		vr_atual = "";

		erro = "";

		tam = 0;

		vr = eval("document.form1."+campo+".value");

		tam = eval("document.form1."+campo+".value.length");		

		if (tam != 5 && tam != 0) {

			alert("Atenção!\nA hora deve estar no formato hh:mm.");

			eval("document.form1."+campo+".focus()");

			eval("document.form1."+campo+".select()");

		} else {

			hora = vr.substring(0,2);

			minuto = vr.substring(3,5);

			if (isNaN(hora)) erro += "\nA hora deve ser um número de 00 a 24."

			if (isNaN(minuto)) erro += "\nO valor dos minutos deve ser um número de 00 a 24."

			if (!isNaN(hora) && parseInt(hora) > 24) erro += "\nA hora deve estar dentro de um intervalo válido (00 a 24)."

			if (!isNaN(minuto) && parseInt(minuto) > 59) erro += "\nO valor dos minutos deve estar dentro de um intervalo válido (00 a 59)."

		}

		if (erro != "") {

			alert("Atenção!!" + erro);

			eval("document.form1."+campo+".focus()");

			eval("document.form1."+campo+".select()");			

		}

	}	

	

	

	//onKeyup="FormataData(this.value,this.name,this.form.name)" onblur="vld_data(this.value,this.name,this.form.name)"

	function FormataData(valor,campo,form) {

		vr_atual = "";

		tam_atual = 0;

		tam_antigo = 0;

		vr_atual = eval("document."+form+"."+campo+".value");		

		tam_atual = eval("document."+form+"."+campo+".value.length");		

		tam_antigo = vr_antigo.length;

		if ((tam_atual == 2 || tam_atual == 5) && tam_antigo < tam_atual) {

			eval("document."+form+"."+campo+".value='"+vr_atual + "/'");

		}

		vr_antigo = vr_atual;

	}	

	

	function vld_data(valor,campo,form) {

		vr_atual = "";

		erro = "";

		tam = 0;

		vr = eval("document."+form+"."+campo+".value");

		tam = eval("document."+form+"."+campo+".value.length");		

		if (tam != 10 && tam != 0) {

			alert("Atenção!\nA data deve estar no formato dd/mm/aaaa.");

			eval("document."+form+"."+campo+".focus()");

			eval("document."+form+"."+campo+".select()");

		} else if (tam == 10 && tam != 0){

			dia = vr.substring(0,2);

			mes = vr.substring(3,5);

			ano = vr.substring(7,10)

			ano_ref = new Date();

			if (isNaN(dia)) erro += "\nO dia deve ser um número."

			if (isNaN(mes)) erro += "\nO mês deve ser um número de 01 a 12."

			if (isNaN(ano)) erro += "\nO ano deve ser um número válido de quatro dígitos."

			mes = (mes * 10) /10

			//alert(mes)

			if (!isNaN(mes) && (parseInt(mes) > 0 && parseInt(mes) <= 12)) {

				verifica_mes(mes,ano);

				if (parseInt(ultimo_dia) == 0 || parseInt(dia) > ultimo_dia) {

					erro += "\nO dia do mês deve ser um valor válido para o mês atual.";

				}

			} else {

				//alert(parseInt(mes))

				erro += "\nO mês deve estar dentro de um intervalo válido (01 a 12)."		

			}

		}

		if (erro != "") {

			alert("Atenção!!" + erro);

			eval("document."+form+"."+campo+".focus()");

			eval("document."+form+"."+campo+".select()");			

		}

	}		

	

	function verifica_mes(mes,ano){

		ultimo_dia = 0;

		switch (parseInt(mes)) {

			case 1 :

			case 3 :

			case 5 :

			case 7 :

			case 8 :

			case 10 :

			case 12 :			

				ultimo_dia = 31;

				break;

			case 4 :

			case 6 :

			case 9 :

			case 11 :									

				ultimo_dia = 30;

				break;

			case 2 :

				ultimo_dia = 28;

				

				if (ano % 4 == 0) {

					ultimo_dia = 29;

				} else {

					ultimo_dia = 28;

				}

				if ((ano % 100 == 0) && (ano % 400 != 0)) {

					ultimo_dia = 28;

				}				

				break;

			default :

				ultimo_dia = 0;

				break;

		}

	}

	

	function func_altera(){

		with(document.forms[0]){

			idbusca = 0;

			idbusca = busca_id.value;

			if (idbusca != 0){

				document.forms[0].id.value = idbusca;

				document.forms[0].submit();

			} else {

				alert("Escolha o registro que deseja alterar!");

			}

		}	

	}

	

	function func_restaura(){

		document.form2.id.value = 0;

		document.form2.acao.value = 0;

		document.form2.submit();

	}

		

	function encontra_nome(cp_id, cp_nome){

		document.forms[0].id.value = "";

		with(document.forms[0]){

			idbusca = 0;

			idbusca = eval(cp_id + ".value");

			if (idbusca != 0){

				total = eval(cp_nome + ".length");

				document.form2.id.value = idbusca;

				for(i=1;i<total;i++){

					if (idbusca == eval(cp_nome + ".options[i].value")){

						eval(cp_nome + ".options[i].selected = true");

						break;

					} else {

						eval(cp_nome + ".options[0].selected = true");

					}

				}

			} else {

				eval(cp_nome + ".options[0].selected = true");

			}

		}

	}

	

	function encontra_id(){

		ind = document.forms[0].lista_reg.selectedIndex;

		id = document.forms[0].lista_reg.options[ind].value;

		document.forms[0].id.value = id;

		document.forms[0].submit();

	}

	

	

	//onClick="limpa_campos(this.form)"

	function limpa_campos(formulario){

		resp = confirm("Tem certeza que deseja limpar os campos do formulário?");

		if (resp){

			itens_form = formulario.length;

			for(i=0;i<itens_form;i++){

				tipo = formulario.elements[i].type;

				nome = formulario.elements[i].name;

				if (tipo == "select-one"){

					formulario.elements[i].options[0].selected=true;

				}

				if (tipo == "checkbox" || tipo == "radio"){

					formulario.elements[i].checked=false;

				}

				if (tipo == "text" || tipo == "textarea"){

					formulario.elements[i].value = "";

				}

				if (nome == "id"){

					formulario.elements[i].value = "";

				}				

			}

		}

	}		

	

	

	//Contador de textarea

	//onKeyUp="vld_txtarea(this.name,300,'campocontador')"

	//OBS: o segundo parâmetro acima (ex. 300) deve ser o limite de caracteres que o campo aceita.

	cont = 0;

	function vld_txtarea(campo,limite,contador,form) {

		cont++;

		motivo = eval("document."+form+"."+campo+".value.length;");

		cont = motivo;

		eval("document."+form+"."+contador+".value = cont;");

		valor = eval("document."+form+"."+campo+".value;");

		if (cont > limite) {

			valor = valor.substring(0,limite);

			eval("document."+form+"."+campo+".value = valor;");

			motivo = eval("document."+form+"."+campo+".value.length;");

			cont = motivo;

			eval("document."+form+"."+contador+".value = cont;");		

			alert("Atenção!\n Não é possível gravar mais de "+limite+" caracteres neste campo!");

		}

	}	



	//onFocus="perdefoco(this.name)"

	//serve para impedir a alteração do contador do textarea

	function perdefoco(campo,form) {

		eval("document."+form+"."+campo+".blur();");

	}

	

	function filtra_tipos(){

		ind = document.form1.item_filtro.selectedIndex;

		valor = document.form1.item_filtro.options[ind].value;

		document.form1.submit();

	}

	



	function abre_prospecto(id){

		win_prospecto = eval("window.open('prospecto.asp?link=1&id="+id+"','prospecto','width=500,height=350')");

	}

		

	//Dá o foco na janela

	//<body...onload="foco()">

	function foco(){

		window.focus();

	}	

	

	function win_curso(valor){

		curso = eval("window.open('../../cursos/detalhes.asp?win_popup=1&id="+valor+"','','width=530,height=400,scrollbars=1')");		

	}	

	

	function win_detalhes(valor,url){

		eval("window.open('"+url+"?win_popup=1&id="+valor+"','detalhes','width=530,height=400,scrollbars=1')");		

	}	



	function invalida_tecla(teclapress,campo,form){

		tecla = teclapress.keyCode;

		//alert(tecla);

		if (tecla == 193){

			vl = eval("document."+form+"."+campo+".value");	

			vl_final = vl.substr(0,vl.length - 1);

			//alert(vl_final);

			eval("document."+form+"."+campo+".value='"+vl_final+"'");	

		}

	}

	

//onKeyUp="vld_preco(indicedocampo,event)" onKeyDown="FormataValor(indicedocampo,event)"	

function FormataValor(tammax,teclapres,campo) {

	var tecla = teclapres.keyCode;

	vr = eval("document.form1."+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 ; }

	//alert(tam);

	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){

		if ( tam <= 2 ){ 

	 		eval("document.form1."+campo+".value =vr"); }

		

	 	if ( (tam > 2) && (tam <= 5) ){

	 		eval("document.form1."+campo+".value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam )"); }

		if ( (tam >= 6) && (tam <= 8) ){

	 		eval("document.form1."+campo+".value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam )"); }

		if ( (tam >= 9) && (tam <= 11) ){

	 		eval("document.form1."+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) ){

	 		eval("document.form1."+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) ){

	 		eval("document.form1."+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 )");}	

		

		/*

	 	if ( (tam >= 5) && (tam <= 10) ){

	 		eval("document.form1."+campo+".value = vr.substr( 0, tam - 4 ) + ',' + vr.substr( tam - 4, tam )"); }

		if ( (tam >= 11) && (tam <= 15) ){

	 		eval("document.form1."+campo+".value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 5 ) + ',' + vr.substr( tam - 4, tam )"); }

		if ( (tam >= 16) && (tam <= 21) ){

	 		eval("document.form1."+campo+".value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam )"); }	

		*/

	}

}	



function vld_preco(tammax,teclapres,campo){

	var tecla = teclapres.keyCode;

	vr = eval("document.form1."+campo+".value");

	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){

		eval("document.form1."+campo+".value =" + vr.substr( 0, vr.length - 1 )); }

}



//onKeydown="JavaScript:FormataCPF(this,event)"

function FormataCPF(Campo, teclapres){

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);

	vr = vr.replace(".", "");

	vr = vr.replace(".", "");

	vr = vr.replace("-", "");



	tam = vr.length + 1;

	

	if (tecla != 9 && tecla != 8)

		{

		if (tam > 3 && tam < 7)

			Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);

		if (tam >= 7 && tam <10)

			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);

		if (tam >= 10 && tam < 12)

			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);

		}	

}



function FormataCPFonBlur(Campo){

	var vr = new String(Campo.value);

	vr = vr.replace(".", "");

	vr = vr.replace(".", "");

	vr = vr.replace("-", "");



	tam = vr.length;

	//alert('cpf');

	if (tam >= 10 && tam < 12) {

		//alert(tam);

		Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);

	}	

}



function paginacao(valor){

	//alert(valor);

	document.form_pagina.botao.value = valor;

	document.form_pagina.submit();

}		



	function cad_cursoprereq(){

		 ind = document.form1.idcurso.selectedIndex;

		 valor = document.form1.idcurso.options[ind].value;

		 if (valor > 0 ){

		 	document.form2.id_curso.value = valor;

			document.form2.submit();

		 } else {

		 	alert("Escolha um curso para continuar!");

		 }

	}

	

	function cad_relaciona(){

		 ind = document.form1.idrelaciona.selectedIndex;

		 valor = document.form1.idrelaciona.options[ind].value;

		 if (valor > 0 ){

		 	document.form2.idrelaciona.value = valor;

			document.form2.submit();

		 } else {

		 	alert("Escolha uma filial para continuar!");

		 }

	}

		

	function mostratodasasfiliais(acao){

		document.form2.mostra_todas.value = acao;

		document.form2.submit();

	}

			

	function del(valor){

		resp = confirm("Tem certeza que deseja excluir esse registro?");

		if (resp == true){

			document.form2.id_del.value = valor;

			document.form2.submit();

			document.form2.id_del.value = 0;	

		}

	}	

	

	//<a href="javascript:valida()">

	function valida_login(){

		login = document.form1.login.value;

		senha = document.form1.senha.value;

		if (login == "" && senha == "") {

			alert("É preciso preencher os campos de Login e Senha para continuar!");

			document.form1.login.focus();

		} else if (login == ""){

			alert("É preciso preencher o campo Login para continuar!");

			document.form1.login.focus();		

		} else if (senha == ""){

			alert("É preciso preencher o campo Senha para continuar!");

			document.form1.senha.focus();		

		} else {

			document.form1.submit();

		}

	}	



//onKeydown="JavaScript:FormataCNPJ(this,event)"

function FormataCNPJ(Campo, teclapres){

	//alert(Campo);

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);

	vr = vr.replace(".", "");

	vr = vr.replace(".", "");

	vr = vr.replace("/", "");

	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	if (tecla != 9 && tecla != 8){

		if (tam > 2 && tam < 6)

			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);

		if (tam >= 6 && tam < 9)

			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);

		if (tam >= 9 && tam < 13)

			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);

		if (tam >= 13 && tam < 15)

			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);

		}

		

}	



	function FormataCNPJonBlur(Campo){

		var vr = new String(Campo.value);

		vr = vr.replace(".", "");

		vr = vr.replace(".", "");

		vr = vr.replace("/", "");

		vr = vr.replace("-", "");

		tam = vr.length;

		if (tam >= 13 && tam < 15){

			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);

		}

			

	}	

	//onblur="apenas_numeros(this.value, this.name,this.form.name) - ideal para campo CEP"

	function apenas_numeros(x,campo,form){

		tam = x.length; erro = 0;

		if(tam > 0){

			for(i=0;i<x.length;i++){

				crt = x.charAt(i);

				if (isNaN(crt)) {

					alert("Entre apenas com números inteiros.");

					seleciona = "document."+form+"."+ campo +".select()";

					eval(seleciona);

					erro++;

					break;					

				}

			}

		}

		return erro;

	}



	//Função que permite ordenar a coluna atual (vl)

	function ordena(cp){

		vl = document.form1.ordem.value;

		if (vl == 'ASC') {

			document.form1.ordem.value = "DESC";

		} else {

			document.form1.ordem.value = "ASC";

		}

		document.form1.campo_ordem.value = cp;

		document.form1.submit();

	}	

	

	function vld_clientes(form){

		with(eval("document."+form)){

			ind = idcliente.selectedIndex;

			vl = idcliente.options[ind].value;

		}

		//alert(vl);

		if (!isNaN(vl)) eval(form + ".obra.value = 0");

		eval("document."+form+".submit()");

	}

	

	//Verifica se string é numérica

	function isNum(str){

		  var VBlnIsNum;

		  VIntTam = str.length;

		  VBlnIsNum = true;

		  if (VIntTam == 0){

			  return false;

		  } else  {

			  for (i=0; i < VIntTam; i++){

				  if (str.substring(i,i+1) < '0' || str.substring(i,i+1) >'9'){

					 VBlnIsNum = false;

				  }

			  }

			  return VBlnIsNum;

		  }

	}



	//onBlur="valida_cpf(this.value,this.name,this.form.name)"

	function valida_cpf(vl,campo,form){

		resp = isCPF(vl);

		if (!resp && vl.length > 0){

			msg = "CPF Inválido!\nVerifique o valor digitado e tente novamente.";	

			alert(msg);

			eval("document."+form+"."+campo+".select()");

			eval("document."+form+"."+campo+".focus()");

		}

	}

	

	//onBlur="valida_cnpj(this.value,this.name,this.form.name)"

	function valida_cnpj(vl,campo,form){

		erro = validaCNPJ(vl);

		if (erro.length > 0 && vl.length > 0){

			msg = "CNPJ Inválido!\nVerifique o valor digitado e tente novamente.";

			alert(msg);

			eval("document."+form+"."+campo+".select()");

			eval("document."+form+"."+campo+".focus()");

		}

	}

	

	//Função de validação de CPF

	function isCPF(st) {

		if (st == "")

		  return (false);

		l = st.length;

		

		//aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho

		if ((l == 9) || (l == 8)){

		   for (i = l ; i < 10; i++){

			  st = '0' + st

		   }

		}

		

		l = st.length;

		st2 = "";

		for (i = 0; i < l; i++) {

		  caracter = st.substring(i,i+1);

		  //if ((caracter >= '0') && (caracter <= '9'));

		  if (!isNaN(caracter)) st2 = st2 + caracter;

		}

		//alert(st2);

		if ((st2.length > 11) || (st2.length < 10))

		   return (false);

		if (st2.length==10)

		   st2 = '0' + st2;

		digito1 = st2.substring(9,10);

		digito2 = st2.substring(10,11);

		digito1 = parseInt(digito1,10);

		digito2 = parseInt(digito2,10);

		sum = 0; mul = 10;

		for (i = 0; i < 9 ; i++) {

			digit = st2.substring(i,i+1);

			tproduct = parseInt(digit ,10) * mul;

			sum += tproduct;

			mul--;

		}

		dig1 = ( sum % 11 );

		if ( dig1==0 || dig1==1 )

		   dig1=0;

		else

		  dig1 = 11 - dig1;

		if (dig1!=digito1)

		  return (false);

		sum = 0;

		mul = 11;

		for (i = 0; i < 10 ; i++) {

			digit = st2.substring(i,i+1);

			tproduct = parseInt(digit ,10)*mul;

			sum += tproduct;

			mul--;

		}

		dig2 = (sum % 11);

		if ( dig2==0 || dig2==1 )

		  dig2=0;

		else

		  dig2 = 11 - dig2;

		if (dig2 != digito2)

		  return (false);

		return (true);

	}

	

	function validaCNPJ(CNPJ) {

		erro = new String;

		if (CNPJ.length < 18) erro += "E' necessarios preencher corretamente o numero do CNPJ! \n\n";

		if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){

			if (erro.length == 0) erro += "E' necessarios preencher corretamente o numero do CNPJ! \n\n";

		}

		//substituir os caracteres que nao sao numeros

		if(document.layers && parseInt(navigator.appVersion) == 4){

			x = CNPJ.substring(0,2);

			x += CNPJ.substring(3,6);

			x += CNPJ.substring(7,10);

			x += CNPJ.substring(11,15);

			x += CNPJ.substring(16,18);

			CNPJ = x;	

		} else {

			CNPJ = CNPJ.replace(".","");

			CNPJ = CNPJ.replace(".","");

			CNPJ = CNPJ.replace("-","");

			CNPJ = CNPJ.replace("/","");

		}

		var nonNumbers = /\D/;

		if (nonNumbers.test(CNPJ)) erro += "A verificacao de CNPJ suporta apenas numeros! \n\n";	

		var a = [];

		var b = new Number;

		var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];

		for (i=0; i<12; i++){

			a[i] = CNPJ.charAt(i);

			b += a[i] * c[i+1];

		}

		if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }

		b = 0;

		for (y=0; y<13; y++) {

			b += (a[y] * c[y]); 

		}

		if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }

		if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){

			erro +="Digito verificador com problema!";

		}

		if (erro.length > 0){

			//alert(erro);

			//return false;			

		} else {

			//alert("CNPJ valido!");

		}

		return erro;

	}	

	

	//onBlur="valida_rg(this.value,this.name,this.form.name)"

	function valida_rg(vl,campo,form){

		erro_num = apenas_numeros(vl,campo);

		if (erro_num == 0){

			//O usuário digitou apenas números

			resp = isRG(vl);

			if (!resp && vl.length > 0){

				msg = "Número de RG Inválido!\nVerifique o valor digitado e tente novamente.";	

				alert(msg);

				eval("document."+form+"."+campo+".select()");

				eval("document."+form+"."+campo+".focus()");

			}			

		}

	}

	

	function isRG(numero){

		 /*

		 ##  Igor Carvalho de Escobar

		 ##    www.webtutoriais.com

		 ##   Java Script Developer

		 */

		 resp = true;

		 var numero = numero.split("");

		 tamanho = numero.length;

		 vetor = new Array(tamanho);

	

		if(tamanho>=1){

			vetor[0] = parseInt(numero[0]) * 2; 

		}

		

		if(tamanho>=2){

			vetor[1] = parseInt(numero[1]) * 3; 

		}

	

		if(tamanho>=3){

			vetor[2] = parseInt(numero[2]) * 4; 

		}

	

		if(tamanho>=4){

			vetor[3] = parseInt(numero[3]) * 5; 

		}

		

		if(tamanho>=5){

			vetor[4] = parseInt(numero[4]) * 6; 

		}

		

		if(tamanho>=6){

			vetor[5] = parseInt(numero[5]) * 7; 

		}

		

		if(tamanho>=7){

			vetor[6] = parseInt(numero[6]) * 8; 

		}

		if(tamanho>=8){

			vetor[7] = parseInt(numero[7]) * 9; 

		}

		if(tamanho>=9){

			vetor[8] = parseInt(numero[8]) * 100; 

		}

	

		total = 0;

	

		if(tamanho>=1){

			total += vetor[0];

		}

		if(tamanho>=2){

			total += vetor[1]; 

		}

		if(tamanho>=3){

			total += vetor[2]; 

		}

		if(tamanho>=4){

			total += vetor[3]; 

		}

		if(tamanho>=5){

			total += vetor[4]; 

		}

		if(tamanho>=6){

			total += vetor[5]; 

		}

		if(tamanho>=7){

			total += vetor[6];

		}

		if(tamanho>=8){

			total += vetor[7]; 

		}

		if(tamanho>=9){

			total += vetor[8]; 

		}

	

		resto = total % 11;

		if(resto!=0){

			resp = false;

			//alert("RG Inválido!");

		}

		return resp;

	}

	

	

//-->