
function ormtable_addRow(tableId)
{
        var url = (contextRoot != null ? contextRoot : "../..") + "/extensions/standard/ormtable/ormtable_newrow_Get.jsp";
        
        ajaxProcessAddJQ (url, '#ormTable-' + tableId + ">tbody", { tableId : tableId }, function (theHTML_JQ) {
            $('#ormTable-' + tableId + ">tbody").append (theHTML_JQ);
            updateListSortOrder(tableId);
        });
        
	return false;
}


var updateListSortOrder = function(tableId)
{
        var $Rows = $("#ormTable-" + tableId + ">tbody>*");
        
        $Rows.each(function(index){
            $(this).find("td.sortHandle>input[type=hidden]").val(index+1);
        });
        
        return true;
};


function ormtable_enableSort(tableId)
{
        var $ListingTable = $('#ormTable-'+tableId);

        $("tbody",$ListingTable).sortable({
            handle: "td.sortHandle",
            cursor: 'move',
            update: function(e, ui) {
                updateListSortOrder(tableId);}
        });
}

function ormtable_deleteRow(deleteAjaxJSPPath,sVarKey,tableId)
{
    ajaxProcessDeleteJQ (deleteAjaxJSPPath, "#"+tableId+">tbody", { varKey: sVarKey });
    return false;
}