function bondeTicker(op,fmt,width,height) {
 if (BTicker) {
  qt = BTicker.length-1;
  v2 = '';
  if (fmt == 'ver') { v2 = '2'; }
  if (op == 'pause') {
   clearInterval(intervalo);
   document.getElementById('control').innerHTML = "<img src='http://www.bonde.com.br/bondenews/bondinho/ic-play.gif' onclick='bondeTicker(&#39;play&#39;,&#39;"+fmt+"&#39;,&#39;"+width+"&#39;,&#39;"+height+"&#39;)'>";
  } else {
   if (op == 'play') {
    document.getElementById('control').innerHTML = "<img src='http://www.bonde.com.br/bondenews/bondinho/ic-pause"+v2+".gif' onclick='bondeTicker(&#39;pause&#39;,&#39;"+fmt+"&#39;,&#39;"+width+"&#39;,&#39;"+height+"&#39;)'>";
    window.setInterval( function() { bondeTicker('',fmt,width,height); }, 5000);
   }
   if (this.layUNC) {
    if (this.layUNC == qt) {
     if (op == 'last') {
      this.layUNC--;
     } else {
      this.layUNC=1;
     }
    } else {
     if (op == 'last') {
      if (this.layUNC == 1) {
       this.layUNC = qt;
 	  } else {
	   this.layUNC--;
	  }
     } else {
      this.layUNC++;
     }
    }
   } else { this.layUNC = 1; }

   if (fmt == 'ver') {
    H = '<div style=padding:4px 1px>' + BTicker[this.layUNC] + '</div>';
	if (BTicker[this.layUNC+1]) { H = H + '<hr><div style=padding:4px 1px>' + BTicker[this.layUNC+1] + '</div>'; }
	if ((width) && (height)) {
	 if ((width == '234') && (height == '300')) {
	  if (BTicker[this.layUNC+2]) { H = H + '<hr><div style=padding:4px 1px>' + BTicker[this.layUNC+2] + '</div>'; }
	 }
	}
   } else {
    H = BTicker[this.layUNC];
   }
   document.getElementById('layUN01').innerHTML = H;
  }
 }
}

function bondeCanal(op,fmt) {
 if (idselect == '') { idselect = '1-3'; }
 if (this.layCANAL) { 
  if (op == 'last') { 
   if (this.layCANAL == 1) { this.layCANAL = CANALNOME.length-1; } else { this.layCANAL--; }
  } else { this.layCANAL++; }
  if (this.layCANAL == CANALNOME.length) { this.layCANAL = 1; }
 } else { this.layCANAL = 1; }
 pr=2; pr2=1; pr3 = ''; H = '';
 for (i=1;i<CANALNOME.length;i++) {
  if (idselect == CANALID[i]) { pr3 = '1'; }
  if ((this.layCANAL < pr) && (pr3 == '1')) {
   if (fmt == 'ver') {
    H = H + "<tr><td align='center' style='background:"+CANALBG[i]+";border-bottom:1px solid #FFFFFF;cursor:pointer;' onclick='mudaCanal(&#39;"+CANALID[i]+"&#39;,&#39;"+fmt+"&#39;)'><img src='http://www.bonde.com.br/bondenews/bondinho/ic"+CANALID[i]+".gif'></td></tr>";
   } else {
    H = H + "<td style='background:"+CANALBG[i]+";color:"+CANALCOLOR[i]+";cursor:pointer;' onclick='mudaCanal(&#39;"+CANALID[i]+"&#39;,&#39;"+fmt+"&#39;)'>"+CANALNOME[i]+"</td>";
   }
   pr2++;
  }
  pr++;
 }
 //alert(pr2);
 if (pr2 < 7) {
  for (i=1;i<5;i++) {
   if (CANALNOME[i]) {
    if (fmt == 'ver') {
     H = H + "<tr><td align='center' style='background:"+CANALBG[i]+";border-bottom:1px solid #FFFFFF;cursor:pointer;' onclick='mudaCanal(&#39;"+CANALID[i]+"&#39;,&#39;"+fmt+"&#39;)'><img src='http://www.bonde.com.br/bondenews/bondinho/ic"+CANALID[i]+".gif'></td></tr>";
	} else {
     H = H + " <td style='background:"+CANALBG[i]+";color:"+CANALCOLOR[i]+";cursor:pointer;' onclick='mudaCanal(&#39;"+CANALID[i]+"&#39;,&#39;"+fmt+"&#39;)'>"+CANALNOME[i]+"</td>";
	}
   }
  }
 }
 if (fmt != 'ver') { H = '<tr>'+H+'</tr>'; }
 H = "<table width='100%' cellpadding=0 cellspacing=0 border=0 id='dataseq'>" + H + "</table>";
 document.getElementById('laymenu').innerHTML = H;
}

function mudaCanal(canal,fmt) {
 var head = document.getElementById('idticker');
 var eScript = document.createElement('script');
 this.layUNC = 1;
 if (fmt == 'ver') {
  for (i=1;i<CANALNOME.length;i++) {
   if (CANALID[i] == canal) {
    document.getElementById('datatop').innerHTML = '<b>'+CANALNOME[i]+'</b>';
   }
  }
 }
 eScript.setAttribute('src',"http://www.bonde.com.br/acao.php?oper=ticker&id_bonde="+canal);
 head.appendChild(eScript);
}