// JavaScript Document
// Função para iniciarmos o Ajax no browser do cliente.
function openAjax() {
var ajax;
try{
ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers decentes, como: Firefox, Safari, dentre outros.
}catch(ee){
try{
ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
}catch(e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
}catch(E){
ajax = false;
}
}
}
return ajax;
}
// -- Fim Funcao AJAX --------------->
// -- Data --------------->
day = new Date( )
hr = day.getHours( )
if (( hr >= 0 ) && (hr <= 4 ))
mess1= "Boa Madrugada! "
if (( hr >= 4 ) && (hr < 12))
mess1= "Bom Dia! "
if (( hr >= 12) && (hr <= 17))
mess1= "Boa Tarde! "
if ((hr >= 18) && (hr <= 23))
mess1= "Boa Noite! "
function MakeArray(n) {
this.length = n
return this}
dayNames = new MakeArray(7)
dayNames[1] = "Domingo"
dayNames[2] = "Segunda-feira"
dayNames[3] = "Terça-feira"
dayNames[4] = "Quarta-feira"
dayNames[5] = "Quinta-feira"
dayNames[6] = "Sexta-feira"
dayNames[7] = "Sábado"
monthNames = new MakeArray(12)
monthNames[1] = "Janeiro"
monthNames[2] = "Fevereiro"
monthNames[3] = "Março"
monthNames[4] = "Abril"
monthNames[5] = "Maio"
monthNames[6] = "Junho"
monthNames[7] = "Julho"
monthNames[8] = "Agosto"
monthNames[9] = "Setembro"
monthNames[10] = "Outubro"
monthNames[11] = "Novembro"
monthNames[12] = "Dezembro"
function customDateString(oneDate) {
var theDay = dayNames[oneDate.getDay() + 1]
var theMonth = monthNames[oneDate.getMonth() + 1]
var theYear1 = oneDate.getFullYear()
if (theYear1 >= 2000) {
theYear = theYear1;
}else{
theYear = theYear1+2000;
}
return theDay + ", "+oneDate.getDate() + " de " + theMonth + " de "+ theYear+"."}
day = new Date( )
// -- Fim Script data --------------->
// -- Data e relogio juntos--------------->
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
// Certifica que o relógio está parado
stopclock();
showtime();
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
var exibedatarelogio = document.getElementById('datarelogio');
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
dataValue = now.getDate()+"/"+ [now.getMonth() + 1] +"/"+now.getFullYear();
// você poderá utilizar a linha abaixo se quiser visualizar dentro de um campo de formulario
//document.clock.face.value = timeValue;
exibedatarelogio.innerHTML = "
"+ timeValue +" "+ dataValue +" ";
// você poderá substituir a linha acima pelo código
// abaixo e terá o relógio na linha de status:
//window.status = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
// -- Fim Script data e relogio juntos--------------->
// -- Mensagem na barra de status --------------->
// window.status = "PRODATER - Gestão de Informação";
// -- Mensagem na barra de status --------------->
function janela_pop_up(theURL,winName,features) {
remote = window.open(theURL,winName,features);
remote.resizeTo(window.screen.availWidth, window.screen.availHeight);
}
function janela_pop_up_2(theURL,winName,features) {
remote = window.open(theURL,winName,features);
}
function resize() {
var i=0;
if (navigator.appName == 'Netscape') i=40;
if (document.images[0]) window.resizeTo(document.images[0].width +12, document.images[0].height+52-i);
}
function mOvr(src,clrOver) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = clrOver;
}
}
function mOut(src,clrIn) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = clrIn;
}
}
function mClk(src) {
if(event.srcElement.tagName=='TD'){
src.children.tags('A')[0].click();
}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function fechar(){
window.opener.location.reload()
window.close();
}
function alerta_publicacao(){
window.opener.location.reload()
alert("Atenção: falta liberação para a publicação!")
window.close();
}
function marcartodos1(){
for (var i=0;i 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
} }
else {
return true;
}
}
// inicio de verificacao de cnpj ou cpf
function validar(Form) {
var invalid, s;
invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
var s;
if (Form.cpf.value.length <= 13) {
alert("O CPF é um campo obrigatório !");
document.myform.cpf.value = "";
Form.cpf.focus();
return false; }
s = limpa_string(Form.cpf.value);
// checa se é cpf
if (s.length == 11) {
if (valida_CPF(Form.cpf.value) == false ) {
alert("O CPF não é válido !");
document.myform.cpf.value = "";
Form.cpf.focus();
return false; }
}
if (Form.cgc.value.length <= 18) {
alert("O CNPJ é um campo obrigatório !");
document.myform.cgc.value = "";
Form.cgc.focus();
return false; }
s = limpa_string(Form.cgc.value);
// checa se é CPNJ
if (s.length == 16) {
if (valida_CGC(Form.cgc.value) == false ) {
alert("O CNPJ não é válido !");
document.myform.cgc.value = "";
Form.cgc.focus();
return false; }
}
return true;
}
// fim da funcao validar()
function limpa_string(S){
// Deixa so' os digitos no numero
var Digitos = "0123456789";
var temp = "";
var digito = "";
for (var i=0; i=0) {
temp=temp+digito }
} //for
return temp
}
// fim da funcao
function valida_CPF(s) {
var i;
s = limpa_string(s);
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(10-i);
}
if (d1 == 0) return false;
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1)
{
return false;
}
d1 *= 2;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(11-i);
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1)
{
return false;
}
return true;
}
function valida_CGC(s)
{
var i;
s = limpa_string(s);
var c = s.substr(0,12);
var dv = s.substr(12,2);
var d1 = 0;
for (i = 0; i < 12; i++)
{
d1 += c.charAt(11-i)*(2+(i % 8));
}
if (d1 == 0) return false;
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1)
{
return false;
}
d1 *= 2;
for (i = 0; i < 12; i++)
{
d1 += c.charAt(11-i)*(2+((i+1) % 8));
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1)
{
return false;
}
return true;
}
function ToggleDiv(id)
{
var b = (navigator.appName.substring(0,2) == "Mi") ? 1:0;
var oDiv = document.getElementById(id);
if(oDiv != null)
{
if (b) {
oDiv.style.display = oDiv.style.display == 'inline' ? 'none' : 'inline';
} else {
oDiv.style.display = oDiv.style.display == 'table-cell' ? 'none' : 'table-cell';
}
}
}
function ToggleImage(id, src1, src2)
{
var oImg = document.getElementById(id);
if(oImg != null)
oImg.src = oImg.src.indexOf(src2) != -1 ? src1 : src2;
}
function imageEnviando() {
tabEnviar = document.getElementById("imgEnviar");
tabEnviar.style.display = "none";
tabEnviar.style.visibility = "hidden";
tabEnviar.disabled=true;
tabEnviando = document.getElementById("imgEnviando");
tabEnviando.style.display = "block";
tabEnviando.style.visibility = "visible";
tabEnviando.disabled=false;
}
function checar_caps_lock(ev) {
var e = ev || window.event;
codigo_tecla = e.keyCode?e.keyCode:e.which;
tecla_shift = e.shiftKey?e.shiftKey:((codigo_tecla == 16)?true:false);
if(((codigo_tecla >= 65 && codigo_tecla <= 90) && !tecla_shift) || ((codigo_tecla >= 97 && codigo_tecla <= 122) && tecla_shift)) {
document.getElementById('aviso_caps_lock').style.visibility = 'visible';
}
else {
document.getElementById('aviso_caps_lock').style.visibility = 'hidden';
}
}
function move(MenuOrigem, MenuDestino){
var arrMenuOrigem = new Array();
var arrMenuDestino = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < MenuDestino.options.length; i++){
arrLookup[MenuDestino.options[i].text] = MenuDestino.options[i].value;
arrMenuDestino[i] = MenuDestino.options[i].text;
}
var fLength = 0;
var tLength = arrMenuDestino.length;
for(i = 0; i < MenuOrigem.options.length; i++){
arrLookup[MenuOrigem.options[i].text] = MenuOrigem.options[i].value;
if (MenuOrigem.options[i].selected && MenuOrigem.options[i].value != ""){
arrMenuDestino[tLength] = MenuOrigem.options[i].text;
tLength++;
}
else{
arrMenuOrigem[fLength] = MenuOrigem.options[i].text;
fLength++;
}
}
arrMenuOrigem.sort();
arrMenuDestino.sort();
MenuOrigem.length = 0;
MenuDestino.length = 0;
var c;
for(c = 0; c < arrMenuOrigem.length; c++){
var no = new Option();
no.value = arrLookup[arrMenuOrigem[c]];
no.text = arrMenuOrigem[c];
MenuOrigem[c] = no;
}
for(c = 0; c < arrMenuDestino.length; c++){
var no = new Option();
no.value = arrLookup[arrMenuDestino[c]];
no.text = arrMenuDestino[c];
MenuDestino[c] = no;
MenuDestino[c].selected = true;
}
}
function mantem(menu){
var arrMenu = new Array();
var i;
for (i = 0; i < menu.options.length; i++){
menu[i].selected = true;
}
}