
function handleErr(msg,url,l){txt="Ocorreu um erro de JS nessa página.\n\n";txt+="Erro: "+msg+"\n";txt+="URL: "+url+"\n";txt+="Linha: "+l+"\n\n";txt+="Clique OK para continuar.\n\n";alert(txt)
return true}
function $id(id){return document.getElementById(id);}
function $name(name){return document.getElementByName(name);}
function $tagName(tg){return document.getElementsByTagName(tg);}
function myObj(){this.set=function(value){this._value=value;}
this.get=function(){return this._value;}}
var mobj=new myObj();var loadimages=new Array();var clear="./../static/jscripts/blank.gif";var framework={charset:'utf-8',system:"SAW7 - Sistema de Administração Web",Navegador:navigator.appName,Browser:navigator.appName+' - version: '+navigator.appVersion,timestamp:new Date().getTime(),filaAjax:new Array(),ajaxInWork:false,Bool:({Browser:{IE:!!(window.attachEvent&&!window.opera),Firefox:navigator.userAgent.indexOf('Firefox')>0&&navigator.userAgent.indexOf('Mozilla')>0,Opera:!!window.opera,WebKit:navigator.userAgent.indexOf('AppleWebKit/')>-1,Gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)}}),xmlhttp:function(){xhr=false;if(!xhr&&typeof XMLHttpRequest!="undefined"){try{xhr=new XMLHttpRequest();}
catch(e){xhr=false;}}
return xhr;},status:({Http:function(stat){switch(stat){case 0:return"Erro desconhecido de javascript";break;case 200:return false;case 400:return"400: Solicitação incompreensível";break;case 403:case 404:return"404: Não foi encontrada a URL solicitada";break;case 405:return"405: O servidor não suporta o método solicitado";break;case 500:return"500: Erro desconhecido de natureza do servidor";break;case 503:return"503: Capacidade máxima do servidor alcançada";break;default:return"Erro "+stat+". Mais informações em http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html";break;}},Ready:function(obj,stat){switch(stat){case 0:return obj.innerHTML="Não inicializado";break;case 1:return obj.innerHTML="Iniciando Requisição";break;case 2:return obj.innerHTML="Enviando Dados";break;case 3:return obj.innerHTML="Recebendo Dados e Carregando";break;default:return false;break;}}}),Errorstr:({Http:function(stat){switch(stat){case 0:resource="Erro desconhecido de javascript";break;case 200:return false;case 400:resource="Erro 400: Solicitação incompreensível";break;case 403:case 404:resource="Erro 404: Não foi encontrada a URL solicitada";break;case 405:resource="Erro 405: O servidor não suporta o método solicitado";break;case 500:resource="Erro 500: Erro desconhecido de natureza do servidor";break;case 503:resource="Erro 503: Capacidade máxima do servidor alcançada";break;default:resource="Erro "+stat+". Mais informações em http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html";break;}
return framework.Errorstr.printf(resource);},printf:function(txt){return"<div id=\"statusReady\">"+txt+"</div>"}}),AntiCache:({url:function(aurl){var dt=new Date();var rand=Math.random().toString().substr(3);var res=encodeURI(rand+"="+dt.getTime());return aurl+((aurl.indexOf("?")>=0)?"&":"?")+res;}}),popup:({def:function(url,name,largura,altura,scroll){var esq=(screen.width-largura)/2;var top=(screen.height-altura)/2;return window.open(url,name,'left='+esq+', top='+top+', height='+altura+', width='+largura+', scrollbars='+scroll+', resizable=no, status=no, directories=no, toolbar=no');},_480x250:function(url,name,scroll){var esq=(screen.width-480)/2;var top=(screen.height-250)/2;return window.open(url,name,'left='+esq+', top='+top+', height=250, width=480, scrollbars='+scroll+', resizable=no, status=no, directories=no, toolbar=no');}}),event:({load:function(func){if(!(document.body==null)){func();}
else{var func_rep=func;setTimeout(function(){framework.event.load(func_rep)},100);}},add:function(obj,evtype,fn){if(obj.addEventListener){obj.addEventListener(evtype,fn,false);return true;}
else if(obj.attachEvent){var r=obj.attachEvent("on"+evtype,fn);return r;}
else return alert('Erro ao carregar eventos no JS');},remove:function(obj,evtype,fn){if(obj.detachEvent){var r=obj.detachEvent('on'+evtype,fn);return r;}
else if(obj.removeEventListener){obj.removeEventListener(evtype,fn,false);return true;}
else return alert('Não foi possivel remover o evento no JS');}}),ajax:({resetVars:function(){if(framework.filaAjax.length<1){framework.ajaxInWork=false;framework.filaAjax=new Array(0);}
setTimeout("framework.ajax.resetVars()",4000);},queue:function(){framework.ajaxInWork=true;values=framework.filaAjax.shift();method=values[0];obj=values[1];url=values[2];params=values[3];params=(!params)?null:params;xml=framework.xmlhttp();url=framework.AntiCache.url(url);xml.open(method,url,true);framework.set.Headers(xml);xml.send(params);xml.onreadystatechange=function(){if(xml.readyState<4){framework.status.Ready(obj,xml.readyState);}
else{if(xml.status==200){response=xml.responseText;obj.innerHTML=response;if(framework.filaAjax.length>0){framework.ajaxInWork=false;setTimeout("framework.ajax.queue()",20);}
else{framework.ajax.resetVars();}}
else{}}}},method:({get:function(obj,url){framework.filaAjax.push(["GET",obj,url]);if(!framework.ajaxInWork){framework.ajax.queue();}},post:function(obj,url,params){framework.filaAjax.push(["POST",obj,url,params]);if(!framework.ajaxInWork){framework.ajax.queue();}}})}),set:({Headers:function(obj){obj.setRequestHeader("X-Requested-With","XMLHttpRequest");if(typeof(keyAjax)=="string"&&keyAjax.length>6){obj.setRequestHeader("X-Requested-Key",keyAjax);}
obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+framework.charset+"");obj.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate");obj.setRequestHeader("Cache-Control","post-check=0, pre-check=0");obj.setRequestHeader("Pragma","no-cache");}}),get:({Object:function(obj,type){if(typeof(type)=="undefined"){type='id'}
if(type=="name"&&document.getElementByName){return document.getElementByName(obj);}
else if(type=="id"&&document.getElementById){return document.getElementById(obj);}
else{return document.all.obj;}}}),validacao:({regex:({email:function(str){var er=new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);if(typeof(str)=="string"){return!!(er.test(str));}
else if(typeof(str)=="object"){return!!(er.test(str.value));}
return false;},data:function(dat){var er=new RegExp(/^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/)
return!!(er.test(dat));}}),subst:({money:function(n){n=n.replace(/\D/g,"");n=n.replace(/^(\d{2})(\d)/,"$1.$2");return n;},num:function(n){return n.replace(/\D/g,"");},cnpj:function(value){value=value.replace(/\D/g,"");value=value.replace(/^(\d{2})(\d)/,"$1.$2");value=value.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3");value=value.replace(/\.(\d{3})(\d)/,".$1/$2");value=value.replace(/(\d{4})(\d)/,"$1-$2");return value;},cep:function(value){value=value.replace(/D/g,"");value=value.replace(/^(\d{5})(\d)/,"$1-$2");return value;},cpf:function(value){value=value.replace(/\D/g,"");value=value.replace(/(\d{3})(\d)/,"$1.$2");value=value.replace(/(\d{3})(\d)/,"$1.$2");value=value.replace(/(\d{3})(\d{1,2})$/,"$1-$2");return value;},tel:function(value){value=value.replace(/\D/g,"");value=value.replace(/^(\d\d)(\d)/g,"($1) $2");value=value.replace(/(\d{4})(\d)/,"$1-$2");return value;}})}),calendario:function(_url,month,year,agenda){if(typeof(month)=="undefined")month='';if(typeof(year)=="undefined")year='';if(typeof(agenda)=="undefined")agenda=true;var url=_url+"calendar.php?month="+month+"&year="+year+"&agenda="+agenda;return framework.ajax.method.get($id("calendar"),url);},delay:function(millis){var date=new Date();var curDate=null;do{curDate=new Date();}while(curDate-date<millis);return true;},menu:function(){var navItems=$id("primary-nav").getElementsByTagName("li");for(var i=0;i<navItems.length;i++){if(navItems[i].className=="menuparent"){navItems[i].onmouseover=function(){this.className+=" over";}
navItems[i].onmouseout=function(){this.className="menuparent";}}}},pgCarrega:function(uri,id){return $id(id)?framework.ajax.method.get($id(id),uri):false;},executeJS:function(id,url){obj=$id(id);xml=framework.xmlhttp();url=framework.AntiCache.url(url);xml.open("GET",url,true);xml.onreadystatechange=function(){if(xml.readyState<4){framework.status.Ready(obj,xml.readyState);}
else{if(xml.status==200){response=xml.responseText;obj.innerHTML=response;framework.extraiScript(response);}else{alert("Encontrado um problema ao carregar os dados:\n"+framework.status.Http(xml.status)+"\n\n Status:"+xml.statusText);}}}
framework.set.Headers(xml);xml.send(null);},extraiScript:function(texto){var ini,pos_src,fim,codigo;var objScript=null;ini=texto.indexOf('<script',0);while(ini!=-1){var objScript=document.createElement("script");pos_src=texto.indexOf(' src',ini)
ini=texto.indexOf('>',ini)+1;if(pos_src<ini&&pos_src>=0){ini=pos_src+4;fim=texto.indexOf('.',ini)+4;codigo=texto.substring(ini,fim);codigo=codigo.replace("=","").replace(" ","").replace("\"","").replace("\"","").replace("\'","").replace("\'","").replace(">","");objScript.src=codigo;}
else{fim=texto.indexOf('</script>',ini);codigo=texto.substring(ini,fim);objScript.text=codigo;}
document.body.appendChild(objScript);ini=texto.indexOf('<script',fim);objScript=null;}},preloadimg:function(){for(x=0;x<framework.preloadimg.arguments.length;x++){loadimages[x]=new Image();loadimages[x].src=framework.preloadimg.arguments[x];}},combobox:function(url,param,id_next){var c=$id(id_next);var aux=c.options[0];while(c.options.length>0){c.options[0]=null;}
c.options[0]=new Option(" --- Aguarde... --- ",null);url=framework.AntiCache.url(url+param);var xmlhttp=null;xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var c=$id(id_next);var aCidades=eval((xmlhttp.responseText))
while(c.options.length>0){c.options[0]=null;}
c.options[0]=aux;if(typeof(aCidades)!="undefined"){for(var i=0;i<aCidades.length;i++){var splitC=aCidades[i].split(':');c.options[c.options.length]=new Option(splitC[1],splitC[0]);}}
else{c.options[1]=new Option("Nenhum resultado encontrado",null);}}}
xmlhttp.send(null);},buscaPessoa:function(url){url=framework.AntiCache.url(url);xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){document.getElementById('resultadoBusca').innerHTML=xmlhttp.responseText;}}
xmlhttp.send(null);},loginConversa:function(url){url=framework.AntiCache.url(url);xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){retorno=xmlhttp.responseText.split('|.|.|');if(retorno[0]=='certo'){document.getElementById('loginForm').style.display='none';document.getElementById('PostForm').style.display='block';document.getElementById('idLoginConversa').value=retorno[1];}else{alert('Apelido repetido, tente outro!');}}}
xmlhttp.send(null);},postconversa:function(url){url=framework.AntiCache.url(url);xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.responseText=='certo'){document.getElementById('textotopost').value='';}else{document.getElementById('textotopost').value='Usuario Bloqueado!';document.getElementById('textotopost').disabled="disabled";alert('Usuario bloqueado!');}}}
xmlhttp.send(null);},loadDataForm:function(url,param,id,values){var c=$id(id);url=framework.AntiCache.url(url+param);xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var aEndereco=eval((xmlhttp.responseText));aEndereco=aEndereco.split('<__>');for(x=0;x<values.length;x++){document.getElementById(values[x]).value=aEndereco[x];}}}
xmlhttp.send(null);},campoBlur:function(url,param,id){var cep=document.frmfuncionariosaw.cep.value;var c=$id(id);document.getElementById("formEndereco").style.display="block";xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url+param+cep,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var aEndereco=eval((xmlhttp.responseText));aEndereco=aEndereco.split('<__>');document.getElementById('endereco').value=aEndereco[0];document.getElementById('numero').value=aEndereco[1];document.getElementById('cidade').value=aEndereco[2];document.getElementById('bairro').value=aEndereco[3];}}
xmlhttp.send(null);},campoBlur2:function(url,param,id){var cep=document.frmempresasaw.cep.value;var c=$id(id);document.getElementById("formEndereco").style.display="block";xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url+param+cep,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var aEndereco=eval((xmlhttp.responseText));aEndereco=aEndereco.split('<__>');document.getElementById('endereco').value=aEndereco[0];document.getElementById('numero').value=aEndereco[1];document.getElementById('cidade').value=aEndereco[2];document.getElementById('bairro').value=aEndereco[3];}}
xmlhttp.send(null);},submitFormPr:function(url){url=framework.AntiCache.url(url);xmlhttp=framework.xmlhttp();xmlhttp.open("GET",url,true);framework.set.Headers(xmlhttp);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.responseText=='sim'){alert('Limite exedido. Escolha outra data ou turno.');return false;}else{return true;}}}
xmlhttp.send(null);},redirect:function(msg,url){alert(msg);if(typeof(url)!="undefined"){document.location.href=url;}},confirm_exclusao:function(url,msg){var _msg=(typeof(msg)!="undefined")?msg:"Você tem certeza que deseja excluir o registro?";if(confirm(_msg)==true){document.location=url;}},go_to:function(url){document.location=url;},update_foto:function(id){xmlhttp=framework.xmlhttp();xmlhttp.open("GET",'combobox.php?type=7&id='+parseInt(id),true);framework.set.Headers(xmlhttp);xmlhttp.send(null);},vota_noticia:function(id,nota){xmlhttp=framework.xmlhttp();xmlhttp.open("GET",'votar_noticia.php?nota='+parseInt(nota)+'&id='+parseInt(id),true);framework.set.Headers(xmlhttp);xmlhttp.send(null);document.getElementById('barra_avalie').innerHTML='Muito obrigado pelo voto!';}}