function bt_check() {
    $(".button-switch").each(function() {
        if ($(this).children("input").is("input")) {
            g_status = $(this).children("input").first().val();

            if (g_status == "0") {
                $(this).removeClass("active");
                $(this).next().slideUp();
            }
            else {
                $(this).addClass("active");
                $(this).next().slideDown();
            }
        }
    });
}

function bt_eventbind(selector) {
    $(selector).live('click', function() {
      if ($(this).children("input").is("input")) {
            g_status = $(this).children("input").first().val();
            
            if (g_status == "1") g_status = "0"; else g_status = "1";
            $(this).children("input").val(g_status);
            
            if (g_status == "0") {
                $(this).removeClass("active");
                $(this).next().slideUp();
            }
            else {
                $(this).addClass("active");
                $(this).next().slideDown();
            }
        }
        else {
            $(this).next("div").slideToggle();
            $(this).toggleClass("active");
        }
    });
}

function bt_init(selector) {
    bt_check();
    bt_eventbind(selector);
}
