var ua=navigator.userAgent.toLowerCase();var isGecko=(ua.indexOf('gecko')!=-1);var isMSIE=((ua.indexOf("msie")!=-1)&&(ua.indexOf("opera")==-1)&&(ua.indexOf("webtv")==-1));if(isGecko){HTMLElement.prototype.remove=function(){this.parentNode.removeChild(this);}}
function $(id_div){if(isMSIE)document.getElementById(id_div).remove=function(){this.parentNode.removeChild(this);}
return document.getElementById(id_div);}
function $F(nome_input){lista=document.getElementsByName(nome_input);obj=null;for(i=0;i<lista.length;i++){if(lista[i].tagName.match(new RegExp("select|input|textarea","i"))){obj=lista[i];break;}}
return obj;}
var Ajax=function(){var _privado={xmlhttp:null,stripScripts:function(texto){return texto.replace(new RegExp("<script[^>]*>([\\S\\s]*?)<\/script>",'img'),'');},extractScripts:function(texto){texto=texto.match(new RegExp("(<script[^>]*>).*?(<\/script>)","img"));if(texto==null)return texto;for(i=0;i<texto.length;i++){texto[i]=texto[i].replace(new RegExp("<script[^>]*>(.*?)<\/script>","img"),"$1");}
return texto;},Init_xmlhttp:function(url,parametros){var xmlhttp;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
else if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
else parametros.onFailure();xmlhttp.onreadystatechange=function()
{switch(xmlhttp.readyState){case 4:eval(parametros.onSuccess(xmlhttp));break;}}
var p="";if(parametros.parameters){for(i in parametros.parameters){p+=(p==""?(parametros.method=="get"?"?":""):"&")+i+"="+parametros.parameters[i];}}
xmlhttp.open(parametros.method,url+(parametros.method=="get"?p:""),true);if(parametros.method=="post"){xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.setRequestHeader("Content-length",parametros.parameters?parametros.parameters.length:0);xmlhttp.setRequestHeader("Connection","close");}
xmlhttp.send(parametros.method=="get"?null:p);return xmlhttp;}};var _publico={Updater:function(div,url,parametros){if(($(div)==null)||(url==""))return false;p={method:parametros.method?parametros.method.toLowerCase():"post",parameters:parametros.parameters,onSuccess:function(xmlhttp){var codigo=xmlhttp.responseText;var scripts=_privado.extractScripts(codigo);codigo=_privado.stripScripts(codigo);$(div).innerHTML=codigo;if((parametros.evalScripts)&&scripts){for(s=0;s<scripts.length;s++){eval(scripts[s]);}};if(parametros.onSuccess){parametros.onSuccess()};},onFailure:function(){if(parametros.onFailure){parametros.onFailure()};}}
if(!(xmlhttp=_privado.Init_xmlhttp(url,p)))return false;return true;}};return _publico;}();var Ajax_teste=function(){teste=1;var _privado={priv_v1:10,priv_f1:function(){return"privado f1: "+_privado.priv_v1;}};var _publico={pub_v1:1,pub_f1:function(v){teste+=v;},pub_f2:function(){alert(_privado.priv_f1());},pub_f3:function(){alert(teste);},fteste:function(ff){var init=function(){alert("inicializado");ff();};init();}};teste=100;return _publico;}();function addEvent(element,type,handler){if(typeof element=="string")element=$(element);if(element.addEventListener){element.addEventListener(type,handler,false);}else{if(!handler.$$guid)handler.$$guid=addEvent.guid++;if(!element.events)element.events={};var handlers=element.events[type];if(!handlers){handlers=element.events[type]={};if(element["on"+type]){handlers[0]=element["on"+type];}}
handlers[handler.$$guid]=handler;element["on"+type]=handleEvent;}};addEvent.guid=1;function removeEvent(element,type,handler){if(element.removeEventListener){element.removeEventListener(type,handler,false);}else{if(element.events&&element.events[type]){delete element.events[type][handler.$$guid];}}};function handleEvent(event){var returnValue=true;event=event||fixEvent(((this.ownerDocument||this.document||this).parentWindow||window).event);var handlers=this.events[event.type];for(var i in handlers){this.$$handleEvent=handlers[i];if(this.$$handleEvent(event)===false){returnValue=false;}}
return returnValue;};function fixEvent(event){event.preventDefault=fixEvent.preventDefault;event.stopPropagation=fixEvent.stopPropagation;return event;};fixEvent.preventDefault=function(){this.returnValue=false;};fixEvent.stopPropagation=function(){this.cancelBubble=true;};function Inicializa(){CarregaAnuncios();AdicionaSubmenus();}
function CarregaAnuncios(){if(document.getElementById("div_listaanuncios")==null)return false;var nscroll=0;var anuncios=$("div_listaanuncios").getElementsByTagName("a");for(var i=0;i<anuncios.length;i++){id="scroll_"+nscroll;div_titulo=anuncios[i].getElementsByTagName("strong")[0];if(div_titulo){div_titulo.setAttribute("id",id);addEvent(div_titulo,'mouseover',function(){ScrollDiv(this,"v",1);});addEvent(div_titulo,'mouseout',function(){ScrollDiv(this,"");});nscroll++;}
divs_scroll=anuncios[i].getElementsByTagName("p")[0]
if(divs_scroll)divs_scroll=divs_scroll.getElementsByTagName("span");if(divs_scroll){for(var s=0;s<divs_scroll.length;s++){if(divs_scroll[s].offsetHeight>=17){id="scroll_"+nscroll;if(divs_scroll[s]){divs_scroll[s].setAttribute("id",id);addEvent(divs_scroll[s],'mouseover',function(){ScrollDiv(this,"v",1);});addEvent(divs_scroll[s],'mouseout',function(){ScrollDiv(this,"");});nscroll++;}}}}}
fotos=document.getElementById("div_listaanuncios").getElementsByTagName("img");for(var i=0;i<fotos.length;i++){fotos[i].style.backgroundImage="url(img/caixaanuncio_foto.jpg?foto="+i+")";}}
function AdicionaSubmenus(){if(document.getElementsByClassName){submenus=document.getElementsByClassName("submenu");}
else{var submenus=[];tmp=document.getElementsByTagName("div");for(i=0;i<tmp.length;i++){if(tmp[i].className=="submenu")submenus.push(tmp[i]);}}
for(s=0;s<submenus.length;s++){if(submenus[s].innerHTML!="")break;var tipo=submenus[s].id.substr(8);new Ajax.Updater("submenu_"+tipo,"paginas/submenu-ajax.php",{method:"post",parameters:{tipo:tipo}});}}
function AbreJanela(url,titulo,tx,ty)
{janela=window.open(url,titulo,"width="+tx+",height="+ty);return false;}
function trim(stringToTrim){return stringToTrim.replace(/^\s+|\s+$/g,"");}
function ltrim(stringToTrim){return stringToTrim.replace(/^\s+/,"");}
function rtrim(stringToTrim){return stringToTrim.replace(/\s+$/,"");}
function CaixaAlerta1(tx,ty){div_videoyoutube=document.getElementById("obj_videoyoutube");if(div_videoyoutube!=null)div_videoyoutube.style.display="none";var caixatransparente=document.createElement("div");caixatransparente.setAttribute("id","div_fundopretotransparente");ctx=document.body.scrollWidth;if(ctx<document.documentElement.clientWidth)cty=document.documentElement.clientWidth;cty=document.body.scrollHeight;if(cty<document.documentElement.clientHeight)cty=document.documentElement.clientHeight;caixatransparente.style.width=ctx+"px";caixatransparente.style.height=cty+"px";document.body.appendChild(caixatransparente);var div_caixaalerta=document.createElement("div");div_caixaalerta.setAttribute("id","div_caixaalerta");x=Math.round((document.documentElement.clientWidth/2)-(tx/2));y=Math.round((document.documentElement.clientHeight/2)-(ty/2));div_caixaalerta.style.left=x+"px";div_caixaalerta.style.top=y+"px";div_caixaalerta.style.width=tx+"px";div_caixaalerta.style.height=ty+"px";div_caixaalerta.style.backgroundImage="url(img/loading.gif)";document.body.appendChild(div_caixaalerta);new Ajax.Updater("div_caixaalerta","paginas/caixaalerta-ajax.php",{evalScripts:true,onSuccess:function(){div_caixaalerta.style.backgroundImage="";},onFailure:function(){}});AddEvent(window,"resize",PosicionaCaixaAlerta1);}
function ApagaCaixaAlerta1(){document.body.removeChild(document.getElementById("div_fundopretotransparente"));document.body.removeChild(document.getElementById("div_caixaalerta"));div_videoyoutube=document.getElementById("obj_videoyoutube");if(div_videoyoutube!=null)div_videoyoutube.style.display="";}
function PosicionaCaixaAlerta1(){ctx=document.body.scrollWidth;if(ctx<document.documentElement.clientWidth)cty=document.documentElement.clientWidth;cty=document.body.scrollHeight;if(cty<document.documentElement.clientHeight)cty=document.documentElement.clientHeight;$("div_fundopretotransparente").style.width=ctx+"px";$("div_fundopretotransparente").style.height=cty+"px";tx=$("div_caixaalerta").offsetWidth;ty=$("div_caixaalerta").offsetHeight;x=Math.round((document.documentElement.clientWidth/2)-(tx/2));y=Math.round((document.documentElement.clientHeight/2)-(ty/2));$("div_caixaalerta").style.left=x+"px";$("div_caixaalerta").style.top=y+"px";}
function ActualizaCaixaAlerta1(div){if(div!=""){new Ajax.Updater(div,"paginas/caixaalerta-ajax.php",{evalScripts:true,onSuccess:function(){document.getElementById(div).style.backgroundImage="";},onFailure:function(){}});}}
function EnviaFormAjax(idform,div,fichphp){form=document.getElementById(idform);var parametros=new Array();inputs=form.getElementsByTagName("input");for(i=0;i<inputs.length;i++){if(inputs[i].id!=undefined)
parametros[inputs[i].name]=inputs[i].value;}
inputs=form.getElementsByTagName("textarea");for(i in inputs){if(inputs[i].id!=undefined)
parametros[inputs[i].name]=inputs[i].value;}
if(div!=""){$(div).innerHTML="";$(div).style.backgroundImage="url(img/loading.gif)";}
new Ajax.Updater(div,fichphp,{method:"post",parameters:parametros,evalScripts:true,onSuccess:function(){if(div!="")document.getElementById(div).style.backgroundImage="";},onFailure:function(){}});}
function EnviaFormIframe(idform,div,fichphp){form=document.getElementById(idform);var iframe;try{var iframe=document.createElement("<iframe name='target' id='iframe_form' style='display:none'>");}
catch(ex){var iframe=document.createElement("iframe");iframe.setAttribute("name","target");iframe.setAttribute("id","iframe_form");iframe.setAttribute("style","display:none");}
document.body.appendChild(iframe);form.action=fichphp;form.target="target";form.submit();if(div!=""){$(div).innerHTML="";$(div).style.backgroundImage="url(img/loading.gif)";}}
function FechaFormIframe(){document.body.removeChild($("iframe_form"));}
var scroll_timeout=null;var scroll_timeout_reset=null;var scroll_div_reset="";function ScrollDiv(div,orientacao,direccao){if(typeof(div)!="string")div=div.id;if((scroll_div_reset!=div)&&(scroll_div_reset!=""))ScrollDivReset();clearTimeout(scroll_timeout);clearTimeout(scroll_timeout_reset);if(orientacao==""){scroll_div_reset=div;scroll_timeout_reset=setTimeout("ScrollDivReset()",50);}
else if(orientacao=="h"){document.getElementById(div).scrollLeft=document.getElementById(div).scrollLeft+direccao;scroll_timeout=setTimeout("ScrollDiv('"+div+"', '"+orientacao+"', "+direccao+")",100)}
else if(orientacao=="v"){document.getElementById(div).scrollTop=document.getElementById(div).scrollTop+direccao;scroll_timeout=setTimeout("ScrollDiv('"+div+"', '"+orientacao+"', "+direccao+")",100)}}
function ScrollDivReset(){document.getElementById(scroll_div_reset).scrollTop=0;document.getElementById(scroll_div_reset).scrollLeft=0;clearTimeout(scroll_timeout);clearTimeout(scroll_timeout_reset);scroll_div_reset="";}
function MostraSubmenu(id){x=document.getElementById("menu_"+id).offsetLeft+10;y=document.getElementById("menu_"+id).parentNode.offsetTop+25;document.getElementById("submenu_"+id).style.left=x+"px";document.getElementById("submenu_"+id).style.top=y+"px";document.getElementById("submenu_"+id).style.display="";}
function EscondeSubmenu(id){document.getElementById("submenu_"+id).style.display="none";}
Array.prototype.find=function(searchStr){var returnArray=false;for(i=0;i<this.length;i++){if(typeof(searchStr)=='function'){if(searchStr.test(this[i])){if(!returnArray){returnArray=[]}
returnArray.push(i);}}else{if(this[i]===searchStr){if(!returnArray){returnArray=[]}
returnArray.push(i);}}}
return returnArray;}