// JavaScript Document
ns = document.layers;
ie = document.all;
ns6 = (document.getElementById && !document.all);
function moveMouse(e){
 if(ie){
  posx = event.clientX;
  posy = event.clientY;
 } else if (ns){
  posx = e.x;
  posy = e.y;
 } else if (ns6){
  posx = e.clientX;
  posy = e.clientY;
 }
}
if(ns) { document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove = moveMouse;

function validafrm(vl,vs){
 pr = '';
 if ((document.getElementById(vl).value == '') || (document.getElementById(vl).value == 'Login')) {
  alert('Você tem que preencher o login/email');
  document.getElementById(vl).focus();
  pr = '1';
 }
 if ((vs != '') && (pr == '')) {
  if ((document.getElementById(vs).value == '') || (document.getElementById(vs).value == 'Senha')) {
   alert('Você tem que preencher a senha');
   document.getElementById(vs).focus();
   pr = '1';
  }
 }
 if (pr == '') { return true; }
 return false;
}

var td='';
var inttitle=0;
var start='';
function colocatitle(tt){
 top.document.title=tt;
}
function reloadstop(tt){
 clearInterval(inttitle);
 this.start='';
 top.document.title=tt;
}
function reloadtitle(p,tt){
 clearInterval(inttitle);
 if (p == 3) { this.start = 1; }
 if (p == 1) { colocatitle("Diz: Mensagem"); pr = 2; } else { colocatitle(tt); pr = 1; }
 if (this.start == 1) {
  inttitle = window.setInterval( function() { reloadtitle(pr,tt); }, 1000);
  top.window.focus();
  parent.cafmainFrame.document.getElementById('msg').focus();
 } else {
  colocatitle(tt);
 }
}
function advertpro(regiao,width,height) {
 document.write('<SCR'+'IPT src="http://adn.bonde.com.br/advertpro/servlet/view/banner/javascript/zone?zid='+regiao+'&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'&referrer='+escape(document.location)+'" language="JavaScript" type="text/javascript"></SCR'+'IPT>');
}
function copyright () {
 //setInterval("window.clipboardData.clearData()",1); // IE
 alert('Prezado leitor,\n\nNÃ£o Ã© permitida a utilizaÃ§Ã£o desse conteÃºdo para fins comerciais e/ou profissionais. Para comprar ou obter autorizaÃ§Ã£o de uso desse conteÃºdo, entre em contato com o Portal Bonde pelo e-mail: redacao@bonde.com.br');
}
function disableselect(E){
 return false;
}
function reEnable(){
 return true;
}
function submitwin(id,oper){
 //alert(id + ' - ' + oper);
 var head = document.getElementById(id);
 var eScript = document.createElement('script');
 eScript.setAttribute('src','/acao.php?'+oper);
 head.appendChild(eScript);
}
function restricao(){
 document.onselectstart=new Function ("return false")
 document.onmousedown=disableselect;
 document.onclick=reEnable;
 document.getElementById('resttexto').blur();
}
function clear_campo(tp) {
 if (tp == 'busca') {
  document.getElementById('qbusca').value = '';
 }
}

function validaSubmit() {
 if (document.getElementById('login_frm').value == "") {
  alert ("VocÃª tem que preencher o e-mail");
  document.getElementById('login_frm').focus();
  return false;
 } else if (document.getElementById('senha_frm').value == "") {
  alert ("VocÃª tem que preencher a senha");
  document.getElementById('senha_frm').focus();
  return false;
 } else {
  return true;
 }
}

function excluir(form) {
 if(confirm('VocÃª tem certeza que deseja excluir?')) { return true; } else { return false; }
}
var oldCellColor = "#000";
function focusRow(row) {
	var cells = row.cells;
	if (!cells) return;
	oldCellColor = cells[0].style.backgroundColor;
	for (var i=0;i<cells.length;i++) {
		cells[i].style.backgroundColor='whitesmoke';
	}
}
function blurRow(row) {
	var cells = row.cells;
	if (!cells) return;
	for (var i=0;i<cells.length;i++) {
		cells[i].style.backgroundColor=oldCellColor;
	}
}

function janela(url, width, height, scroll, resizable, name) {
 var Win = window.open(url, name,'width=' + width + ',height=' + height +',scrollbars=' + scroll + ',resizable=' + resizable + ',menubar=no,status=no,left=50,top=50');
 Win.focus();
}

function linkUrl (url) {
 var Win = opener.open(url);
 Win.focus();
}

function textCounter(field, countfield, maxlimit) {
 if (field.value.length > maxlimit)
  field.value = field.value.substring(0, maxlimit);
 else 
  countfield.value = maxlimit - field.value.length;
}

function verificaCPF(cpf){
 var numeros, digitos, soma, i, resultado, digitos_iguais;
 for (i=0;i<4;i++) {
  cpf = cpf.replace(".","");
  cpf = cpf.replace("-","");
 }
 digitos_iguais = 1;
 if (cpf.length < 11)
  return false;
 for (i = 0; i < cpf.length - 1; i++)
 if (cpf.charAt(i) != cpf.charAt(i + 1)){
  digitos_iguais = 0;
   break;
 }
 if (!digitos_iguais){
  numeros = cpf.substring(0,9);
  digitos = cpf.substring(9);
  soma = 0;
  for (i = 10; i > 1; i--)
  soma += numeros.charAt(10 - i) * i;
  resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
  if (resultado != digitos.charAt(0))
   return false;
  numeros = cpf.substring(0,10);
  soma = 0;
  for (i = 11; i > 1; i--)
   soma += numeros.charAt(11 - i) * i;
  resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
  if (resultado != digitos.charAt(1))
   return false;
  return true;
 }else
   return false;
}

function newcaptcha() {
 var head = document.getElementById("idCaptcha");
 var eScript = document.createElement('script');
 eScript.setAttribute('src','/captcha.php?oper=newgera');
 head.appendChild(eScript);
}

function clearText (loc) {
 if (loc == "Login") {
  if (document.frmL.frmLogin.value == "Login") {
   document.frmL.frmLogin.value = "";
  }
 } else if (loc == "Senha") {
  if (document.frmL.frmSenha.value == "*****") {
   document.frmL.frmSenha.value = "";  
  }
 } else if (loc == "cadastro") {
  p1 = document.frmL.frmLogin.value;
  p2 = document.frmL.frmSenha.value;
  if ((p1 == "") || (p1 == "Login") || (p2 == "")) {
   if (p2 == "") {
    document.frmL.frmSenha.focus();
   } else {
    document.frmL.frmLogin.value = "";
    document.frmL.frmLogin.focus();
   }
   alert ("VocÃª tem que digitar seu login e senha");
   return false;
  } else { return true; }
 } else if (loc == "textBusca") {
  if (document.frm.q.value == "Busca") {
   document.frm.q.value = "";
  }
 } else if (loc == "busca") {
  if ((document.frm.q.value == "Busca") || (document.frm.q.value == "")) {
   document.frm.q.value = "";
   document.frm.q.focus();
   alert ("VocÃª tem que digitar a palavra para fazer a busca");
   return false;
  } else {
   return true;
  }
 }
}

function menu(frm) {
 window.location.href= frm.value;
}
function menu2(lnk,frm) {
 window.location.href= lnk + frm.value;
}

/* INICIO YOUTYBE */
var IE = document.all?true:false;
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
}

function abre_video(tag_musica) {
 var d=document.getElementById('video');
 d.style.display='block';	
 swidth = 375;
 sheight = 310;
 //alert(posx + ' - ' + posy);
 //d.style.top = posy;
 //d.style.left = posx;
 htmlps = '<div><div class="tamanho"><a title="fechar" href="#" onclick="fecha_youtube(&#39;video&#39;);return false;"/></a><a href="#" title="grande" onclick="altera_tamanho_youtube(3,&#39;video&#39;);return false;"/></a><a href="#" title="mÃ©dio" onclick="altera_tamanho_youtube(2,&#39;video&#39;);return false;"/></a><a href="#" title="pequeno"onclick="altera_tamanho_youtube(1,&#39;video&#39;);return false;"/></a></div></div>';
 htmlps = htmlps + '<object id="obj_video" width="'+swidth+'" height="'+sheight+'" align="middle" type="application/x-shockwave-flash" id="swfobj" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="http://www.youtube.com/v/'+tag_musica+'&autoplay=1" name="movie"/><param value="high" name="quality"/><param value="Transparent" name="wmode"/><embed id="ebd_video" width="'+swidth+'" height="'+sheight+'" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="Transparent" type="application/x-shockwave-flash" allowscriptaccess="sameDomain" name="flashobj" quality="high" flashvars="" src="http://www.youtube.com/v/'+tag_musica+'&autoplay=1"/></embed></object>';
 d.innerHTML=htmlps;
 altera_tamanho_youtube(3,'video');
}

function closediv(ids) {
 var elemento=document.getElementById(ids);
 elemento.innerHTML='';
 elemento.style.display='none';	
}

function abre_video2(ids,tag_musica) {
var d=document.getElementById(ids);
 d.style.display='block';	
 swidth = 375;
 sheight = 310;
 //alert(posx + ' - ' + posy);
 lnk = 'http://www.youtube.com/v/'+tag_musica+'&autoplay=1';
// htmlps = '<div><div class="tamanho"><a title="fechar" href="#" onclick="fecha_youtube(&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="grande" onclick="altera_tamanho_youtube(3,&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="mÃ©dio" onclick="altera_tamanho_youtube(2,&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="pequeno"onclick="altera_tamanho_youtube(1,&#39;'+ids+'&#39;);return false;"/></a></div></div>';
 htmlps = "<div style='width:368px;border:1px solid #ACA899;background:#ECE8D8;text-align:right;padding:3px 5px 3px 0px'><a href=javascript:closediv('"+ids+"') style='color:#FFFFFF;background:#ACA899;font-size:12px;padding:2px'><b>X</b></a></div>";
 htmlps = htmlps + '<div><object id="obj_video" width="'+swidth+'" height="'+sheight+'" align="middle" type="application/x-shockwave-flash" id="swfobj" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="'+lnk+'" name="movie"/><param value="high" name="quality"/><param value="Transparent" name="wmode"/><embed id="ebd_video" width="'+swidth+'" height="'+sheight+'" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="Transparent" type="application/x-shockwave-flash" allowscriptaccess="sameDomain" name="flashobj" quality="high" flashvars="" src="'+lnk+'"/></embed></object></div>';
 d.innerHTML=htmlps;
 //altera_tamanho_youtube(3,ids);
 
 ids2 = ids.replace("letra","");
 var head = document.getElementById(ids);
 var eScript = document.createElement('script');
 eScript.setAttribute('src','/acao.php?oper=musica_video&id='+ids2);
 head.appendChild(eScript);
}

function abre_audio(ids,tag_musica) {
 var d=document.getElementById(ids);
 d.style.display='block';	
 swidth = 200;
 sheight = 50;
 //alert('A[' + posx + ' - ' + posy + ']');
// htmlps = '<div><div class="tamanho"><a title="fechar" href="#" onclick="fecha_youtube(&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="grande" onclick="altera_tamanho_youtube(3,&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="mÃ©dio" onclick="altera_tamanho_youtube(2,&#39;'+ids+'&#39;);return false;"/></a><a href="#" title="pequeno"onclick="altera_tamanho_youtube(1,&#39;'+ids+'&#39;);return false;"/></a></div></div>';
 htmlps = "<div style='width:194px;border:1px solid #ACA899;background:#ECE8D8;text-align:right;padding:3px 5px 3px 0px'><a href=javascript:closediv('"+ids+"') style='color:#FFFFFF;background:#ACA899;font-size:12px;padding:2px'><b>X</b></a></div>";
 htmlps = htmlps + "<object type='application/x-shockwave-flash' data='/new/img/player.swf' width='200' height='20'><param name='wmode' value='transparent' /><param name='movie' value='/new/img/player.swf' /><param name='FlashVars' value='mp3="+tag_musica+"&amp;bgcolor1=ffffff&amp;bgcolor2=cccccc&amp;buttoncolor=999999&amp;buttonovercolor=0&amp;slidercolor1=cccccc&amp;slidercolor2=999999&amp;sliderovercolor=666666&amp;textcolor=0&amp;showvolume=1' /></object>";
 d.innerHTML=htmlps;
 
 ids2 = ids.replace("letra","");
 var head = document.getElementById(ids);
 var eScript = document.createElement('script');
 eScript.setAttribute('src','/acao.php?oper=musica_audio&id='+ids2);
 head.appendChild(eScript);
}

function fecha_youtube(ids) {
 var elemento=document.getElementById(ids);
 elemento.innerHTML='';
 elemento.style.display='none';	
 if(ns) { document.captureEvents(Event.MOUSEMOVE); }
 document.onmousemove = moveMouse;
 //alert('C[' + posx + ' - ' + posy + ']');
}

function altera_tamanho_youtube(tamanho,ids) {	
  switch(tamanho)
  {
   case 1:var largura='170';var altura='138';var x=1;break;
   case 2:var largura='250';var altura='200';var x=2;break;
   case 3:var largura='375';var altura='300';var x=2;break;
   default: var largura='375';var altura='300';var x=2;break;
  }
  var elemento=document.getElementById('det_video');
  elemento=document.getElementById(ids);
  elemento.style.width=largura+'px';
  
  elemento=document.getElementById('obj_video');
  elemento.width=largura;
  elemento.height=altura;
  if(!IE)
  {  
   elemento=document.getElementById('ebd_video');
   elemento.width=largura;
   elemento.height=altura;
  }
}

var DragHandler = {
 _oElem : null,
 attach : function(oElem) {
  oElem.onmousedown = DragHandler._dragBegin;
  // callbacks
  oElem.dragBegin = new Function();
  oElem.drag = new Function();
  oElem.dragEnd = new Function();
  return oElem;
 },

 _dragBegin : function(e) {
  var oElem = DragHandler._oElem = this;
  if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
  if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }
  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);
  e = e ? e : window.event;
  oElem.mouseX = e.clientX;
  oElem.mouseY = e.clientY;
  oElem.dragBegin(oElem, x, y);
  document.onmousemove = DragHandler._drag;
  document.onmouseup = DragHandler._dragEnd;
  return false;
 },

 _drag : function(e) {
  var oElem = DragHandler._oElem;
  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);
  e = e ? e : window.event;
  oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
  oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';
  oElem.mouseX = e.clientX;
  oElem.mouseY = e.clientY;
  oElem.drag(oElem, x, y);
  return false;
 },

 _dragEnd : function() {
  var oElem = DragHandler._oElem;
  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);
  oElem.dragEnd(oElem, x, y);
  document.onmousemove = null;
  document.onmouseup = null;
  DragHandler._oElem = null;
 }
}

function moveon(elemento){
 DragHandler.attach(elemento);
}

function pos() {
 var ss = document.getElementById('subset');
 var gog = document.getElementById('google');
 if (document.body.clientWidth >= 940){
  ss.style.position = 'absolute';
  ss.style.top = 55+'px';
  ss.style.left = 810+'px';
  gog.style.top = 310+'px';
 } else {
  ss.style.position = 'static';
  gog.style.top = 65+'px';
 }
}
/* END YOUTUBE*/
function voto(v,idd,oper) {
 var head = document.getElementById("idVoto");
 var eScript = document.createElement('script');
 var cor = "EB6A00";
 if (oper == "receita"){ cor = "FFFFFF"; }
 if (oper == "banda") { cor = "174173"; }
 document.getElementById('idVotar').innerHTML = "<span style='color:#"+cor+"'><center>Obrigado!</center></span>";
 document.getElementById('idVoto').innerHTML = "*** votos";
 eScript.setAttribute('src','acao.php?oper='+oper+'&id='+idd+'&voto='+v);
 head.appendChild(eScript); 
}

function acao(idlayer,idlayret,oper,id,id1,id2,id3) {
 //alert('idlayer:'+idlayer+'idlayret:'+idlayret+'oper:'+oper+'id:'+id+'id1:'+id1+'id2:'+id2+'id3:'+id3);
 var head = document.getElementById(idlayer);
 var eScript = document.createElement('script');
 pr = '';
 if (idlayer != '') { pr = pr + '&idlayer=' + idlayer; }
 if (idlayret != '') { pr = pr + '&idlayret=' + idlayret; }
 if (id != '') { pr = pr + '&id=' + id; }
 if (id1 != '') { if (document.getElementById(id1)) { pr = pr + '&' + id1 + '=' + document.getElementById(id1).value; } }
 if (id2 != '') { if (document.getElementById(id2)) { pr = pr + '&' + id2 + '=' + document.getElementById(id2).value; } }
 if (id3 != '') { if (document.getElementById(id3)) { pr = pr + '&' + id3 + '=' + document.getElementById(id3).value; } }
 eScript.setAttribute('src','?'+oper+pr);
 head.appendChild(eScript);
}

function isNumeric(elem){
 var numericExpression = /^[0-9]+$/;
 if(elem.value.match(numericExpression)){
  return true;
 }else{
  elem.focus();
  elem.value = elem.value.substring(0, (elem.value.length -1));
  return false;
 }
}

function isEmail(val) {
 if (val.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/)){
  return true;
 }else{
  return false;
 } 
}

function validaFormCad(){
  alert("erro");
  return false;
}

// FONT SIZE MANAGEMENT 
function FindObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ChangeProp(objName,x,theProp,theValue) { //v6.0
var obj = FindObj(objName);
if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
if (theValue == true || theValue == false)
eval("obj."+theProp+"="+theValue);
else eval("obj."+theProp+"='"+theValue+"'");
}
}

function LoadActualFontSize() {
tempArray = document.cookie.split(";");
for (tA = 0; tA < tempArray.length; tA++){
if (tempArray[tA].indexOf('fontSize') > -1){
fontSizeValue = tempArray[tA].split("=");
ACTUAL_FONTSIZE = parseInt(fontSizeValue[1]);
}
}
}

function SaveActualFontSize() {
var expire = new Date ();
expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
expire = expire.toGMTString();
document.cookie="fontSize="+ACTUAL_FONTSIZE+"; path=/; expires="+expire;
}

function Bigger(tp) {
ACTUAL_FONTSIZE = 16;
SMALLEST_FONTSIZE = 12;
LARGEST_FONTSIZE = 20;
ACTUAL_FONTSIZE = ACTUAL_FONTSIZE+1;
if (ACTUAL_FONTSIZE > LARGEST_FONTSIZE) { ACTUAL_FONTSIZE = LARGEST_FONTSIZE }
ChangeProp(tp,'','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
SaveActualFontSize();
}

function Smaller(tp) {
ACTUAL_FONTSIZE = 16;
SMALLEST_FONTSIZE = 12;
LARGEST_FONTSIZE = 20;
ACTUAL_FONTSIZE = ACTUAL_FONTSIZE-1;
if (ACTUAL_FONTSIZE < SMALLEST_FONTSIZE) { ACTUAL_FONTSIZE = SMALLEST_FONTSIZE }
ChangeProp(tp,'','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
SaveActualFontSize();
}

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}

function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}

function openbox(fadin)
{
  var box = document.getElementById('cadbox'); 
  document.getElementById('cadfilter').style.display='block';
  
  if(fadin)
  {
	 gradient("cadbox", 0);
	 fadein("cadbox");
  }
  else
  { 	
    box.style.display='block';
  }  	
}

function closebox()
{
   document.getElementById('cadbox').style.display='none';
   document.getElementById('cadfilter').style.display='none';
}

function sizeFont(elem, acao){
 // Quantidade
 var qtd = 2;
 // tamanho inicial da fonte (em px)
 var tamInic = 16;
 // Tamanho mÃ­nimo da [b]fonte (em px)
 var tamMin = 12;
 // Tamanho mÃ¡ximo da fonte (em px)
 var tamMax = 20;
 // Pega o tamanho da fonte. Se nÃ£o foi setada ainda (primeira vez que a funÃ§Ã£o Ã© executada) terÃ¡ como tamanho padrÃ£o 'tamInic'.
 if (document.getElementById(elem).style.fontSize == "") {
  var tamFonte = tamInic;
 } else {
  var tamFonte = parseInt(document.getElementById(elem).style.fontSize);
 }
 //alert('[' + document.getElementById(elem).style.fontSize + '] - [' + tamFonte + '] - [' + tamInic + '] - [' + acao + '] - ['+elem+']');
 switch (acao){
  // Aumenta o tamanho, enquanto foi menor que 'tamMax'
  case '+':
   if (tamFonte < tamMax)
   document.getElementById(elem).style.fontSize = (tamFonte + qtd) + "px";
  break;
  // Diminui o tamanbo, enquanto for maior que 'tamMin'
  case '-':
  if (tamFonte > tamMin)
   document.getElementById(elem).style.fontSize = (tamFonte - qtd) + "px";
  break;
 }
}
// SCRIPTS DO OPER_DEFAULT 
function Checker(fd) {
 (fd.value.length>2000) ? fd.value=fd.value.substring(0,2000) : document.getElementById('sobra').childNodes[0].data=(2000-fd.value.length);
}
function sendOpiniao(ids) {  
 pas = '';
 if (document.getElementById("nome"))      { pas = pas + "&nome="+document.getElementById("nome").value; }
 if (document.getElementById("email"))     { pas = pas + "&email="+document.getElementById("email").value; }
 if (document.getElementById("cidade"))    { pas = pas + "&cidade="+document.getElementById("cidade").value; }
 if (document.getElementById("cpf"))       { pas = pas + "&cpf="+document.getElementById("cpf").value; }
 if (document.getElementById("rg"))        { pas = pas + "&rg="+document.getElementById("rg").value; }
 if (document.getElementById("profissao")) { pas = pas + "&profissao="+document.getElementById("profissao").value; }
 if (document.getElementById("telefone"))  { pas = pas + "&telefone="+document.getElementById("telefone").value; }
 if (document.getElementById("endereco"))  { pas = pas + "&endereco="+document.getElementById("endereco").value; }
 if (document.getElementById("opiniao"))   { pas = pas + "&opiniao="+document.getElementById("opiniao").value; }
 if (document.getElementById("opiniao").value == '') {
  alert('Você tem que preencher a opinião');
  document.getElementById('opiniao').focus();
 } else {
  document.getElementById('idopiniao').innerHTML = "<div style='padding:10px 0px'><center><img src='_img/_icones/ic-loading.gif'></center></div>";
  acao('operindex','','oper=acao&op=opiniao&acao=grava&id_folha='+ids+pas,'','','','');
 }
 return false;
}
function ajax(indice){
 if(indice){
  document.getElementById("topfolha").innerHTML = "<div align='center'><img src='_img/ajax.gif'></div>";
  var head = document.getElementById("topfolha");
  var eScript = document.createElement('script');
  eScript.setAttribute('src','/oper_acao.php?op=topfolha&indice='+indice);
  head.appendChild(eScript);
 }
}
// FIM SCRIPTS DO OPER_DEFAULT 

function maskInput(f, m) {
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[Àÿ]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask);
} 
//Manipulador de Eventos: addEvent e removeEvent cross-browser
addEvent = function(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
};
removeEvent = function(o, e, f, s){
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
};

function verifica_data(obj) { 
 dia = (obj.value.substring(0,2)); 
 mes = (obj.value.substring(3,5)); 
 ano = (obj.value.substring(6,10)); 
 pr2 = true; 
 if ((dia) && (mes) && (ano)) {
  dia = eval(dia);
  mes = eval(mes);
  ano = eval(ano);
  // verifica o dia valido para cada mes 
  if ((dia < 1) || (((dia < 1 || dia > 30)) && ((mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))) || (dia > 31)) { 
      pr2 = false; 
  } 
  // verifica se o mes e valido 
  if (mes < 01 || mes > 12 ) { 
      pr2 = false; 
  } 
  // verifica se e ano bissexto 
  if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
      pr2 = false 
  } 
  if (ano < 1900) { pr2 = false; }
 } else { pr2 = false; }
 return pr2;
} 

function enviarbusca(idc,idp){
 pas = '';
 if (document.getElementById(idc).value == '') {
  alert('Você tem que selecionar a categoria');
  document.getElementById(idc).focus();
 } else {
  pas = pas + "id_folha=" + document.getElementById(idc).value;
  if (document.getElementById(idp).value != 'Palavra-chave') {
   pas = pas + '&palavra='+document.getElementById(idp).value
  }
  window.location.href='?'+pas;
 }
 return false;
}

function mudaclass(idp) {
 if (document.getElementById(idp).style.display == 'none') {
  document.getElementById(idp).style.display = '';
 } else {
  document.getElementById(idp).style.display = 'none';
 }
}
