function flash(largura, altura, arquivo, transparencia){
 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
 document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="'+transparencia+'" /><param name="menu" value="false" />');
 document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="'+transparencia+'" menu="false" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
 document.write('</object>');
}
function NumberOnly(obj, e) {
    var tecla = (window.event) ? e.keyCode : e.which;
    if (tecla == 8 || tecla == 0)
        return true;
    if (tecla != 44 && tecla != 46 && tecla < 48 || tecla > 57)
        return false;
}
function IntegerOnly(obj, e) {
    var tecla = (window.event) ? e.keyCode : e.which;
    if (tecla == 8 || tecla == 0)
        return true;
    if (tecla != 46 && tecla < 48 || tecla > 57)
        return false;
}
function checa_tamanho(strCampo, strQtdRestante, intTamanho) {
    if (strCampo.value.length > intTamanho) {
        strCampo.value = strCampo.value.substring(0, intTamanho);
        alert("O conteúdo de sua mensagem excedeu os " + intTamanho + " caracteres permitidos. Por favor, elabore novamente o conteúdo ");
    }
    else
        strQtdRestante.value = intTamanho - strCampo.value.length;
}
// ------------------------------------------------------------------------------------------ //
// Função   : Formata Campo Moeda
// ------------------------------------------------------------------------------------------ //
function FormataMoeda(campo, tammax, teclapres, decimal) {

    //Verifica se atingiu o tamanho máximo de caracteres
    if (campo.value.length > tammax) {
        alert('Tamanho máximo atingido!');
        return false;
    }
    
    var browser = navigator.appName;
    if (browser == "Netscape") {
        var tecla = teclapres.which;
    } else {
        var tecla = teclapres.keyCode;
    }

    //Se for alguma tecla diferente de número, sair.
    if (tecla < 48 || tecla > 57)
        return false;

    vr = Limpar(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);
        }
    }
}
// ------------------------------------------------------------------------------------------ //
// Função   : Limpar
// ------------------------------------------------------------------------------------------ //
function Limpar(valor, validos) {
    // retira caracteres invalidos da string 
    var result = "";
    var aux;
    for (var i = 0; i < valor.length; i++) {
        aux = validos.indexOf(valor.substring(i, i + 1));
        if (aux >= 0) {
            result += aux;
        }
    }
    return result;
} 
function SetSingleRadioButton(NomeListView, RadioButtonSelecionado) {
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (elm.name.search(NomeListView) > 0) {
                elm.checked = false;
            }
        }
    }
    RadioButtonSelecionado.checked = true;
}

