/*/ihjljikujnyx QW1 `r5ffhy68uj;;.[p''
\

 * Jeditable - jQuery in place edit plugin
 *
 * Copyright (c) 2006-2008 Mika Tuupola, Dylan Verheul
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/jeditable
 *
 * Based on editable by Dylan Verheul <dylan_at_dyve.net>:
 *    http://www.dyve.net/jquery/?editable
 *
 */

/**
  * Version 1.6.2
  *
  * ** means there is basic unit tests for this parameter. 
  *
  * @name  Jeditable
  * @type  jQuery
  * @param String  target             (POST) URL or function to send edited content to **
  * @param Hash    options            additional options 
  * @param String  options[method]    method to use to send edited content (POST or PUT) **
  * @param Function options[callback] Function to run after submitting edited content **
  * @param String  options[name]      POST parameter name of edited content
  * @param String  options[id]        POST parameter name of edited div id
  * @param Hash    options[submitdata] Extra parameters to send when submitting edited content.
  * @param String  options[type]      text, textarea or select (or any 3rd party input type) **
  * @param Integer options[rows]      number of rows if using textarea ** 
  * @param Integer options[cols]      number of columns if using textarea **
  * @param Mixed   options[height]    'auto', 'none' or height in pixels **
  * @param Mixed   options[width]     'auto', 'none' or width in pixels **
  * @param String  options[loadurl]   URL to fetch input content before editing **
  * @param String  options[loadtype]  Request type for load url. Should be GET or POST.
  * @param String  options[loadtext]  Text to display while loading external content.
  * @param Mixed   options[loaddata]  Extra parameters to pass when fetching content before editing.
  * @param Mixed   options[data]      Or content given as paramameter. String or function.**
  * @param String  options[indicator] indicator html to show when saving
  * @param String  options[tooltip]   optional tooltip text via title attribute **
  * @param String  options[event]     jQuery event such as 'click' of 'dblclick' **
  * @param String  options[submit]    submit button value, empty means no button **
  * @param String  options[cancel]    cancel button value, empty means no button **
  * @param String  options[cssclass]  CSS class to apply to input form. 'inherit' to copy from parent. **
  * @param String  options[style]     Style to apply to input form 'inherit' to copy from parent. **
  * @param String  options[select]    true or false, when true text is highlighted ??
  * @param String  options[placeholder] Placeholder text or html to insert when element is empty. **
  * @param String  options[onblur]    'cancel', 'submit', 'ignore' or function ??
  *             
  * @param Function options[onsubmit] function(settings, original) { ... } called before submit
  * @param Function options[onreset]  function(settings, original) { ... } called before reset
  * @param Function options[onerror]  function(settings, original, xhr) { ... } called on error
  *             
  * @param Hash    options[ajaxoptions]  jQuery Ajax options. See docs.jquery.com.
  *             
  */

(function($) {

    $.fn.editable = function(target, options) {
    
        var settings = {
            target     : target,
            name       : 'value',
            id         : 'id',
            type       : 'text',
            width      : 'auto',
            height     : 'auto',
            event      : 'click',
            onblur     : 'cancel',
            loadtype   : 'GET',
            loadtext   : 'Loading...',
            placeholder: 'Click to edit',
            loaddata   : {},
            submitdata : {},
            ajaxoptions: {},
            keys: '',
            token :false,
            datetime: false,
            lockkey :''
        };
        
        if(options) {
            $.extend(settings, options);
        }
    
        /* setup some functions */
        var plugin   = $.editable.types[settings.type].plugin || function() { };
        var submit   = $.editable.types[settings.type].submit || function() { };
        var buttons  = $.editable.types[settings.type].buttons 
                    || $.editable.types['defaults'].buttons;
        var content  = $.editable.types[settings.type].content 
                    || $.editable.types['defaults'].content;
        var element  = $.editable.types[settings.type].element 
                    || $.editable.types['defaults'].element;
        var reset    = $.editable.types[settings.type].reset 
                    || $.editable.types['defaults'].reset;
        var callback = settings.callback || function() { };
        var onsubmit = settings.onsubmit || function() { };
        var onreset  = settings.onreset  || function() { };
        var onerror  = settings.onerror  || reset;
        
        /* add custom event if it does not exist */
        if  (!$.isFunction($(this)[settings.event])) {
            $.fn[settings.event] = function(fn){
                return fn ? this.bind(settings.event, fn) : this.trigger(settings.event);
            }
        }
          
        /* show tooltip */
        $(this).attr('title', settings.tooltip);
        
        settings.autowidth  = 'auto' == settings.width;
        settings.autoheight = 'auto' == settings.height;

        return this.each(function() {
                        
            /* save this to self because this changes when scope changes */
            var self = this;  
           
            /* inlined block elements lose their width and height after first edit */
            /* save them for later use as workaround */
            var savedwidth  = $(self).width();
            var savedheight = $(self).height();
            
            /* if element is empty add something clickable (if requested) */
            if (!$.trim($(this).html())) {
                $(this).html(settings.placeholder);
            }
            
            $(this)[settings.event](function(e) {

                /* prevent throwing an exeption if edit field is clicked again */
                if (self.editing) {
                    return;
                }

                /* remove tooltip */
                $(self).removeAttr('title');
               
                if (0 == $(self).width()) {
                    //$(self).css('visibility', 'hidden');
                    settings.width  = savedwidth;
                    settings.height = savedheight;
                } else {
                    if (settings.width != 'none') {
                        settings.width = 
                            settings.autowidth ? $(self).width()  : settings.width;
                    }
                    if (settings.height != 'none') {
                        settings.height = 
                            settings.autoheight ? $(self).height() : settings.height;
                    }
                }
                //$(this).css('visibility', '');
                
                /* remove placeholder text, replace is here because of IE */
                if ($(this).html().toLowerCase().replace(/;/, '') == 
                    settings.placeholder.toLowerCase().replace(/;/, '')) {
                        $(this).html('');
                }
                                
                self.editing    = true;
                self.revert     = $(self).html();
                
                /* create the form object */
                var form = $('<form />');
                
                /* apply css or style or both */
                if (settings.cssclass) {
                    if ('inherit' == settings.cssclass) {
                        form.attr('class', $(self).attr('class'));
                    } else {
                        form.attr('class', settings.cssclass);
                    }
                }

                if (settings.style)
                {
                    if ('inherit' == settings.style) {
                        form.attr('style', $(self).attr('style'));
                        /* IE needs the second line or display wont be inherited */
                        form.css('display', $(self).css('display'));                
                    } else {
                        form.attr('style', settings.style);
                    }
                }
                
                form.css('width','100%');
                
                var count = 0;
                if(settings.token)
                {   
                    
                    var input = $('<input />');
                    if (settings.width  != 'none') { input.width(settings.width);  }
                    if (settings.height != 'none') { input.height(settings.height -4); }
                    input.css('border','0px solid #3366FF');
                    input.css('background-color','#ffeeee');
                    input.css('text-align','left');
                    input.css('padding-left','5px');
                    input.css('padding-top','2px');
                    input.css('font-size','12px');
                    input.css('font-family','Arial');
                    input.css('float','left');
    
                    //input[0].5setAttribute('autocomplete','off');
                    input.attr('autocomplete','off');
                    var width =  settings.width ;
                    
                    input.val($(self).find('span:eq(0)').html());
                    
                    //width = 150 ;
                    $(self).html('') ;
                    
                    $(self).append(input) ;   
                    
                    var ten = input.val();
                    
                    //---------Token ----------------------------------------
                    input.tokenInput("Business/XuatNhap/Xuly/searchToken.aspx", {
                        hintText: "Tim kiem theo ten ",
                        noResultsText: "khong co ket qua",
                        searchingText: "Tim kiem...",
                        width:0,
                        value:input.val(),
                        focus: true,
                        onkeyup: function(e)
                        {
                            
                            if($(self).attr('className') != 'focus')
                            {
                                $(self).addClass('focus');
                            };
                            if(e.keyCode == 27 || e.keyCode == 9){
                                e.preventDefault();
                                $(self).html(self.revert);   
                                self.editing   = false;
                                settings.keys.block = false;
                                $(self).attr('title', settings.tooltip);
                                return ;
                            }
                            else if(e.keyCode == 32)
                            {   
                                e.preventDefault();   
                                var ma = input.attr('ma');    
                                
                                if(ma != null)
                                {
                                    if(ma == '')
                                    {
                                        alert('Sản phẩm không hợp lệ');
                                        if(self.editing)
                                        {       
                                            self.editing   = false;
                                            $(self).html(self.revert);   
                                            $(self).attr('title', settings.tooltip);
                                        }
                                        settings.keys.block = false;
                                        return ;
                                        
                                    }
                                    else 
                                    {
                                        $(self).html(self.revert);
                                        $(self).find('span:eq(0)').html(input.val());
                                       
                                        //------------Loading --------------------
                                        $(self).parent().find('td:eq(1)').html('Loading');
                                        $(self).parent().find('td:eq(2)').html('Loading');
                                        $(self).parent().find('td:eq(3)').html('Loading');
                                        $(self).parent().find('td:eq(4)').html('Loading');
                                        $(self).parent().find('td:eq(5)').html('Loading');
                                        $(self).parent().find('td:eq(6)').html('Loading');
                                        $(self).parent().find('td:eq(6)').html('Loading');
                                        $(self).parent().find('td:eq(7)').html('Loading');
                                        $(self).parent().find('td:eq(8)').html('Loading');
                                        $(self).parent().find('td:eq(9)').html('Loading');
                                        
                                        
                                        jQuery.ajax({
                                            url:'Business/XuatNhap/Xuly/Select.aspx',
                                            data:{q:5,id:ma},
                                            type:'POST',
                                            
                                            success: function(data)
                                            {
                                                var str ="{\"HH\":[" + data + "]}";
                                                var myObject = eval('(' + str + ')');
                                              
                                                
                                                $(self).parent().find('td:eq(1)').html(myObject.HH[0].HH_Tiente);
                                                $(self).parent().find('td:eq(2)').html(convert(myObject.HH[0].HH_GiaBan.toString()));
                                                $(self).parent().find('td:eq(3)').html("0");
                                                $(self).parent().find('td:eq(4)').html("0");
                                                $(self).parent().find('td:eq(5)').html(convert(myObject.HH[0].HH_ChietKhau.toString()));
                                                $(self).parent().find('td:eq(6)').html("0");
                                                $(self).parent().find('td:eq(7)').html("10/20/2009");
                                                $(self).parent().find('td:eq(8)').html("Ghi chu");
                                                
                                                self.editing   = false;
                                                settings.keys.block = false;
                                                $(self).attr('title', settings.tooltip);
                                                tinhtien();
                                                    
                                            },
                                            
                                            error: function()
                                            {
                                                alert(data);
                                                jQuery(".ui-dialog").unblock(); 
                                            }
                                                       
                                        }); 
                                              
                                    }
                                }
                                else 
                                {
                                    if(ten == input.val())
                                    {
                                        e.preventDefault();
                                        if(self.editing)
                                        {       
                                            self.editing   = false;
                                            $(self).html(self.revert);   
                                            $(self).attr('title', settings.tooltip);
                                        }
                                        settings.keys.block = false;
                                        return ;
                                    }
                                    else 
                                    {
                                      
                                        if(self.editing)
                                        {       
                                            self.editing   = false;
                                            $(self).html(self.revert);   
                                            $(self).attr('title', settings.tooltip);
                                        }
                                        settings.keys.block = false;
                                        return ;
                                    }
                                    
                                }
                               
                            }
                                                   
                        },
                        onblur : function() 
                        {
                            $(self).html(self.revert);
                            self.editing   = false;
                            settings.keys.block = false;
                            $(self).attr('title', settings.tooltip);
                        }
                        
                    }); 
                    
                    input.setFocus() ;  
                    
                    
                    
                    return ;
                }
                else if(settings.datetime)
                {
                    var input = $('<input />');
                    if (settings.width  != 'none') { input.width(settings.width);  }
                    if (settings.height != 'none') { input.height(settings.height -4); }
                    input.css('border','0px solid #3366FF');
                    input.css('background-color','#ffeeee');
                    input.css('text-align','left');
                    input.css('padding-left','5px');
                    input.css('padding-top','2px');
                    input.css('font-size','12px');
                    input.css('font-family','Arial');
                    input.css('float','left');
    
                    //input[0].setAttribute('autocomplete','off');
                    input.attr('autocomplete','off');
                    var width =  settings.width ;
                    
                    input.val($(self).html());
                    
                    //width = 150 ;
                    $(self).html('') ;
                    
                    $(self).append(input)
                    
                    var date = input.val();
                    
                    input.dateinput({
                        value:date,
                        onkeydown: function(e)
                        {
                            
                            if($(self).attr('className') != 'focus')
                            {
                                $(self).addClass('focus');
                            };
                            if(e.keyCode == 27 || e.keyCode == 9){
                                e.preventDefault();
                                $(self).html(self.revert);   
                                self.editing   = false;
                                settings.keys.block = false;
                                $(self).attr('title', settings.tooltip);
                                return ;
                            }
                            else if(e.keyCode == 32)
                            {   
                                e.preventDefault();   
                                var ma = input.attr('ma'); 
                                $(self).html(input.val());
                                self.editing   = false;
                                settings.keys.block = false;
                                $(self).attr('title', settings.tooltip);
                                return ;
                            }                    
                       
                        }
                    });
                    
                    input.setFocus();
                    
                    return false ;
                    
                }
                
                $(self).html('');

               

                /* add main input element to form and store it in input */
                var input = element.apply(form, [settings,self]);
                input.css('border','solid; 0px; black;');
                /* set input content via POST, GET, given data or existing value */
                var input_content;
                
                if (settings.loadurl) {
                    var t = setTimeout(function() {
                        input.disabled = true;
                        content.apply(form, [settings.loadtext, settings, self]);
                    }, 100);

                    var loaddata = {};
                    loaddata[settings.id] = self.id;
                    if ($.isFunction(settings.loaddata)) {
                        $.extend(loaddata, settings.loaddata.apply(self, [self.revert, settings]));
                    } else {
                        $.extend(loaddata, settings.loaddata);
                    }
                    $.ajax({
                       type : settings.loadtype,
                       url  : settings.loadurl,
                       data : loaddata,
                       async : false,
                       success: function(result) {
                          window.clearTimeout(t);
                          input_content = result;
                          input.disabled = false;
                       }
                    });
                } else if (settings.data) {
                    input_content = settings.data;
                    if ($.isFunction(settings.data)) {
                        input_content = settings.data.apply(self, [self.revert, settings]);
                    }
                } else {
                    input_content = self.revert; 
                }
                content.apply(form, [input_content, settings, self]);

                input.attr('name',settings.name);
                
                
                /* add buttons to the form */
                buttons.apply(form, [settings, self]);
         
                /* add created form to self */
                $(self).append(form);
         
                /* attach 3rd party plugin if requested */
                plugin.apply(form, [settings, self]);

                /* focus to first visible form element */
                $(':input:visible:enabled:first', form).focus();

                /* highlight input contents when requested */
                if (settings.select) {
                    input.select();
                }
                settings.keys.block = true;
                var val_oringal ="";
                /* discard changes if pressing esc */
                input.keydown(function(e) {
                    if($(self).attr('className') != 'focus')
                    {
                        $(self).addClass('focus');
                    };
                    var key = e.charCode || e.keyCode || 0;
                   // alert(key);
                    if(e.keyCode == 27 || e.keyCode == 9){
                        e.preventDefault();
                        //self.reset();
                        reset.apply(form, [settings, self]);   
                    }
                    
                    return ((key >= 48 && key <= 57)||(key == 8)||(key == 13|| e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40)||(key == 190));
                });
                
                input.keyup(function(e){
                     
                    if(e.keyCode != 13)
                    {
                        val_oringal = input.val();
                        val_oringal = reconvert(val_oringal) ;
                       
                        //alert(val_oringal+":"+convert(val_oringal));
                        input.attr('value',convert(val_oringal));
                        
                        
                    }
                   
                
                });

                /* discard, submit or nothing with changes when clicking outside */
                /* do nothing is usable when navigating with tab */
                var t;
                if ('cancel' == settings.onblur) {
                    input.blur(function(e) {
                        /* prevent canceling if submit was clicked */
                        t = setTimeout(function() {
                            reset.apply(form, [settings, self]);
                        }, 500);
                    });
                } else if ('submit' == settings.onblur) {
                    input.blur(function(e) {
                        /* prevent double submit if submit was clicked */
                        t = setTimeout(function() {
                            form.submit();
                        }, 200);
                    });
                } else if ($.isFunction(settings.onblur)) {
                    input.blur(function(e) {
                        settings.onblur. apply(self, [input.val(), settings]);
                    });
                } else {
                    input.blur(function(e) {
                      /* TODO: maybe something here */
                    });
                }

                form.submit(function(e) {

                    if (t) { 
                        clearTimeout(t);
                    }

                    /* do no submit */
                    e.preventDefault(); 
            
                    /* call before submit hook. */
                    /* if it returns false abort submitting */                    
                    if (false !== onsubmit.apply(form, [settings, self])) { 
                        /* custom inputs call before submit hook. */
                        /* if it returns false abort submitting */
                        //settings.key.block = false;
                        if (false !== submit.apply(form, [settings, self])) { 

                          /* check if given target is function */
                          if ($.isFunction(settings.target)) {
                              var str = settings.target.apply(self, [input.val(), settings]);
                              $(self).html(str);
                              self.editing = false;
                              callback.apply(self, [self.innerHTML, settings]);
                             
                              /* TODO: this is not dry */                              
                              if (!$.trim($(self).html())) {
                                  $(self).html(settings.placeholder);
                              }
                              
                              
                           
                                  //var taisao ='tai sao';
                                  //settings.key(taisao) ;  
                              
                          } else {
                              /* add edited content and id of edited element to POST */
                              var submitdata = {};
                              submitdata[settings.name] = input.val();
                              submitdata[settings.id] = self.id;
                              /* add extra data to be POST:ed */
                              if ($.isFunction(settings.submitdata)) {
                                  $.extend(submitdata, settings.submitdata.apply(self, [self.revert, settings]));
                              } else {
                                  $.extend(submitdata, settings.submitdata);
                              }

                              /* quick and dirty PUT support */
                              if ('PUT' == settings.method) {
                                  submitdata['_method'] = 'put';
                              }

                              /* show the saving indicator */
                              $(self).html(settings.indicator);
                              
                              /* defaults for ajaxoptions */
                              var ajaxoptions = {
                                  type    : 'POST',
                                  data    : submitdata,
                                  url     : settings.target,
                                  success : function(result, status) {
                                      $(self).html(result);
                                      self.editing = false;
                                      callback.apply(self, [self.innerHTML, settings]);
                                      
                                      if (!$.trim($(self).html())) {
                                          $(self).html(settings.placeholder);
                                      }
                                      
                                         
                                  },
                                  
                                  error   : function(xhr, status, error) {
                                      onerror.apply(form, [settings, self, xhr]);
                                  }
                              }
                              
                              /* override with what is given in settings.ajaxoptions */
                              $.extend(ajaxoptions, settings.ajaxoptions);   
                              $.ajax(ajaxoptions);          
                              
                            }
                        }
                    }
                    
                    /* show tooltip again */
                    $(self).attr('title', settings.tooltip);
                    settings.keys.block = false;
                    tinhtoan($(self).parent());
                    return false;
                });
            });
            
            
            /* privileged methods */
            this.reset = function(form) {
                /* prevent calling reset twice when blurring */
                if (this.editing) {
                    /* before reset hook, if it returns false abort reseting */
                    if (false !== onreset.apply(form, [settings, self])) { 
                        $(self).html(self.revert);
                        self.editing   = false;
                        
                        if (!$.trim($(self).html())) {
                            $(self).html(settings.placeholder);
                        }
                        /* show tooltip again */
                        $(self).attr('title', settings.tooltip);                
                    }                    
                }
            }            
        });

    };


    $.editable = {
        types: {
            defaults: {
                element : function(settings, original) {
                    var input = $('<input type="hidden"></input>');                
                    $(this).append(input);
                    return(input);
                },
                content : function(string, settings, original) {
                    $(':input:first', this).val(string);
                },
                reset : function(settings, original) {
                  original.reset(this);
                },
                buttons : function(settings, original) {
                    var form = this;
                    if (settings.submit) {
                        /* if given html string use that */
                        if (settings.submit.match(/>$/)) {
                            var submit = $(settings.submit).click(function() {
                                if (submit.attr("type") != "submit") {
                                    form.submit();
                                }
                            });
                        /* otherwise use button with given string as text */
                        } else {
                            var submit = $('<button type="submit" />');
                            submit.html(settings.submit);                            
                        }
                        $(this).append(submit);
                    }
                    if (settings.cancel) {
                        /* if given html string use that */
                        if (settings.cancel.match(/>$/)) {
                            var cancel = $(settings.cancel);
                        /* otherwise use button with given string as text */
                        } else {
                            var cancel = $('<button type="cancel" />');
                            cancel.html(settings.cancel);
                        }
                        $(this).append(cancel);

                        $(cancel).click(function(event) {
                            //original.reset();
                            if ($.isFunction($.editable.types[settings.type].reset)) {
                                var reset = $.editable.types[settings.type].reset;                                                                
                            } else {
                                var reset = $.editable.types['defaults'].reset;                                
                            }
                            reset.apply(form, [settings, original]);
                            return false;
                        });
                    }
                }
            },
            text: {
                element : function(settings, original) {
                    var input = $('<input />');
                    if (settings.width  != 'none') { input.width(settings.width);  }
                    if (settings.height != 'none') { input.height(settings.height-2) ; }
                    input.css('border','none');
                    input.css('background-color','#ffeeee');
                    input.css('text-align','center');
                    input.css('font-size','12px');
                    input.css('font-family','Arial');
    

                    //input[0].setAttribute('autocomplete','off');
                    input.attr('autocomplete','off');
                    $(this).append(input);
                    return(input);
                }
            },
            
            token: {
                element : function(settings, original) {
                    var input = $('<input />');
                    if (settings.width  != 'none') { input.width(settings.width - 20);  }
                    if (settings.height != 'none') { input.height(settings.height); }
                    input.css('border','1px solid #3366FF');
                    input.css('background-color','#ffeeee');
                    input.css('text-align','left');
                    input.css('padding-left','5px');
                    input.css('font-size','12px');
                    input.css('font-family','Arial');
    

                    //input[0].setAttribute('autocomplete','off');
                    input.attr('autocomplete','off');
                    //$(this).append(input);
                    return(input);
                }
            },
            
            textarea: {
                element : function(settings, original) {
                    var textarea = $('<textarea />');
                    if (settings.rows) {
                        textarea.attr('rows', settings.rows);
                    } else {
                        textarea.height(settings.height);
                    }
                    if (settings.cols) {
                        textarea.attr('cols', settings.cols);
                    } else {
                        textarea.width(settings.width);
                    }
                    $(this).append(textarea);
                    return(textarea);
                }
            },
            select: {
               element : function(settings, original) {
                    var select = $('<select />');
                    $(this).append(select);
                    return(select);
                },
                content : function(string, settings, original) {
                    if (String == string.constructor) {      
                        eval ('var json = ' + string);
                        for (var key in json) {
                            if (!json.hasOwnProperty(key)) {
                                continue;
                            }
                            if ('selected' == key) {
                                continue;
                            } 
                            var option = $('<option />').val(key).append(json[key]);
                            $('select', this).append(option);    
                        }
                    }
                    /* Loop option again to set selected. IE needed this... */ 
                    $('select', this).children().each(function() {
                        if ($(this).val() == json['selected'] || 
                            $(this).text() == original.revert) {
                                $(this).attr('selected', 'selected');
                        };
                    });
                }
            }
        },

        /* Add new input type */
        addInputType: function(name, input) {
            $.editable.types[name] = input;
        }
    };

})(jQuery);

//---------tinh toan -----------------------------------------------
    function tinhtoan(obj)
    {
          var sl,gia,total,ck,totalck, t_re, t_tien,t_ck ;
          var $cellsl = obj.find('td:eq(4)') ;
          // alert($cellsl.html());
          var $cellgia = obj.find('td:eq(3)') ;
          var $celltotal = obj.find('td:eq(5)') ;
          var $cellck = obj.find('td:eq(6)') ;
          var $celltotalck = obj.find('td:eq(7)') ;
          //var $tbl1 = obj.('table:first') ;
          //var $tbl2 = $tbl1.parent().next().find('table') ;
          //alert($tbl2.html());
                             
          
          sl =  parseFloat(reconvert($cellsl.html()));
          gia =  parseFloat(reconvert($cellgia.html()));
          total =  parseFloat(reconvert($celltotal.html()));
          ck =  parseFloat(reconvert($cellck.html()));
          totalck =  reconvert($celltotalck.html());   
          
          
          total = sl*gia ;
          totalck = ck*total/100 ;
          
          
          $celltotal.html(convert(total.toString()));
          $celltotalck.html(convert(totalck.toString()));
          
          tinhtien(); 
    
    }