			
			function CheckFieldEd(campoCheck,campoDisab){
				var cCheck = document.form[campoCheck];
				var cDisab = document.form[campoDisab];

				if (cCheck.checked == 1) {
					cDisab.disabled = false;
				} else {
					cDisab.disabled = true;
				}
			}
			
			function CheckFieldHabilit(){
				if (document.form.habilitacao.checked == 1) {
					document.form.habilitacao_nr.disabled = false;
					document.form.habilitacao_tipos.disabled = false;
					document.form.habilitacao_vct.disabled = false;
				} else {
					document.form.habilitacao_nr.disabled = true;
					document.form.habilitacao_tipos.disabled = true;
					document.form.habilitacao_vct.disabled = true;
				}
			}
			
			function mascaraCNPJ(campoCNPJ,campoNext){
				var cnpj = document.form[campoCNPJ].value;
				if (cnpj.length == 2){
					cnpj = cnpj + '.';
					document.form[campoCNPJ].value = cnpj;
					return true;
				}
				if (cnpj.length == 6){
					cnpj = cnpj + '.';
					document.form[campoCNPJ].value = cnpj;
					return true;
				}
				if (cnpj.length == 10){
					cnpj = cnpj + '/';
					document.form[campoCNPJ].value = cnpj;
					return true;
				}
				if (cnpj.length == 15){
					cnpj = cnpj + '-';
					document.form[campoCNPJ].value = cnpj;
					return true;
				}
				if (cnpj.length == 18 && campoNext != ""){
					document.form[campoNext].focus();
					return true;
				}
			}
			
			function mascaraCEP(campoCEP,campoNext){
				var cep = document.form[campoCEP].value;
				if (cep.length == 5){
					cep = cep + '-';
					document.form[campoCEP].value = cep;
					return true;
				}
				if (cep.length == 9 && campoNext != ""){
					document.form[campoNext].focus();
					return true;
				}
			}

			function mascaraData(campoData,campoNext){
				var data = document.form[campoData].value;
				if (data.length == 2){
					data = data + '/';
					document.form[campoData].value = data;
					return true;
				}
				if (data.length == 5){
					data = data + '/';
					document.form[campoData].value = data;
					return true;
				}
				if (data.length == 10 && campoNext != ""){
					document.form[campoNext].focus();
					return true;
				}
			}
			
			function mascaraHora(campoHora,campoNext){
				var hora = document.form[campoHora].value;
				if (hora.length == 2){
					hora = hora + ':';
					document.form[campoHora].value = hora;
					return true;
				}
				if (hora.length == 5 && campoNext != ""){
					document.form[campoNext].focus();
					return true;
				}
			}
			
			function mascaraFone(campoFone){
				var fone = document.form[campoFone].value;
				if (fone.length == 2){
					fone = fone + ' ';
					document.form[campoFone].value = fone;
					return true;
				}
			}
			
			function mascaraCPF(campoCPF,campoNext){
				var cpf = document.form[campoCPF].value;
				if (cpf.length == 3){
					cpf = cpf + '.';
					document.form[campoCPF].value = cpf;
					return true;
				}
				if (cpf.length == 7){
					cpf = cpf + '.';
					document.form[campoCPF].value = cpf;
					return true;
				}
				if (cpf.length == 11){
					cpf = cpf + '-';
					document.form[campoCPF].value = cpf;
					return true;
				}
				if (cpf.length == 14 && campoNext == "xx"){
					document.form.submit();
					return true;
				}
				if (cpf.length == 14 && campoNext != "" && campoNext != "xx"){
					document.form[campoNext].focus();
					return true;
				}
			}
			
			function FormataValor(campo,tammax,teclapres) {
			
				var tecla = teclapres.keyCode;
				vr = document.form[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 ){ 
						document.form[campo].value = vr ; }
					if ( (tam > 2) && (tam <= 5) ){
						document.form[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
					if ( (tam >= 6) && (tam <= 8) ){
						document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
					if ( (tam >= 9) && (tam <= 11) ){
						document.form[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) ){
						document.form[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) ){
						document.form[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 ) ;}
				}
					
				for (var ct = 0; ct < document.form.elements.length; ct++) {
					if (document.form.elements[ct].name == document.form.elements[campo].name) {
						if ( !teclapres.shiftKey && tecla == 9 && document.form.elements[ct+1] && document.form.elements[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
							document.applets['tclJava'].setFocus();
						}	
					}
				}
			}
			
			function MM_openBrWindow(theURL,winName,features) { //v2.0
			window.open(theURL,winName,features);
			}

			function DisplayInfo(pagina,janela,w,h,scrolling) {
			 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
			}

			function imprimir(id) {
			 DisplayInfo("imprimir.php?id="+id,"imprimir",600,500,"yes","no");
			}

			function artigos (cid) {
				 location.replace('$config[site]artigos.php?in=lista&cid='+cid);
			}
			
			function DisplayInfo(pagina,janela,w,h,scrolling) {
			 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
			}
	
	
			function boldThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<b>" + strSelection 
				+ "</b>" 
				return;
			}
			
			function italicThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<i>" + strSelection 
				+ "</i>" 
				return;
			}
			
			function underlineThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<u>" + strSelection 
				+ "</u>" 
				return;
			}
			
			function changecolor(t) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<font" + " color" +"=" +t+">" + strSelection 
				+ "</font>" 
				return;
			}
			
			function changesize(t) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<font" + " class" +"=" +t+">" + strSelection 
				+ "</font>" 
				return;
			}

			function nbspThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				alert("Selecione um caracter.."); 
				} 
				else document.selection.createRange().text = "&nbsp; &nbsp; " 
				return;
			}
			
			function produtos (tipo,id,cid) {
			  if(tipo == '1') {
				 location.replace('$config[site]admin/?on=produtos&in=novo_prod&cid='+cid);
			  } else {
				 location.replace('$config[site]admin/?on=produtos&in=editar_produto&id='+id+'&cid='+cid);
			  }
			}

		    function clearall (form) {
				form.reset();
		    }

			function changeLine(name,opt){
				var lista = document.getElementsByName(name);
				for (i=0; i<lista.length; i++){
				  lista[i].style.background = opt;
				}
			}