var isNN = (navigator.appName.indexOf("Netscape")!=-1); function autoTab(input,len, e) { var keyCode = (isNN) ? e.which : e.keyCode; var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; if(input.value.length >= len && !containsElement(filter,keyCode)) { input.value = input.value.slice(0, len); input.form[(getIndex(input)+1) % input.form.length].focus(); } function containsElement(arr, ele) { var found = false, index = 0; while(!found && index < arr.length) if(arr[index] == ele) found = true; else index++; return found; } function getIndex(input) { var index = -1, i = 0, found = false; while (i < input.form.length && index == -1) if (input.form[i] == input)index = i; else i++; return index; } return true; } function abre_janela(cUrl, width, height, nome) { var top; var left; top = ((screen.height/2) - (height/2)) left = ((screen.width/2) - (width/2)) oJanela = window.open(cUrl,nome,'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top); if (oJanela != null) { oJanela.focus(); } } function recebe_imagem(campo, imagem){ var foto = 'img_' + campo document.form_incluir[campo].value = imagem; document.form_incluir[foto].src = imagem; } function mascara_data(data){ var mydata = ''; mydata = mydata + data; if (mydata.length == 2){ mydata = mydata + '/'; } if (mydata.length == 5){ mydata = mydata + '/'; } return mydata; } function desabilita_cor(campo) { campo.className='campos_formulario' } function checa_numerico(String) { var mensagem = "Este campo aceita somente números" var msg = ""; if (isNaN(String)) msg = mensagem; return msg; } function checa_email(campo) { var mensagem = "Informe corretamente o email" var msg = ""; var email = campo.match(/(\w+)@(.+)\.(\w+)$/); if (email == null){ msg = mensagem; } return msg; } function abre_popup(width, height, nome) { var top; var left; top = ( (screen.height/2) - (height/2) ) left = ( (screen.width/2) - (width/2) ) window.open('',nome,'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top); } function definir_data(dia,mes,ano) { formPesquisa.dia.value=dia; formPesquisa.mes.value=mes; formPesquisa.ano.value=ano; formPesquisa.submit(); } function up_dia() { if(formPesquisa.dia.value==''){ formPesquisa.dia.value=1; } else { if(isNaN(formPesquisa.dia.value)){ formPesquisa.dia.value=1; } else { if (parseInt(formPesquisa.dia.value) < 31){ formPesquisa.dia.value=parseFloat(formPesquisa.dia.value)+1; } } } } function down_dia() { if(formPesquisa.dia.value==''){ formPesquisa.dia.value=1; } else { if(isNaN(formPesquisa.dia.value)){ formPesquisa.dia.value=1; } else { if (parseInt(formPesquisa.dia.value) > 1){ formPesquisa.dia.value=parseFloat(formPesquisa.dia.value)-1; } } } } function up_mes() { if(formPesquisa.mes.value==''){ formPesquisa.mes.value=1; } else { if(isNaN(formPesquisa.mes.value)){ formPesquisa.mes.value=1; } else { if (parseInt(formPesquisa.mes.value) < 12){ formPesquisa.mes.value=parseFloat(formPesquisa.mes.value)+1; } } } } function down_mes() { if(formPesquisa.mes.value==''){ formPesquisa.mes.value=1; } else { if(isNaN(formPesquisa.mes.value)){ formPesquisa.mes.value=1; } else { if (parseInt(formPesquisa.mes.value) > 1){ formPesquisa.mes.value=parseFloat(formPesquisa.mes.value)-1; } } } } function up_ano() { var oData = new Date() if(formPesquisa.ano.value==''){ formPesquisa.ano.value=oData.getFullYear(); } else { if(isNaN(formPesquisa.ano.value)){ formPesquisa.ano.value=1; } else { formPesquisa.ano.value=parseFloat(formPesquisa.ano.value)+1; } } } function down_ano() { var oData = new Date() if(formPesquisa.ano.value==''){ formPesquisa.ano.value=oData.getFullYear(); } else { if(isNaN(formPesquisa.ano.value)){ formPesquisa.ano.value=1; } else { if (parseInt(formPesquisa.ano.value) > 2000){ formPesquisa.ano.value=parseFloat(formPesquisa.ano.value)-1; } } } } function ExibeImgProcessando () { // Exibe imagem centralizada avisando que aguarde o processamento var oImg, nTop, nLeft; // Imagem de "processando, aguarde ..." window.imgProcessando = document.createElement("IMG"); window.imgProcessando.src = 'images/processando.gif'; // Adiciona ao documento document.body.appendChild(window.imgProcessando); // Exibe centalizada oImg = window.imgProcessando; nTop = ((document.body.offsetHeight - oImg.height)/2); nLeft = ((document.body.offsetWidth - oImg.width)/2); oImg.style.position = "absolute"; oImg.style.top = nTop; oImg.style.left= nLeft; oImg.style.visibility= "visible"; oImg.style.display= ""; } function loadImages() { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('hidepage').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.hidepage.visibility = 'hidden'; } else { // IE 4 document.all.hidepage.style.visibility = 'hidden'; } } } function SalvaUsuario() { var cCodigo = ""; var cNome = ""; var cLogin = ""; var cSenha = ""; var cConfSenha = ""; var cParametros = ""; cCodigo = document.getElementById("txtCodigo").value; cNome = document.getElementById("txtNome").value; cLogin = document.getElementById("txtLogin").value; cSenha = document.getElementById("txtSenha").value; cConfSenha = document.getElementById("txtConfirmaSenha").value; if (cCodigo == "" || cCodigo == null) { cCodigo = 0; } if (cLogin == null || cLogin == "") { alert("Por favor informe o Login do Usuário"); document.getElementById("txtLogin").focus(); return false; } if (cNome == null || cNome == "") { alert("Por favor informe o Nome do Usuário"); document.getElementById("txtNome").focus(); return false; } if (cSenha == null || cSenha == "") { alert("Por favor informe a Senha do Usuário"); document.getElementById("txtSenha").focus(); return false; } if (cConfSenha == null || cConfSenha == "") { alert("Por favor informe confirme a Senha do Usuário"); document.getElementById("txtConfirmaSenha").focus(); return false; } if (cSenha != cConfSenha) { alert("Senha não confere"); document.getElementById("txtConfirmaSenha").focus(); return false; } cParametros = "codigo=" + cCodigo + "&nome=" + encodeHtml(cNome) + "&login=" + cLogin + "&senha=" + cSenha; enviaPagina('usuario_salva.asp', 'POST', 'true', 'conteudo', cParametros); } function Excluir(cPagina, nCod) { var cParametros; if (confirm("Confirma a exclusão?") == true) { cParametros = "cod=" + nCod; enviaPagina(cPagina, 'POST', 'true', 'conteudo', cParametros); } } function Editar(cPagina, nCod) { var cParametros; cParametros = "cod=" + nCod; enviaPagina(cPagina, 'POST', 'true', 'conteudo', cParametros); } function encodeHtml(cEncode) { cHtml = escape(cEncode); cHtml = cHtml.replace(/\//g,"%2F"); cHtml = cHtml.replace(/\?/g,"%3F"); cHtml = cHtml.replace(/=/g,"%3D"); cHtml = cHtml.replace(/&/g,"%26"); cHtml = cHtml.replace(/@/g,"%40"); return cHtml; } function mascara(o,f){ v_obj=o v_fun=f setTimeout("execmascara()",1) } function execmascara(){ v_obj.value=v_fun(v_obj.value) } function soNumeros(v){ return v.replace(/\D/g,"") } function SomenteNumero(e){ if(document.all) // Internet Explorer { nTecla = event.keyCode; } else if(document.layers) // Nestcape { nTecla = event.which; } else { nTecla = event.which; if (nTecla == 8) { return true; } } if(nTecla > 47 && nTecla < 58) { return true; } else { if (nTecla != 8) { return false; } else { return true; } } } function Percentual(e){ if(document.all) // Internet Explorer { nTecla = event.keyCode; } else if(document.layers) // Nestcape { nTecla = event.which; } else { nTecla = event.which; if (nTecla == 8) { return true; } } if(nTecla > 47 && nTecla < 58 || nTecla == 44) { return true; } else { if (nTecla != 8) { return false; } else { return true; } } } function ValorPreco(e){ if(document.all) // Internet Explorer { nTecla = event.keyCode; } else if(document.layers) // Nestcape { nTecla = event.which; } else { nTecla = event.which; if (nTecla == 8) { return true; } } if(nTecla > 47 && nTecla < 58 || nTecla == 44) { return true; } else { if (nTecla != 8) { return false; } else { return true; } } } function ShowHide(id_layer){ if( document.getElementById(id_layer).style.display=='none' ){ document.getElementById(id_layer).style.display = ''; } else{ document.getElementById(id_layer).style.display = 'none'; } } function exibeDiv(objeto){ document.getElementById(objeto).style.display = "block"; } function someDiv(objeto){ document.getElementById(objeto).style.display = "none"; } function mostraDiv(objeto){ document.getElementById(objeto).style.visibility = "visible"; } function escondeDiv(objeto){ document.getElementById(objeto).style.visibility = "hidden"; } /* Uso: Formato: mm/dd/yyyy Formato: yyyy/mm/dd Formato: dd/mm/yyyy */ // Check browser version var isNav4 = false, isNav5 = false, isIE4 = false var strSeperator = "/"; // If you are using any Java validation on the back side you will want to use the / because // Java date validations do not recognize the dash as a valid date separator. var vDateType = 3; // Global value for type of date format // 1 = mm/dd/yyyy // 2 = yyyy/dd/mm (Unable to do date check at this time) // 3 = dd/mm/yyyy var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating. var err = 0; // Set the error code to a default of zero 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; // vDateName = object name // vDateValue = value in the field being checked // e = event // dateCheck // True = Verify that the vDateValue is a valid date // False = Format values being entered into vDateValue only // vDateType // 1 = mm/dd/yyyy // 2 = yyyy/mm/dd // 3 = dd/mm/yyyy //Enter a tilde sign for the first number and you can check the variable information. 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; // Check to see if a seperator is already present. // bypass the date if a seperator is present and the length greater than 8 if (vDateValue.length > 8 && isNav4) { if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1)) return true; } //Eliminate all the ASCII codes that are not valid 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) //Ignore the Netscape value for backspace. IE has no value return false; else { //Create numeric string values for 0123456789/ //The codes provided include both keyboard and keypad values 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("Data Inválida\nDigite novamente."); 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) //Turn a two digit year into a 4 digit year if (mYear.length == 2 && vYearType == 4) { var mToday = new Date(); //If the year is greater than 30 years from now use 19, otherwise use 20 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("Data Inválida\nDigite novamente."); vDateName.value = ""; vDateName.focus(); vDateName.select(); return false; } return true; } else { // Reformat the date for validation and set date type to a 1 if (vDateValue.length >= 8 && dateCheck) { if (vDateType == 1) // mmddyyyy { 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) // yyyymmdd { 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) // ddmmyyyy { 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; } //Create a temporary variable for storing the DateType and change //the DateType to a 1 for validation. var vDateTypeTemp = vDateType; vDateType = 1; var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear; if (!dateValid(vDateValueCheck)) { alert("Data Inválida\nDigite novamente."); 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("Data Inválida\nDigite novamente."); vDateName.value = ""; vDateName.focus(); vDateName.select(); return false; } } } } else { // Non isNav Check if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) { alert("Data Inválida\nDigite novamente."); vDateName.value = ""; vDateName.focus(); return true; } // Reformat date to format that can be validated. mm/dd/yyyy if (vDateValue.length >= 8 && dateCheck) { // Additional date formats can be entered here and parsed out to // a valid date format that the validation routine will recognize. if (vDateType == 1) // mm/dd/yyyy { var mMonth = vDateName.value.substr(0,2); var mDay = vDateName.value.substr(3,2); var mYear = vDateName.value.substr(6,4) } if (vDateType == 2) // yyyy/mm/dd { var mYear = vDateName.value.substr(0,4) var mMonth = vDateName.value.substr(5,2); var mDay = vDateName.value.substr(8,2); } if (vDateType == 3) // dd/mm/yyyy { 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("Data Inválida\nDigite novamente."); vDateName.value = ""; vDateName.focus(); return true; } } // Create temp. variable for storing the current vDateType var vDateTypeTemp = vDateType; // Change vDateType to a 1 for standard date format for validation // Type will be changed back when validation is completed. vDateType = 1; // Store reformatted date to new variable for validation. var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear; if (mYear.length == 2 && vYearType == 4 && dateCheck) { //Turn a two digit year into a 4 digit year var mToday = new Date(); //If the year is greater than 30 years from now use 19, otherwise use 20 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; // Store the new value back to the field. This function will // not work with date type of 2 since the year is entered first. if (vDateTypeTemp == 1) // mm/dd/yyyy vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear; if (vDateTypeTemp == 3) // dd/mm/yyyy vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear; } if (!dateValid(vDateValueCheck)) { alert("Data Inválida\nDigite novamente."); 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)) { // Un-comment the next line of code for debugging the dateValid() function error messages //alert(err); alert("Data Inválida\nDigite novamente."); vDateName.focus(); vDateName.select(); } } return false; } else { // If the value is not in the string return the string minus the last // key entered. 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 err = 0; 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 = datefield.value; 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); } } //Adjustment for short years entered 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; } var CorAlerta = "#FFEDD2"; var CorNormal = "#FFFFFF"; function EnviaLogo() { var cNome = ""; var cSexo = ""; var cEmail = ""; var cCidade = ""; var cEstado = ""; var cTelefone = ""; var cTipoTelefone = ""; var cMensagem = ""; var cParametros = ""; cNome = document.getElementById("txtNome").value; cSexo = document.getElementById("txtSexo").value; cEmail = document.getElementById("txtEmail").value; cCidade = document.getElementById("txtCidade").value; cEstado = document.getElementById("txtEstado").value; cTelefone = document.getElementById("txtTelefone").value; cTipoTelefone = document.getElementById("txtTipoTelefone").value; cMensagem = document.getElementById("txtMensagem").value; if (cNome == null || cNome == "") { alert("Por favor informe seu Nome"); document.getElementById("txtNome").style.background = CorAlerta; document.getElementById("txtNome").focus(); return false; } else { document.getElementById("txtNome").style.background = CorNormal; } //---------------------------------------------- if (cEmail == "") { alert("Por favor informe um Email"); document.getElementById("txtEmail").focus(); document.getElementById("txtEmail").style.background = CorAlerta; return false; } else { var msg = checa_email(document.getElementById("txtEmail").value); if (msg != "") { alert(msg); document.getElementById("txtEmail").focus(); document.getElementById("txtEmail").style.background = CorAlerta; return false; } document.getElementById("txtEmail").style.background = CorNormal; } cParametros = "txtNome=" + encodeHtml(cNome) + "&txtSexo=" + encodeHtml(cSexo) + "&txtEmail=" + encodeHtml(cEmail) + "&txtCidade=" + encodeHtml(cCidade) + "&txtEstado=" + encodeHtml(cEstado) + "&txtTelefone=" + encodeHtml(cTelefone) + "&txtTipoTelefone=" + encodeHtml(cTipoTelefone) + "&txtMensagem=" + encodeHtml(cMensagem); //alert(cParametros); enviaPagina('faleconosco.asp', 'POST', 'true', 'conteudo', cParametros); } var CorAlerta = "#FFEDD2"; var CorNormal = "#FFFFFF"; function Busca(cPagina, cNome) { var cNome; var cCod; cNome = ""; cCod = ""; cNome = document.getElementById("txtBusca").value; cCod = document.getElementById("txtCod").value; if ((cNome == "" || cNome == null) && (cCod == "" || cCod == null)) { document.getElementById("txtBusca").style.background = CorAlerta; document.getElementById("txtCod").style.background = CorAlerta; document.getElementById("txtBusca").focus(); alert("Preencha pelo menos um campo"); return false; } else { document.getElementById("txtBusca").style.background = CorNormal; document.getElementById("txtCod").style.background = CorNormal; } var cParametros; cParametros = "cNome=" + encodeHtml(cNome) + "&cCod=" + cCod; enviaPagina(cPagina, 'POST', 'true', 'conteudo', cParametros); } function BuscaPedido(cPagina, cNome) { var cNome; var cCod; cNome = ""; cCod = ""; cNome = document.getElementById("txtBuscap").value; cCod = document.getElementById("txtCod").value; if ((cNome == "" || cNome == null) && (cCod == "" || cCod == null)) { document.getElementById("txtBuscap").style.background = CorAlerta; document.getElementById("txtCod").style.background = CorAlerta; document.getElementById("txtBuscap").focus(); alert("Preencha pelo menos um campo"); //return false; } else { document.getElementById("txtBuscap").style.background = CorNormal; document.getElementById("txtCod").style.background = CorNormal; var cParametros; cParametros = "cNome=" + encodeHtml(cNome) + "&cCod=" + cCod; enviaPagina(cPagina, 'POST', 'true', 'conteudo', cParametros); } } function BuscaPedidoCliente(cPagina, cNome) { var cNome; var cCod; cNome = ""; cCod = ""; cNome = document.getElementById("txtBuscap").value; cCod = document.getElementById("txtCod").value; cTipoPedido = document.getElementById("tipopedido").value; if ((cNome == "" || cNome == null) && (cCod == "" || cCod == null)) { document.getElementById("txtBuscap").style.background = CorAlerta; document.getElementById("txtCod").style.background = CorAlerta; document.getElementById("txtBuscap").focus(); alert("Preencha pelo menos um campo"); //return false; } else { document.getElementById("txtBuscap").style.background = CorNormal; document.getElementById("txtCod").style.background = CorNormal; var cParametros; cParametros = "cNome=" + encodeHtml(cNome) + "&cCod=" + cCod + "&tipopedido=" + encodeHtml(cTipoPedido); enviaPagina(cPagina, 'POST', 'true', 'cliente_painel', cParametros); } } function BuscaPedidoData(cPagina, cNome) { cTipoPedido = document.getElementById("tipopedido").value; cDtInic = document.getElementById("txtDtPeriodoInic").value; cDtFim = document.getElementById("txtDtPeriodoFim").value; var cParametros; cParametros = "txtDtPeriodoInic=" + encodeHtml(cDtInic) + "&txtDtPeriodoFim=" + encodeHtml(cDtFim) + "&tipopedido=" + encodeHtml(cTipoPedido); enviaPagina(cPagina, 'POST', 'true', 'cliente_painel', cParametros); } function SalvaStatus(nPedido) { var cFlTipo = ""; var oRadio = document.getElementsByTagName("INPUT"); for (nCont = 0; nCont < oRadio.length; nCont++) { var item = oRadio[nCont]; if (item.type == "radio" && item.checked) { if (item.id == 'optSituacao') { cFlTipo = cFlTipo + item.value; break; } } } if (cFlTipo == "" || cFlTipo == null) { alert("Por favor informe o status do pedido"); } else { var cParametros; cParametros = "cTipo=" + encodeHtml(cFlTipo) + "&Cod=" + nPedido; enviaPagina("atualiza_status_pedido.asp", 'POST', 'true', 'conteudo', cParametros); } } function ListaPedido() { var cNome; var cCod; var cStatus; var cCpf; cNome = ""; cCod = ""; cStatus = ""; cCpf = ""; cNome = document.getElementById("txtBusca").value; cCod = document.getElementById("txtCod").value; cCpf = document.getElementById("txtCpf").value; cStatus = document.getElementById("Status").value; cDtInic = document.getElementById("txtDtPeriodoInic").value; cDtFim = document.getElementById("txtDtPeriodoFim").value; var cParametros; cParametros = "Status=" + encodeHtml(cStatus) + "&cNome=" + encodeHtml(cNome) + "&cCod=" + cCod + "&cCpf=" + cCpf + "&txtDtPeriodoInic=" + encodeHtml(cDtInic) + "&txtDtPeriodoFim=" + encodeHtml(cDtFim); enviaPagina("lista_pedido.asp", 'POST', 'true', 'conteudo', cParametros); } function CampoInformado ( oCampo, bMens ) { var cValor; var cMens; var cNome; cNome=oCampo.name; if ( cNome.substr(0, 3) == "cmb" ) { cValor = oCampo.value; } else { cValor = RetiraEspacos (oCampo.value); } if ( cValor == "" ) { if ( bMens == true ) { cMens = 'Campo requerido não preenchido !'; if ( oCampo.title || '' != '' ) { cMens += ' (' + oCampo.title; } else { cMens += ' (' + oCampo.name; } cMens += ')'; ExibeMens ( cMens ); } return ( false ); } else { return ( true ); } } function RetiraEspacos ( cString ) { var cAux; cAux = cString; cAux = ( cAux.replace ( /^ +/, '' ) ).replace ( / +$/ ,'' ); return ( cAux ); } function Preenche ( cString, cChar, cEsqDir, nTam ) { var cAux=new String(cString); var nMax=(parseInt (nTam, 10) - cAux.length); var nCont; cChar=cChar.substr(0,1) cEsqDir=cEsqDir.substr(0,1); cEsqDir=cEsqDir.toUpperCase(); for ( nCont = 1; nCont <= nMax; nCont++ ) { if (cEsqDir == "E") { cAux=cChar + cAux; } else { cAux+=cChar; } } return (cAux); } function ValidaData ( oCampo ) { if ( CampoInformado ( oCampo, false ) == false ) { return ( true ); } var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; var dateStr = new String(oCampo.value); if (dateStr.length == 1) { dateStr = '0' + dateStr; } if (dateStr.length == 2) { var cDtAtual = new Date(); dateStr += Preenche ((cDtAtual.getMonth() + 1), '0', 'E', 2); dateStr += cDtAtual.getFullYear(); } if (dateStr.length == 4) { var cDtAtual = new Date(); dateStr += cDtAtual.getFullYear(); } else { if (dateStr.length == 5 && dateStr.substr(2,1) == '/') { var cDtAtual = new Date(); dateStr += '/' + cDtAtual.getFullYear(); } } if ( dateStr.indexOf ( "/" ) == -1 && ( dateStr.length == 6 || dateStr.length == 8 ) ) { dateStr = dateStr.substr ( 0, 2 ) + "/" + dateStr.substr ( 2, 2 ) + "/" + dateStr.substr ( 4, 4 ); } var matchArray = dateStr.match ( datePat ); if ( matchArray == null ) { event.returnValue = false; ExibeMens ( "Formato de data inválida! (deve ser dia/mes/ano ou ddmmaaaa)" ); oCampo.value=''; oCampo.focus (); return ( false ); } nMes = matchArray [ 3 ]; nDia = matchArray [ 1 ]; nAno = matchArray [ 4 ]; if ( nAno.length == 2 ) { if ( parseInt ( nAno, 10 ) < 40 ) nAno = "20" + nAno; else nAno = "19" + nAno; } else { if ( nAno < 1900 || nAno > 2100 ) { ExibeMens ( "Ano inválido.(deve ser de 1900 a 2100)." ); oCampo.value=''; oCampo.focus (); return ( false ); } } if ( nMes < 1 || nMes > 12 ) { ExibeMens ( "Mês inválido.(deve ser de 1 a 12)." ); oCampo.value=''; oCampo.focus (); return ( false ); } if ( nDia < 1 || nDia > 31 ) { ExibeMens ( "Dia inválido. (deve ser de 1 a 31)." ); oCampo.value=''; oCampo.focus (); return ( false ); } if ( (nMes==4 || nMes==6 || nMes==9 || nMes==11) && nDia == 31 ) { ExibeMens ( "O mês " + nMes + " não tem 31 dias!" ) oCampo.value=''; oCampo.focus (); return ( false ); } if ( nMes == 2 ) { var isleap = (nAno % 4 == 0 && (nAno % 100 != 0 || nAno % 400 == 0)); if ( nDia>29 || (nDia==29 && !isleap)) { ExibeMens ( "Fevereiro " + nAno + " não tem " + nDia + " dias!" ); oCampo.value=''; oCampo.focus (); return ( false ); } } dateStr=Preenche(nDia,"0","E",2) + "/" + Preenche(nMes,"0","E",2) + "/" + nAno; if (oCampo.value != dateStr) oCampo.value = dateStr; return ( true ); } function ValidaMesAno ( oCampo ) { if ( CampoInformado ( oCampo, false ) == false ) { return ( true ); } var datePat = /^(\d{1,2})(\/|-)(\d{2}|\d{4})$/; var dateStr = new String(oCampo.value); if (dateStr.length == 2) { var cDtAtual = new Date(); dateStr += cDtAtual.getFullYear(); } if ( dateStr.indexOf ( "/" ) == -1 && ( dateStr.length == 4 || dateStr.length == 6 ) ) { dateStr = dateStr.substr ( 0, 2 ) + "/" + dateStr.substr ( 2, 4 ); } var matchArray = dateStr.match ( datePat ); if ( matchArray == null ) { event.returnValue = false; ExibeMens ( "Formato de mes/ano inválido! (deve ser mes/ano ou mmaaaa)" ); oCampo.value=''; oCampo.focus (); return ( false ); } nMes = matchArray [ 1 ]; nAno = matchArray [ 3 ]; if ( nAno.length == 2 ) { if ( parseInt ( nAno, 10 ) < 40 ) nAno = "20" + nAno; else nAno = "19" + nAno; } else { if ( nAno < 1900 || nAno > 2100 ) { ExibeMens ( "Ano inválido.(deve ser de 1900 a 2100)." ); oCampo.value=''; oCampo.focus (); return ( false ); } } if ( nMes < 1 || nMes > 12 ) { ExibeMens ( "Mês inválido.(deve ser de 1 a 12)." ); oCampo.value=''; oCampo.focus (); return ( false ); } dateStr=Preenche(nMes,"0","E",2) + "/" + nAno; if (oCampo.value != dateStr) oCampo.value = dateStr; return ( true ); } function ValidaHora ( oCampo ) { if ( CampoInformado ( oCampo, false ) == false ) { return ( true ); } var hrPat = /^(\d{1,2})(:)(\d{1,2})$/; var hrStr = new String(oCampo.value); if (hrStr.length == 1) { hrStr = '0' + hrStr; } if (hrStr.length == 2) { hrStr += '00'; } if ( hrStr.indexOf ( ":" ) == -1 && hrStr.length == 4 ) { hrStr = hrStr.substr ( 0, 2 ) + ":" + hrStr.substr ( 2, 2 ); } var matchArray = hrStr.match ( hrPat ); if ( matchArray == null ) { event.returnValue = false; ExibeMens ( "Formato de hora inválida! (deve ser hh:mm ou hhmm)" ); oCampo.value=''; oCampo.focus (); return ( false ); } nHora = matchArray [ 1 ]; nMin = matchArray [ 3 ]; if ( nHora < 0 || nHora > 23 ) { ExibeMens ( "Hora inválida.(deve ser de 0 a 23)." ); oCampo.value=''; oCampo.focus (); return ( false ); } if ( nMin < 0 || nMin > 59 ) { ExibeMens ( "Minuto inválido. (deve ser de 0 a 59)." ); oCampo.value=''; oCampo.focus (); return ( false ); } hrStr=Preenche(nHora,"0","E",2) + ":" + Preenche(nMin,"0","E",2); if (oCampo.value != hrStr) oCampo.value = hrStr; return ( true ); } function ExibeCalend() { var oData = new Date(); var cData = ""; oCampoData = arguments[0]; if (oCampoData.disabled == true) { return; } oCampoData.style.position = "relative"; FrameCalend = document.all("frameCalend"); if (FrameCalend == null) { FrameCalend =document.createElement( ""); document.body.insertBefore(FrameCalend); } else { FrameCalend = document.all.frameCalend; } FrameCalend.style.position = "absolute"; FrameCalend.style.left = oCampoData.offsetLeft + 10; var nOffSetTop = oCampoData.offsetTop; var nOffSetHeight = oCampoData.offsetHeight; var nPixelHeight = FrameCalend.style.pixelHeight; var nScrollTop = document.body.scrollTop; FrameCalend.style.top = nOffSetTop+nOffSetHeight; if (oCampoData.value == "") { oData = new Date(); cData = oData.getDate() + '/' + (oData.getUTCMonth() + 1) + '/' + oData.getFullYear() } else { cData = oCampoData.value; } if (FrameCalend.style.display == "block") { FrameCalend.style.display = "none"; return; } MontaCalend(cData); FrameCalend.style.display = "none"; FrameCalend.style.display = "block"; } function MontaCalend (cData) { var sHTML = new String(); var nAno; var nMes; var nDia; var oData; var cSepData; cSepData = cData.split('/'); nAno = new String (cSepData[2]); nMes = new String (cSepData[1] -1); nDia = new String (cSepData[0]); sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += '
'; sHTML += MontaCalendMes(nAno, nMes, nDia); sHTML += '
'; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += ''; sHTML += '' sHTML += ''; self.frameCalend.document.open(); self.frameCalend.document.write(sHTML); self.frameCalend.document.close(); } function MontaCalendMes(nAno, nMes, nDia) { var cCalend = new String(); var oData= new Date(nAno, nMes, nDia); var oDtAtual = new Date(); aMes = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'); aDia = new Array('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'); aDiaReduz = new Array('Dom','Seg','Ter','Qua','Qui','Sex','Sab'); var nDiasMes = NrDiasMes(oData.getMonth()+1, oData.getYear()); var nPrimeiroDiaMes = new Date(oData.getYear(), oData.getMonth(), 1); var cProxAno = 1 + '/' + (nPrimeiroDiaMes.getUTCMonth()+ 1) + '/' + (nPrimeiroDiaMes.getFullYear() +1); var cAnoAnt = 1 + '/' + (nPrimeiroDiaMes.getUTCMonth()+ 1) + '/' + (nPrimeiroDiaMes.getFullYear() -1); var cProxMes = 1 + '/' + (nPrimeiroDiaMes.getUTCMonth()+ 2) + '/' + (nPrimeiroDiaMes.getFullYear()); var cMesAnt = 1 + '/' + (nPrimeiroDiaMes.getUTCMonth()+ 0) + '/' + (nPrimeiroDiaMes.getFullYear()); var cOpcoesTDAcao = 'style="cursor:hand;" onmouseover="this.style.backgroundColor=\'#FF6600\';" onmouseout="this.style.backgroundColor=\'\';"'; var nSemanas=0; cCalend = ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cCalend += ''; cDiasSemana = ''; for (i in aDiaReduz) { cDiasSemana += ''; } cDiasSemana += ''; cCalend += cDiasSemana; for (i=0; i < nPrimeiroDiaMes.getDay(); i++) { cCalend += MontaCalendDiaMensAnt(nPrimeiroDiaMes.getDay() - i, oData); } nSemanas=1; for (i=1; i < nDiasMes+1; i++) { oData.setDate(i); cCalend += MontaCalendDia(i, oData); if (oData.getDay() == 6) { cCalend +=''; nSemanas++; } } document.all.frameCalend.style.height=(nSemanas > 5)?138:122; return cCalend; } function MontaCalendDiaMensAnt(nOffSetDia, oData) { var nNrDia; var oDtAux = new Date(oData.getYear(), oData.getMonth(), (- nOffSetDia) + 1) var cAux = new String(); nNrDia = oDtAux.getDate(); cAux = ''; return cAux; } function MontaCalendDia(nNrDia, oData) { var cData = new String(); var cAux = new String(); var oDtAtual = new Date(); cData = FormataData (nNrDia + '/' + (oData.getMonth() + 1) + '/' + oData.getFullYear()); if (oData.getFullYear() == oDtAtual.getFullYear() && oData.getMonth() == oDtAtual.getMonth() && nNrDia == oDtAtual.getDate()) { cAux += ''; return cAux; } function EscondeCalend() { FrameCalend.style.display = "none"; oCampoData.focus(); } function ProximoMes(oData) { if (oData.getMonth == 11) { oData.setMonth(0); oData.setYear(oData.getYear() + 1); } else { oData.setMonth(oData.getMonth() + 1); } return oData; } function NrDiasMes(nMes, nAno) { var oDtAnt = new Date(nAno, nMes, 0); return oDtAnt.getDate(); } function FormataData ( cStr ) { if (cStr == "" || cStr == null) { return; } var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; var dateStr = new String(cStr); if ( dateStr.indexOf ( "/" ) == -1 && (dateStr.length == 6 || dateStr.length == 8)) { dateStr = dateStr.substr ( 0, 2 ) + "/" + dateStr.substr ( 2, 2 ) + "/" + dateStr.substr ( 4, 4 ); } var matchArray = dateStr.match(datePat); if (matchArray == null) { ExibeMens("Formato de data inválida! (deve ser dia/mes/ano)"); return ""; } nMes = matchArray[3]; nDia = matchArray[1]; nAno = matchArray[4]; if (nAno.length == 2) { if (parseInt(nAno, 10) < 40) nAno="20" + nAno; else nAno="19" + nAno; } dateStr=Preenche(nDia,"0","E",2) + "/" + Preenche(nMes,"0","E",2) + "/" + nAno; return ( dateStr ); } function Preenche ( cString, cChar, cEsqDir, nTam ) { var cAux=new String(cString); var nMax=(parseInt (nTam, 10) - cAux.length); var nCont; cChar=cChar.substr(0,1) cEsqDir=cEsqDir.substr(0,1); cEsqDir=cEsqDir.toUpperCase(); for ( nCont = 1; nCont <= nMax; nCont++ ) { if (cEsqDir == "E") cAux=cChar + cAux; else cAux+=cChar; } return (cAux); } function ExibeMens (cMensagem, bErro, bAutoLimpar, bAlert) { window.alert ( cMensagem ); } function Mascara_Hora(Hora){ SomenteNumero(event) var hora01 = ''; hora01 = hora01 + Hora.value; if (hora01.length == 2){ hora01 = hora01 + ':'; Hora.value = hora01; } //if (hora01.length == 5){ // Verifica_Hora(Hora); //} } function Verifica_Hora(Hora, bLimpa){ if (Hora.value == "" || Hora.value == null) { return } hrs = (Hora.value.substring(0,2)); min = (Hora.value.substring(3,5)); estado = ""; if ((hrs < 00 ) || (hrs > 23) || (hrs == null || hrs == "") || ( min < 00) ||( min > 59) || (min == null || min == "")){ estado = "errada"; } if (Hora.value == "") { estado = "errada"; } if (estado == "errada") { alert("Hora inválida!"); if (bLimpa = true) { Hora.value = ""; } Hora.focus(); } } 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; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } } sValue = "" + objForm[strField].value; // Limpa todos os caracteres de formatação que // já estiverem no campo. // toString().replace [transforma em sring e troca elementos por ""] 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( " ", "" ); 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) == ".") || (sMask.charAt(i) == "/")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ") || (sMask.charAt(i) == ".")) //Se for true utiliza elementos especiais aumenta a máscara if (bolMask) { sCod += sMask.charAt(i); mskLen++; //Caso false mostra o sValue(o q foi digitado) } 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 $(obj) { return document.getElementById(obj);} function MM_showHideLayers() { //v9.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v; } } function tabselect(nTotal,nItem){ for(x=1;x<=nTotal;x++){ panel=eval('document.getElementById("panel' + x + '").style;'); if(x==nItem){ panel.display='inline'; } else { panel.display='none'; } } } function selTab2(tab){ tabs = document.getElementsByTagName("div"); for (n=0;n < tabs.length ;n++) { if (tabs[n].id == tab){ tabs[n].style.display = "inline"; } else { tabs[n].style.display = "none"; } } } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); } String.prototype.ltrim = function() { return this.replace(/^\s+/, ''); } String.prototype.rtrim = function() { return this.replace(/\s+$/, ''); } function formataValor(campo) { campo.value = filtraCampo(campo); vr = campo.value; tam = vr.length; 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 <= 18) ){ 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 filtraCampo(campo){ var s = ""; var cp = ""; vr = campo.value; tam = vr.length; for (i = 0; i < tam ; i++) { if (vr.substring(i,i + 1) != "/" && vr.substring(i,i + 1) != "-" && vr.substring(i,i + 1) != "." && vr.substring(i,i + 1) != "," ){ s = s + vr.substring(i,i + 1);} } campo.value = s; return cp = campo.value } function FechaJanela() { window.close(); } function Formata(campo,tammax,teclapres,decimal) { var tecla = teclapres.keyCode; if(tecla > 47 && tecla < 58) { vr = Limpar(campo.value,"0123456789"); tam = vr.length; dec=decimal 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 <= dec ) { campo.value = vr ; } if ( (tam > dec) && (tam <= 5) ){ campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; } if ( (tam >= 6) && (tam <= 8) ){ campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, 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 - dec, 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 - dec, 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 ) ;} } } else { teclapres.keyCode = 0; } } function Limpar(valor, validos) { // retira caracteres invalidos da string var result = ""; var aux; for (var i=0; i < valor.length; i++) { aux = validos.indexOf(valor.substring(i, i+1)); if (aux>=0) { result += aux; } } return result; } function DefinePosicao(valor){ document.getElementById('txtPosicao').value = valor; } function FormataReal(nvalor){ nvalor = nvalor.replace(".",""); nvalor = nvalor.replace(",","."); return nvalor; } function FormataValor(objeto,teclapres,tammax,decimais) { var tecla = teclapres.keyCode; var tamanhoObjeto = objeto.value.length; if ((tecla == 8) && (tamanhoObjeto == tammax)) { tamanhoObjeto = tamanhoObjeto - 1 ; } if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax)) { vr = objeto.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 > 1)) { tam = tam - 1 ; vr = objeto.value; vr = vr.replace( "/", "" ); vr = vr.replace( "/", "" ); vr = vr.replace( ",", "" ); vr = vr.replace( ".", "" ); vr = vr.replace( ".", "" ); vr = vr.replace( ".", "" ); vr = vr.replace( ".", "" ); } if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) { if (decimais > 0) { if ( (tam <= decimais) ) { objeto.value = ("0," + vr) ; } if( (tam == (decimais + 1)) && (tecla == 8)) { objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ; } if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) && ((vr.substr(0,1)) == "0")) { objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ; } if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) && ((vr.substr(0,1)) != "0")) { objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; } if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) ) { objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ; } if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) ) { objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ; } if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) ) { objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ; } if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) ) { objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ; } } else if(decimais == 0) { if ( tam <= 3 ) { objeto.value = vr ; } if ( (tam >= 4) && (tam <= 6) ) { if(tecla == 8) { objeto.value = vr.substr(0, tam); window.event.cancelBubble = true; window.event.returnValue = false; } objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); } if ( (tam >= 7) && (tam <= 9) ) { if(tecla == 8) { objeto.value = vr.substr(0, tam); window.event.cancelBubble = true; window.event.returnValue = false; } objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); } if ( (tam >= 10) && (tam <= 12) ) { if(tecla == 8) { objeto.value = vr.substr(0, tam); window.event.cancelBubble = true; window.event.returnValue = false; } objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); } if ( (tam >= 13) && (tam <= 15) ) { if(tecla == 8) { objeto.value = vr.substr(0, tam); window.event.cancelBubble = true; window.event.returnValue = false; } objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ; } } } } else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46)) { window.event.cancelBubble = true; window.event.returnValue = false; } }
HojeCalendário - ' + oData.getFullYear() + 'Sair
<<<' + aMes[oData.getMonth()] + '>>>
' + aDiaReduz[i] +'
'; cAux += ''; cAux += nNrDia + '' + nNrDia + ''; cAux +='