/* * @ NeoPhoto - 04/2004 - André Cupini - andre@neobiz.com.br * @ NeoBiz - Mundo digital, resultado real */ /* * @ Testa validade de uma data * @ Recebe dia, mês, ano e retorna true ou false */ function testDate(arg_day, arg_month, arg_year) { var day = new Number(arg_day); var month = new Number(arg_month-1); var year = new Number(arg_year); var aux = new Date(year, month, day); if (year==aux.getFullYear() && month==aux.getMonth() && day==aux.getDate()) return true; else return false; } /* * @ Utiliza testDate() para validar campo data */ function checkDate() { for(i = 0; i < arguments.length; i++) { var sDt = arguments[i].split('/'); var tmp = sDt[2].split('\ '); if(tmp) sDt[2] = tmp[0]; if(testDate(sDt[0], sDt[1], sDt[2]) == false) { return false; } } return true; } /* * @ Checa se o formulário de inclusão de categorias foi * @ preenchido corretamente */ function checkCategoryForm() { if(!document.all['category'].value) { blink('category'); return false; } if(!checkDate(document.all['insDate'].value)) { blink('insDate'); return false; } return true; } /* * @ Checa se o formulário de inclusão/alteração de imagens foi * @ preenchido corretamente */ function checkImageForm() { var category = document.all['category'][document.all['category'].selectedIndex].value; if(category == 0) { blink('category'); return false; } if(document.all['action'].value == "insert") { if(!document.all['image'].value) { blink('image'); return false; } } if(!checkDate(document.all['insDate'].value)) { blink('insDate'); return false; } return true; } /* * @ Cheaca os dados do formulário de envio de image */ function checkSendImgForm() { var mailRegExp = new RegExp('^([\.a-zA-Z0-9_-]+)@([\.a-zA-Z0-9_-]){1,}[\.]{1,1}[a-zA-Z]{2,3}$'); if(!document.getElementById('f').senderName.value) { document.getElementById('f').senderName.focus(); //blink('senderName'); return false; } if(!mailRegExp.test(document.getElementById('f').senderMail.value)) { document.getElementById('f').senderMail.focus(); //blink('senderMail'); return false; } if(!document.getElementById('f').rcptName.value) { document.getElementById('f').rcptName.focus(); //blink('rcptName'); return false; } if(!mailRegExp.test(document.getElementById('f').rcptMail.value)) { document.getElementById('f').rcptMail.focus(); //blink('rcptMail'); return false; } } /* * @ Alterna as cores de um elemento do form criando o efeito "blink" */ function blink(object_id, color_on, color_off) { if(!color_on) color_on = '#666666'; if(!color_off) color_off = '#FFFFFF'; if(document.all[object_id].type != "select-one") document.all[object_id].focus(); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_on+"'", "300"); this.window.setTimeout("document.all['"+object_id+"'].style.color='"+color_off+"'", "300"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_off+"'", "600"); this.window.setTimeout("document.all['"+object_id+"'].style.color=''", "600"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_on+"'", "900"); this.window.setTimeout("document.all['"+object_id+"'].style.color='"+color_off+"'", "900"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_off+"'", "1200"); this.window.setTimeout("document.all['"+object_id+"'].style.color=''", "1200"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_on+"'", "1500"); this.window.setTimeout("document.all['"+object_id+"'].style.color='"+color_off+"'", "1500"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_off+"'", "1800"); this.window.setTimeout("document.all['"+object_id+"'].style.color=''", "1800"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_on+"'", "2100"); this.window.setTimeout("document.all['"+object_id+"'].style.color='"+color_off+"'", "2100"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_off+"'", "2400"); this.window.setTimeout("document.all['"+object_id+"'].style.color=''", "2400"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_on+"'", "2700"); this.window.setTimeout("document.all['"+object_id+"'].style.color='"+color_off+"'", "2700"); this.window.setTimeout("document.all['"+object_id+"'].style.backgroundColor='"+color_off+"'", "3000"); this.window.setTimeout("document.all['"+object_id+"'].style.color=''", "3000"); }