﻿function SelecionaTodos(SelecionaTodos,Tabela,CheckboxID) {
    var TBID = "#" + Tabela;
    var CHID = "#" + CheckboxID;
    var CHTODOS = "#" + SelecionaTodos;
    
    if ($(CHTODOS).attr("checked") == true) {
        $(TBID).find(CHID).each(function() {
            $(this).attr("checked", "checked");
        });
    } else {
        $(TBID).find(CHID).each(function() {
            $(this).attr("checked", "");
        });
    }
}

function FormataMoeda(valor) {
    var teste = valor.toString();
    /*if (teste.indexOf(".") == -1) {
        teste = teste + ".00";
    }
    if (teste.indexOf(".") == 1) {
        teste = teste + "0";
    }
    if (teste.charAt(teste.length - 2) == ".") {
        teste = teste + "0";
    }*/
    teste = teste.replace('.', ',');
    return teste;
}

function SelecionaCHByLinha(Celula, CelulaCheckbox) {
    //alert(Celula+"\n"+CelulaCheckbox);
    IDlinha  = "#" + ($(Celula).parent().attr("id"));
    CLCelula = "." + CelulaCheckbox;    
    if ($(IDlinha).find(CLCelula).attr("checked") == false) {
        $(IDlinha).find(CLCelula).attr("checked", "checked");
    } else {
        $(IDlinha).find(CLCelula).attr("checked", "");
    }
}

function ClickMudaCorTextbox(STRCampos) {    
    $(STRCampos).focus(function() {
        $(this).css("backgroundColor", "#FFFFFF");
    });
    $(STRCampos).blur(function() {
        $(this).css("backgroundColor", "#eeeeee");
    });
}



