var valida = ''; var obr_msg = true; // When the page loads: function ativaObj() { if (document.getElementsByTagName) { // Get all the tags of type object in the page. var objs = document.getElementsByTagName("object"); for (i=0; i < objs.length; i++) { // Get the HTML content of each object tag // and replace it with itself. objs[i].outerHTML = objs[i].outerHTML; } } } window.onload = ativaObj; function desativaObj() { // When the page unloads: if (document.getElementsByTagName) { //Get all the tags of type object in the page. var objs = document.getElementsByTagName("object"); for (i=0; i < objs.length; i++) { // Clear out the HTML content of each object tag // to prevent an IE memory leak issue. objs[i].outerHTML = ""; } } } window.onunload = desativaObj; function OpenWin(URL, Nome, W, H, T, L, resizable) { if (T == undefined) T = '200'; if (L == undefined) L = '130'; if (resizable == undefined) resizable = 'no'; var Janela = window.open(URL, Nome,'alwaysLowered=yes,alwaysRaised=no,dependent=yes,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=' + resizable + ',scrollbars=yes,status=no,titlebar=no,toolbar=no,width=' + W + ',height=' + H + ',z-lock=yes,left=' + L + ',top=' + T) } function getPosicaoElemento(elemID) { var offsetTrail = document.getElementById(elemID); var offsetLeft = 0; var offsetTop = 0; while (offsetTrail) { offsetLeft += offsetTrail.offsetLeft; offsetTop += offsetTrail.offsetTop; offsetTrail = offsetTrail.offsetParent; } if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") { offsetLeft += document.body.leftMargin; offsetTop += document.body.topMargin; } return {left:offsetLeft, top:offsetTop}; } function getPosicaoElementoParent(elemID) { var offsetTrail = parent.document.getElementById(elemID); var offsetLeft = 0; var offsetTop = 0; while (offsetTrail) { offsetLeft += offsetTrail.offsetLeft; offsetTop += offsetTrail.offsetTop; offsetTrail = offsetTrail.offsetParent; } if (navigator.userAgent.indexOf("Mac") != -1 && typeof parent.document.body.leftMargin != "undefined") { offsetLeft += parent.document.body.leftMargin; offsetTop += parent.document.body.topMargin; } return {left:offsetLeft, top:offsetTop}; } function checkdate(objName) { var datefield = objName; if (datefield.value == "") return true; if (chkdate(objName) == false) { //datefield.select(); alert("Data inválida"); datefield.value = "" datefield.focus(); return false; } else { //alert("Data Válida"); return true; } } function chkdate(objName) { var strDate; var strDay; var strMonth; var strYear; var intday; var intMonth; var intYear; var datefield = objName; strDate = datefield.value; //concatenar os campos e verificar quantidades // considerando um campo só com quantidade certa. strDay = strDate.substr(0, 2); strMonth = strDate.substr(3, 2); strYear = strDate.substr(6, 4); strBarra1 = strDate.substr(2, 1); strBarra2 = strDate.substr(5, 1); // Mostra os valores das variaveis //alert("strDay: " + strDay + "\nstrBarra1: " + strBarra1 + "\nstrMonth: " + strMonth + "\nstrBarra2: " + strBarra2 + "\nstrYear: " + strYear); intday = parseInt(strDay, 10); intday1 = parseInt(strDate.substr(0, 1), 10); intday2 = parseInt(strDate.substr(1, 1), 10); if ((isNaN(intday1)) || (isNaN(intday2))) { //alert("Erro no dia"); return false; } intMonth = parseInt(strMonth, 10); intMonth1 = parseInt(strDate.substr(3, 1), 10); intMonth2 = parseInt(strDate.substr(4, 1), 10); if ((isNaN(intMonth1)) || (isNaN(intMonth2))) { //alert("Erro no mês"); return false; } intYear = parseInt(strYear, 10); intYear1 = parseInt(strDate.substr(6, 1), 10); intYear2 = parseInt(strDate.substr(7, 1), 10); intYear3 = parseInt(strDate.substr(8, 1), 10); intYear4 = parseInt(strDate.substr(9, 1), 10); if ((isNaN(intYear1)) || (isNaN(intYear2)) || (isNaN(intYear3)) || (isNaN(intYear4)) || (intYear <= 1900)) { //alert("Erro no ano"); return false; } if ((strBarra1 != "/") ||(strBarra2 != "/")) { //alert("Erro na Barra / "); return false; } if (intMonth > 12 || intMonth < 1) { return false; } if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) { return false; } if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) { return false; } if (intMonth == 2) { if (intday < 1) { return false; } if (LeapYear(intYear) == true) { if (intday > 29) { return false; } } else { if (intday > 28) { return false; } } } return true; } function chkdate_str(strDate) { var strDate; var strDay; var strMonth; var strYear; var intday; var intMonth; var intYear; //concatenar os campos e verificar quantidades // considerando um campo só com quantidade certa. strDay = strDate.substr(0, 2); strMonth = strDate.substr(3, 2); strYear = strDate.substr(6, 4); strBarra1 = strDate.substr(2, 1); strBarra2 = strDate.substr(5, 1); // Mostra os valores das variaveis //alert("strDay: " + strDay + "\nstrBarra1: " + strBarra1 + "\nstrMonth: " + strMonth + "\nstrBarra2: " + strBarra2 + "\nstrYear: " + strYear); intday = parseInt(strDay, 10); intday1 = parseInt(strDate.substr(0, 1), 10); intday2 = parseInt(strDate.substr(1, 1), 10); if ((isNaN(intday1)) || (isNaN(intday2))) { //alert("Erro no dia"); return false; } intMonth = parseInt(strMonth, 10); intMonth1 = parseInt(strDate.substr(3, 1), 10); intMonth2 = parseInt(strDate.substr(4, 1), 10); if ((isNaN(intMonth1)) || (isNaN(intMonth2))) { //alert("Erro no mês"); return false; } intYear = parseInt(strYear, 10); intYear1 = parseInt(strDate.substr(6, 1), 10); intYear2 = parseInt(strDate.substr(7, 1), 10); intYear3 = parseInt(strDate.substr(8, 1), 10); intYear4 = parseInt(strDate.substr(9, 1), 10); if ((isNaN(intYear1)) || (isNaN(intYear2)) || (isNaN(intYear3)) || (isNaN(intYear4)) || (intYear <= 1900)) { //alert("Erro no ano"); return false; } if ((strBarra1 != "/") ||(strBarra2 != "/")) { //alert("Erro na Barra / "); return false; } if (intMonth > 12 || intMonth < 1) { return false; } if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) { return false; } if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) { return false; } if (intMonth == 2) { if (intday < 1) { return false; } if (LeapYear(intYear) == true) { if (intday > 29) { return false; } } else { if (intday > 28) { 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; } function Formata_Data(objeto,teclapres) { var tecla = teclapres.keyCode; vr = objeto.value; s=""; for (x=0; x < vr.length; x++) if (vr.charCodeAt(x) >= 48 && vr.charCodeAt(x)<=57) s= s + vr.charAt(x); vr = s; tam = vr.length + 1; if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39 && tecla != 35 && tecla != 36){ if ( tam < 2 ) objeto.value = vr.substr(0,2); if ( tam > 2 && tam < 4 ) objeto.value = vr.substr(0,2) + '/' + vr.substr(2,2); if ( tam > 4 ) objeto.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4); } if (tam > 5 && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4); if ((tam > 2 && tam < 6) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '/' + vr.substr(2,2); if (tam < 4 && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2); } function Valida_Email(objeto) { if ((objeto.value.indexOf("@")==-1 || objeto.value.indexOf(".")==-1) && objeto.value!="") { objeto.select(); alert("e-Mail inválido"); objeto.value = ""; objeto.focus(); return false; } return true; } function Valida_Telefone(objeto) { str=objeto.value; tel=""; if (str == "") return true if ((str.length<12 || str.length>13 || str.substring(0,1)!="(" || str.substring(3,4)!=")") && (str.indexOf("-")!=7 || str.indexOf("-")!=8)) { objeto.select(); alert("Telefone inválido. Formato: (12)3456-7890"); objeto.value = ""; objeto.focus(); return false; } for (var i = 0; i < str.length; i++) if (str.substring(i,i+1) >= "0" && str.substring(i,i+1) <= "9") tel+=str.substring(i,i+1); if (isNaN(tel)) { objeto.select(); alert("Telefone inválido. Formato: (12)3456-7890"); objeto.value = ""; objeto.focus(); return false; } return true; } function Formata_Telefone(objeto,teclapres) { var tecla = teclapres.keyCode; vr = objeto.value; s="" for (x=0; x < vr.length; x++) if (vr.charCodeAt(x) >= 48 && vr.charCodeAt(x)<=57) s= s + vr.charAt(x) vr = s tam = vr.length + 1; if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39 && tecla != 35 && tecla != 36) { if ( tam == 1 ) objeto.value = vr.substr(0,1); if ( tam > 1 && tam < 3 ) objeto.value = '(' + vr; if ( tam >=3 && tam < 7 ) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,4); if ( tam > 6 && tam < 11 ) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,3) + '-' + vr.substr(5,4); if ( tam > 10 ) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,4) + '-' + vr.substr(6,4); } if (tam > 10 && (tecla == 8 || tecla == 46)) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,4) + '-' + vr.substr(6,4); if ((tam > 6 && tam < 11) && (tecla == 8 || tecla == 46)) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,3) + '-' + vr.substr(5,4); if ((tam > 3 && tam < 7) && (tecla == 8 || tecla == 46)) objeto.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,4); if ((tam > 1 && tam < 3) && (tecla == 8 || tecla == 46)) objeto.value = '(' + vr; if (tam == 1 && (tecla == 8 || tecla == 46)) objeto.value = vr; } function Valida_Url(objeto) { if (objeto.value.substr(0,7).toLowerCase() == "http://") objeto.value = objeto.value.substr(7).toLowerCase(); return true; } function enumero(field) { var valid = "0123456789" var ok = "yes"; var temp; var msg = ""; for (var i=0; i < field.value.length; i++) { temp = "" + field.value.substring(i, i+1); if (valid.indexOf(temp) == "-1") ok = "no"; msg += i + " - Temp: " + temp + " Ok: " + ok + "\n" } //alert(msg); if (ok == "no") { alert("Neste campo só pode ter número inteiro!"); field.value = ""; field.focus(); return false; } else return true; } //******************************************************************* // Valida Campo de CNPJ //Passa o objeto Text function Valida_CNPJ(objName) { var datefield = objName; if (datefield.value == "") return true; if (CalculaCNPJ(objName.value) == false) { datefield.select(); alert("CNPJ inválido!!!"); datefield.value = "" datefield.focus(); return false; } else { return true; } } function CalculaCNPJ(RecebeCNPJ) { var soma var resultado1 var resultado2 s="" for (x=0; x < RecebeCNPJ.length; x++) if (RecebeCNPJ.charCodeAt(x) >= 48 && RecebeCNPJ.charCodeAt(x)<=57) s= s + RecebeCNPJ.charAt(x) RecebeCNPJ = s if (RecebeCNPJ.length != 14 || RecebeCNPJ == "00000000000000") { return false } else { soma = RecebeCNPJ.charAt(0) * 5 + RecebeCNPJ.charAt(1) * 4 + RecebeCNPJ.charAt(2) * 3 + RecebeCNPJ.charAt(3) * 2 + RecebeCNPJ.charAt(4) * 9 + RecebeCNPJ.charAt(5) * 8 + RecebeCNPJ.charAt(6) * 7 + RecebeCNPJ.charAt(7) * 6 + RecebeCNPJ.charAt(8) * 5 + RecebeCNPJ.charAt(9) * 4 + RecebeCNPJ.charAt(10) * 3 + RecebeCNPJ.charAt(11) * 2 soma = soma -(11 * (parseInt(soma / 11))) if (soma == 0 || soma == 1) resultado1 = 0 else resultado1 = 11 - soma if (resultado1 == RecebeCNPJ.charAt(12)) { soma = RecebeCNPJ.charAt(0) * 6 + RecebeCNPJ.charAt(1) * 5 + RecebeCNPJ.charAt(2) * 4 + RecebeCNPJ.charAt(3) * 3 + RecebeCNPJ.charAt(4) * 2 + RecebeCNPJ.charAt(5) * 9 + RecebeCNPJ.charAt(6) * 8 + RecebeCNPJ.charAt(7) * 7 + RecebeCNPJ.charAt(8) * 6 + RecebeCNPJ.charAt(9) * 5 + RecebeCNPJ.charAt(10) * 4 + RecebeCNPJ.charAt(11) * 3 + RecebeCNPJ.charAt(12) * 2 soma = soma - (11 * (parseInt(soma / 11))) if (soma == 0 || soma == 1) resultado2 = 0 else resultado2 = 11 - soma if (resultado2 == RecebeCNPJ.charAt(13)) return true else return false } else return false } } function Formata_Cnpj(objeto,teclapres) { var tecla = teclapres.keyCode; vr = objeto.value; s="" for (x=0; x < vr.length; x++) if (vr.charCodeAt(x) >= 48 && vr.charCodeAt(x)<=57) s= s + vr.charAt(x) vr = s tam = vr.length + 1; if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39 && tecla != 35 && tecla != 36) { if (tam < 3) objeto.value = vr.substr(0,2); if (tam > 2 && tam < 6) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3); if (tam > 5 && tam < 9) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3); if (tam > 8 && tam < 13) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4); if (tam > 12) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4) + '-' + vr.substr(12,2); } if (tam > 12 && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4) + '-' + vr.substr(12,2); if ((tam > 8 && tam < 13) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4); if ((tam > 5 && tam < 9) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3); if ((tam > 2 && tam < 6) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) if ((tam > 1 && tam < 3) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) } function Valida_CPF(objName) { var datefield = objName; if (datefield.value == "") return true; if (checaCPF(objName.value) == false) { datefield.select(); alert("CPF inválido!!!"); datefield.value = "" datefield.focus(); return false; } else { //alert("Data Válida"); return true; } } function checaCPF (CPF) { s="" for (x=0; x < CPF.length; x++) if (CPF.charCodeAt(x) >= 48 && CPF.charCodeAt(x)<=57) s= s + CPF.charAt(x) CPF = s 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 Formata_Cpf(obj,teclapres) { var tecla = teclapres.keyCode; vr = obj.value; s="" for (x=0; x < vr.length; x++) if (vr.charCodeAt(x) >= 48 && vr.charCodeAt(x)<=57) s= s + vr.charAt(x) vr = s tam = vr.length + 1; if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39 && tecla != 35 && tecla != 36) { if (tam < 4) obj.value = vr.substr(0,3); if (tam > 3 && tam < 7) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3); if (tam > 6 && tam < 10) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3); if (tam > 9) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,2); } if (tam > 10 && (tecla == 8 || tecla == 46)) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,2); if ((tam > 7 && tam < 10) && (tecla == 8 || tecla == 46)) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3); if ((tam > 4 && tam < 7) && (tecla == 8 || tecla == 46)) obj.value = vr.substr(0,3) + '.' + vr.substr(3,3); if ((tam > 2 && tam < 4) && (tecla == 8 || tecla == 46)) obj.value = vr.substr(0,3); } function Formata_Cep(objeto,teclapres) { var tecla = teclapres.keyCode; vr = objeto.value; s="" for (x=0; x < vr.length; x++) if (vr.charCodeAt(x) >= 48 && vr.charCodeAt(x)<=57) s= s + vr.charAt(x) vr = s tam = vr.length + 1; if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39 && tecla != 35 && tecla != 36) { if ( tam < 2 ) objeto.value = vr.substr(0,2); if (tam > 2 && tam < 5) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3); if (tam > 5) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '-' + vr.substr(5,3); } if ((tam > 5 && tam < 9) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '-' + vr.substr(5,3); if ((tam > 2 && tam < 6) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) + '.' + vr.substr(2,3) if ((tam > 1 && tam < 3) && (tecla == 8 || tecla == 46)) objeto.value = vr.substr(0,2) } function money(field) { if (field.value == "") return true; if (validateNumber(field)) { //alert("VALIDO!!!"); return true; } else { alert("Informe apenas valor no formato numérico!"); field.value = ""; field.focus(); return false; } } function validateNumber(field) { var valid = "0123456789," var ok = "yes"; var ponto = 0; var temp; var numponto = 0; var vFinal = ""; var msg = ""; //Retira os Pontos field.value = field.value.replace(/\./gi,''); for (var i=0; i < field.value.length; i++) { temp = "" + field.value.substring(i, i+1); if (temp == ",") { numponto++; if (ponto == 0) ponto = i; } if (valid.indexOf(temp) == "-1") ok = "no"; msg += i + " - Temp: " + temp + " Ok: " + ok + " NumPonto: " + numponto + " Ponto: " + ponto + "\n" } if (ponto != 0) temp = field.value.length - (ponto + 1) - 2; else temp = 0; msg += "\nPonto: " + ponto + " Temp: " + temp + "\n" //alert(msg); if (ok == "no") return false; if (numponto >= 2) return false; if (temp == -2 && numponto == 1) return false; if (temp >= 1) return false; if (ponto == 0 && numponto == 1) return false; //Coloca os pontos msg = ""; if (ponto > 0) vFinal = field.value.substr(ponto); if (ponto == 0) ponto = field.value.length; for (var i = ponto - 3; i > -3; i = i - 3) { temp = "" + field.value.substring(i, i + 3); vFinal = "." + temp + vFinal; msg += i + " - Temp: " + temp + " vFinal: " + vFinal + "\n" } //alert(msg); if (vFinal.substring(0, 1) == ".") vFinal = vFinal.substr(1); field.value = vFinal; return true; } function Limita_Tamanho(campo, tam) { if (campo.value.length >= tam) { return false; } else { return true; } } function Trunca_Campo(campo,tam) { if (campo.value.length > tam) { alert("O campo tem um limite de " + tam + " caracteres!"); campo.value = campo.value.substring(0,tam); } } function troca_caracter(campo) { var estranha = 'áéíóúàèìòùâêîôûäëïöüãõ@#$%^&*()_+=-~` ç|\/:.?,'; var correta = 'aeiouaeiouaeiouaeiouao________________c_______'; var re; campo = campo.toLowerCase(); for (var i = 0; i < estranha.length; i++) { re = new RegExp('\\' + estranha.charAt(i), "g"); campo = campo.replace(re, correta.charAt(i)); } campo = campo.replace(/_/gi, ""); return campo; } function url_decode(str) { var n, strCode, strDecode = ""; for (n = 0; n < str.length; n++) { if (str.charAt(n) == "%") { strCode = str.charAt(n + 1) + str.charAt(n + 2); strDecode += String.fromCharCode(parseInt(strCode, 16)); n += 2; } else { strDecode += str.charAt(n); } } return strDecode; } //Codigo do AJAX //////////////////////////////////////////////////////////////////////////////////////// // This JavaScript file provides generic functions for usage in AJAX transactions. // Author: Sascha Kalinowski - s.k.rj.br@gmail.com // Version: 1.1 //////////////////////////////////////////////////////////////////////////////////////// function AjaxUtil() {} var req; var callback; // This function is responsable to begin the procesing request, the parameter are // pRequestFormId --> the form that will be submited in case of POST // pGetPost --> or GET or POST, default is GET // pURL --> the URL to be called by the function with AJAX // pCallback --> the function that receives the return of AJAX, if empty the default function name is processResponse // pTargetFieldId --> the field that will receive the response text data in the innerHTML // pFocusFieldId --> the field that will receive the focus after the processing, can be empty // AjaxUtil.exec = function (pRequestFormId, pGetPost, pURL, pCallback) { callback = pCallback; var queryString = null; if (pGetPost == "POST" && pRequestFormId != "") queryString = getFormValues(pRequestFormId); if (window.ActiveXObject) // IE { req = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) // not IE { req = new XMLHttpRequest(); } req.onreadystatechange = processResponse; req.open(pGetPost, pURL, true); if (pGetPost == "POST") req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); req.send(queryString); } // Internal function: // Create the QueryString in case a POST is to be executed via AJAX // function getFormValues(pFormId) { var str = ""; var form = document.getElementById(pFormId); for(var i = 0;i < form.elements.length;i++) { switch(form.elements[i].type) { case "text": case "textarea": case "password": case "hidden": str += form.elements[i].name + "=" + escape(form.elements[i].value) + "&"; break; case "select-one": str += form.elements[i].name + "=" + form.elements[i].options[form.elements[i].selectedIndex].value + "&"; break; case "radio": if (form.elements[i].checked) str += form.elements[i].name + "=" + escape(form.elements[i].value) + "&"; break; } } str = str.substr(0,(str.length - 1)); return str; } // Internal function: // Response function, waits until response available and then calls the callback function passing the // responseText as parameter if the callback function was specified in the submitAjax // function processResponse() { if (req.readyState == 4) { if(req.status == 200) { if (callback != '') callback(req.responseText); } else if (req.status == 401) // náo autorizado { document.location.href = "index.html"; document.location.reload(); } } } var includedJavaScripts = new Array(); // This function includes a remote JavaScript into the current opened page // AjaxUtil.includeJavaScript = function (pJavaScriptsURL) { if (!in_array(pJavaScriptsURL, includedJavaScripts)) { includedJavaScripts[includedJavaScripts.length] = pJavaScriptsURL; var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', pJavaScriptsURL); html_doc.appendChild(js); } } // Internal function: // Auxiliar funtion to include every remote JavaScript only once // function in_array(needle, haystack) { for (var i = 0; i < haystack.length; i++) { if (haystack[i] == needle) { return true; } } return false; } /** * Find the element in the current HTML document with the given id or ids * @see http://getahead.ltd.uk/dwr/browser/util/$ */ var $ajax; if (!$ajax && document.getElementById) { $ajax = function() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') { element = document.getElementById(element); } if (arguments.length == 1) { return element; } elements.push(element); } return elements; } } else if (!$ajax && document.all) { $ajax = function() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') { element = document.all[element]; } if (arguments.length == 1) { return element; } elements.push(element); } return elements; } } //Fim do AJAX function CancelKeys(e) { // Thiago Marotta Couto // thiago@isbyte.com // http://thiagocouto.wordpress.com // September, 27 - 2008 var e = e ? e : window.event; var key = (e.keyCode) ? e.keyCode : e.which; var keys = new Array( 116, /* F5 */ 9 /* Tab */ ); for (i = 0 ; i < keys.length ; i++) { //if (key == keys[i]) { try { e.preventDefault(); } catch(ex) { e.returnValue=false; e.keyCode=0; } return false; //} } } function queryString(parameter) { var loc = location.search.substring(1, location.search.length); var param_value = false; var params = loc.split("&"); for (i=0; i < params.length;i++) { param_name = params[i].substring(0,params[i].indexOf('=')); if (param_name == parameter) { param_value = params[i].substring(params[i].indexOf('=')+1) } } if (param_value) { return param_value; } else { return ''; } } function newDataStr(c) { var vet = c.split('/'); return new Date(vet[2], vet[1] - 1, vet[0]); } function mudaTab(g) { if ($('div#grd' + g).css('display') == 'none') { $('div#tabHtml > ul').tabs('select', '#grd' + g); } }