//<script type="text/javascript">
    //<![CDATA[
$(document).ready(function()
{
    $.tablesorter.addParser({
        id: 'classimage',
        is: function(s)
        {
            return false;
        },
        type: 'text',
        format: function(s)
        {
            //alert(s);
            var matchs = s.match(/\/images\/class\/(.*?)"/);
            return matchs[1];
        }

    });

    $("#pointsTable").tablesorter({
        sortList: [[0,0]],
        //sortForce: [[0,0]],
        cssAsc: "headerUp ui-state-active",
        cssDesc: "headerDown ui-state-active",
        cssHeader: "headerUpDown",
        textExtraction: function(node) {
            // extract data from markup and return it
            if (node.childNodes[1] && node.childNodes[1].innerHTML)
                return node.childNodes[1].innerHTML;
            else
                return node.innerHTML;
        }
    });

    $("#pointsTable").bind(
        "sortStart",
        function()
        {
            $(".pointsdata").remove();
            $('#pointsTable').removeData('content_old');
            $("#"+pointsTable_content_show+"").children().removeClass('ui-state-active');
            $("#"+pointsTable_content_show+"").children().addClass('ui-widget-content');
        });

    $("#pointsTable").bind(
        "sortEnd",
        function()
        {
            $(".headerUpDown > span").removeClass("ui-icon-triangle-2-n-s").addClass("ui-icon-triangle-2-n-s");
            $(".headerUp > span").addClass("ui-icon-triangle-1-n").removeClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-2-n-s");
            $(".headerDown > span").addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-n").removeClass("ui-icon-triangle-2-n-s");
        });
        
    var pointsTable_content_show;
    $("#pointsTable tr").click(
        function()
        {
            if (pointsTable_content_show != $(this).attr("id"))
            {
                pointsTable_content_show = $(this).attr("id");
                $.ajax({
                    method: "get",
                    url: "/raidpoints/ajax/points",
                    data: "p="+pointsTable_content_show.replace("points", "")+"&r=1",
                    beforeSend: function()
                    {
                        $("#"+pointsTable_content_show+"").after('<tr id="ajaxContainerTr"><td class="ui-widget-content" colspan="8" id="ajaxContainerTd"></td></tr>');
                        $('#ajaxLoader').appendTo("#ajaxContainerTd").css({
                            position: "relative",
                            top: "0px",
                            left: "0px"
                        });
                        $("#ajaxContainerTr").hide();
                        $("#ajaxContainerTr").fadeIn("fast");
                    },
                    success: function(html)
                    { //so, if data is retrieved, store it in html
                        $(".pointsdata").remove();

                        if($('#pointsTable').data('content_old') == pointsTable_content_show)
                        {
                            $('#pointsTable').removeData('content_old');
                        }
                        else
                        {
                            $('#pointsTable').data('content_old', pointsTable_content_show);
                            $('#pointsTable').data('content', $("."+pointsTable_content_show+"").html());
                        }
                        $("#ajaxContainerTr").slideUp("fast", function () { $("#ajaxContainerTr").remove(); });
                        $("#ajaxLoader").appendTo("body").css({
                            position: "relative",
                            top: "0px",
                            left: "0px"
                        });

                        //$("#"+pointsTable_content_show+"").hide(); //animation
                        $("#"+pointsTable_content_show+"").after(html); //show the html inside .content div
                        docReady('#tabsAjax');
                        setupLinks(".pointsdata");
                        $("#"+pointsTable_content_show+"").children().addClass('ui-state-active').removeClass('ui-widget-content');
                        $(".pointsdata").hide();
                        $(".pointsslide").hide();
                        $(".pointsdata").show();

                        //$("#"+pointsTable_content_show+"").fadeIn("slow", function() { $("#filterDialog").dialog('option', 'position', [left,top]); } ); //animation
                        $(".pointsslide").slideDown("slow", function() {
                            //$('#tabs3 > div').equalHeights();
                        } );
                    }
                }); //close $.ajax(
            }
            $('#pointsTable tbody > tr').children().removeClass('ui-state-active').addClass('ui-widget-content');
            if ($(".pointsslide").is(":visible"))
            {
                $(".pointsslide").slideUp("fast", pointsTablePartTwo)
            }
            else if (pointsTable_content_show == $(this).attr("id"))
            {
                $(".pointsdata").show();
                $(".pointsslide").slideDown("slow", pointsTablePartTwo)
                $("#"+pointsTable_content_show+"").children().addClass('ui-state-active').removeClass('ui-widget-content');
            }
        }
        );

    function pointsTablePartTwo()
    {
        if (!$(".pointsslide").is(":visible"))
        {
            $(".pointsdata").hide();
        }
    }
});
    //]]>
//</script>
