Click logic -- swap icons w/jQuery
<p>I have two buttons that show/hide areas below. By default both buttons have the following icons: "ui-icon-triangle-1-e</p>

<p>When a button is clicked I want to changed the icon of the clicked button to: "ui-icon-triangle-1-s, and show appropriate section below while hiding the other if it was open.</p>

<p>I can't seem to be able to get the logic right, when I expand one section and then click another button. The areas swap properly, but the button icons do not update...</p>

<p>Need more eyes to look and tell me what am I missing.</p>

<pre><code>$(".features").bind("click", function () {
    var that = this,
        pid  = $(this).attr("id"),
        pidC = pid + "C",
        index = $(this).closest("td").index();

    $(".features").find("span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
    $(that).find("span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");

    // indicator OFF for all
    $(".ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
    $("#prT").find("td").removeClass("txtCCC");

    $.each($("#prT").find("tr").children(), function () {
        if ($(that).index() != index) {
            $(that).addClass("txtCCC");
        }
    });

    if ($(".fList").hasClass("current")) {
        $(".fList:visible").slideUp().removeClass("current");

        if ($(".fList:visible").attr("id") != pidC) {
            $("#" + pidC).slideDown(function(){
            }).addClass("current"); 
        }           
    } else {        
        $("#" + pidC).slideDown(function(){
            $(".ui-icon-triangle-1-e", that).removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
        }).addClass("current");

    }
});
</code></pre>
