
       
function CarregaItem(cod, item, obj, url)
{
	if (item == "gerenciador") {
		document.getElementById('Gerenciar').style.fontWeight = 'bold';
		document.getElementById('Enviar').style.fontWeight = 'normal';
		CarregaPagina(obj, url + '?cod=' + cod + '&modo=' + item);
	} else {
		document.getElementById('Gerenciar').style.fontWeight = 'normal';
		document.getElementById('Enviar').style.fontWeight = 'bold';
		CarregaPagina(obj, url + '?cod=' + cod + '&modo=' + item);
	}
}

function ativaUpCapas( categoria )
{
    var obj_capa1 = ( document.getElementById ) ? document.getElementById( 'capa1' ) : document.all.capa1;
    var obj_capa2 = ( document.getElementById ) ? document.getElementById( 'capa2' ) : document.all.capa2;
    var obj_acompanhe = ( document.getElementById ) ? document.getElementById( 'acompanhe' ) : document.all.acompanhe;

    var obj_capa1_caption = ( document.getElementById ) ? document.getElementById( 'capa1_caption' ) : document.all.capa1_caption;
    var obj_capa2_caption = ( document.getElementById ) ? document.getElementById( 'capa2_caption' ) : document.all.capa2_caption;
    var obj_acompanhe_caption = ( document.getElementById ) ? document.getElementById( 'acompanhe_caption' ) : document.all.acompanhe_caption;
        
    if ( !obj_acompanhe ) {    
      setTimeout("ativaUpCapas("+categoria+");", 500 );    
    } else {
    
        if ( obj_capa1 ) { 
		    if ( ( categoria == '1' ) || ( categoria == '2' ) || ( categoria == '3' ) ) {
		       obj_capa1.parentNode.parentNode.style.display = '';
		       obj_capa2.parentNode.parentNode.style.display = '';
		       obj_capa1_caption.parentNode.parentNode.style.display = '';
		       obj_capa2_caption.parentNode.parentNode.style.display = '';
		    } else {
		       obj_capa1.parentNode.parentNode.style.display = 'none';
		       obj_capa2.parentNode.parentNode.style.display = 'none';
		       obj_capa1_caption.parentNode.parentNode.style.display = 'none';
		       obj_capa2_caption.parentNode.parentNode.style.display = 'none';
		    }
	    }
	    if ( categoria != '5' ) {
	       obj_acompanhe.parentNode.parentNode.style.display = '';
	       obj_acompanhe_caption.parentNode.parentNode.style.display = '';
	    } else {
	       obj_acompanhe.parentNode.parentNode.style.display = 'none';
	       obj_acompanhe_caption.parentNode.parentNode.style.display = 'none';
	    }
    }
		
}

function uploadComplete()
{
	//if (arguments.length > 0)
		//parent.CarregaPagina('Fotos_' + arguments[0], url + '?cod=' + cod + '&modo=' + item);
}


function clearKey( valor, validos ){
  // retira caracteres invalidos da string
  var key_accept = "";
  var aux;
  for (var i=0; i < valor.length; i++) {
    aux = validos.indexOf(valor.substring(i, i+1));
    if (aux>=0) {
      key_accept += aux;
    }
  }
  return key_accept;
}

//Formata número tipo moeda usando o evento onKeyDown
function formatValue(campo,tammax,teclapres,decimal) {
  var tecla = teclapres.keyCode;
  vr = clearKey(campo.value,"0123456789");
  tam = vr.length;
  dec=decimal
  if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
  if (tecla == 8 ) { tam = tam - 1 ; }
  if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
    if ( tam <= dec ) { campo.value = vr ; }
    if ( (tam > dec) && (tam <= 5) ){
    campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 6) && (tam <= 8) ){
    campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
    }
    if ( (tam >= 9) && (tam <= 11) ){
    campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 12) && (tam <= 14) ){
    campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 15) && (tam <= 17) ){
    campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
  }
}


