Slow response in flexigrid checkbox.

Slow response in flexigrid checkbox.

function checkAccess(celDiv,id)
{
   var celValue = $(celDiv).html();
   
   if (celValue==1) $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' checked disabled>")//display detFlex1
   else $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' disabled>")//convert value of checkbox to 0/1   

   $(celDiv).click
   (
       function()
      {
         $('input',this).each(
             function(){

               tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent());   
               td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
               td_last = 13;
            for(var td=td_idx+1; td<=td_last;td++)
            {
               if ($(this).attr('checked') == true)
               {
                        df[0].rows[tr_idx].cell[td_idx] = 1;//index[1] = Full Access
                  if (td_idx==3)
                     {
                        df[0].rows[tr_idx].cell[td] = 1;
                     }      
                     df[0].rows[tr_idx].cell[2] = 1;
                  if (td_idx > 3)
                     {
                        df[0].rows[tr_idx].cell[2] = 1;
                     }                  
               }
               else
               {         
                        df[0].rows[tr_idx].cell[td_idx] = 0;//index[0] = With Access
                  if (td_idx==2 )
                     {
                        df[0].rows[tr_idx].cell[td] = 0;
                     }
                  
                  if (td_idx > 3)
                     {
                        df[0].rows[tr_idx].cell[3] = 0;
                     }
               }
            }
               $('#detFlex1').flexAddData(df[0]);
               $('.toolbar a[title=Edit Item]').trigger('click');
             });   
      }
   );
}


Im trying to optimize a website and im stuck with this code. The problem is when i check/uncheck a checkbox it took 5-6 sec just by clicking. Can anyone help me to rewrite a code similar to this one? or point me out why its like this?
this is how it looks like:
Image[/img][/code]