
// default
// --------------------------------------------------------------
window.onerror = function () { return true }


// função de Trim
// --------------------------------------------------------------
function JStrim( p_str ) { return p_str . replace(/^\s+|\s+$/g, ""); } 


// atualiza combo de canais conforme oferta selecionada
// --------------------------------------------------------------
function reloadCanais( arrCanais, selectedOferta, eleCanal ) 
{
	var comboDestino = eval('document.getElementById( "'+eleCanal+'" )');

	comboDestino.options.length = 0;
	//comboDestino.disabled = true;
	
	for ( var i = 0; i <= arrCanais.length; i++ ) {

		if ( arrCanais[i][0] == selectedOferta ) {
			comboDestino.options.add( new Option( arrCanais[i][2], arrCanais[i][1]+'@'+arrCanais[i][3]+'@'+arrCanais[i][4] ) );
			if ( comboDestino.options.length > 1 ) {
				comboDestino.disabled = false;
			}
		} 
	}
}

// mudança automática de campo após preenchimento estipulado
// --------------------------------------------------------------
VerifiqueTAB=true;
function Mostra(quem, tammax) {
   if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
     var i=0,j=0, indice=-1;
     for (i=0; i<document.forms.length; i++) {
       for (j=0; j<document.forms[i].elements.length; j++) {
          if (document.forms[i].elements[j].name == quem.name) {
            indice=i;
            break;
          }
       }
 
     if (indice != -1) break;
  }
    
  for (i=0; i<=document.forms[indice].elements.length; i++) {
       if (document.forms[indice].elements[i].name == quem.name) {
          while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
                  (i < document.forms[indice].elements.length) ) {
             i++;
          }
          document.forms[indice].elements[(i+1)].focus();
          VerifiqueTAB=false;
          break;
       }
     }
   }
}
function PararTAB(quem) {
    VerifiqueTAB=false; 
}
function ChecarTAB() {
    VerifiqueTAB=true;
}
