component['frgCard'] = Class.create({

  THREAD_ID: null,
  EXEC_UID: null,
  arrParams:  null,
  
  intQuan: 0,

  initialize: function(arrInstVars, arrParams, arrLang)
  {
    this.THREAD_ID    = arrInstVars.THREAD_ID;
    this.EXEC_UID     = arrInstVars.EXEC_UID;
    
    $$('div.row input[type="checkbox"]').each(function(el)
    {
    	el.observe('click', this._update.bind(this));
    
    	if(el.checked)
    	  this.intQuan++;
    }.bind(this))
    
    if($('quan'))
    {
      //$('quan').update(this.intQuan);
    }  
	//alert($$('div.row input[type="checkbox"]'));
  },
  
  _update: function(evt)
  {
    var intAllQuan = $('quan') ? parseInt($('quan').innerHTML) : 0;
    intAllQuan = intAllQuan - this.intQuan;
    this.intQuan = 0;
    $$('div.row input[type="checkbox"]').each(function(el)
    {
    	if(el.checked)
    	  this.intQuan++;
    }.bind(this));
    
    if($('quan'))
    {
      $('quan').update(this.intQuan+intAllQuan);
    }
    
    var elRow = evt.element().up('div[_id]');
    
    if(!elRow.getAttribute('_id'))
    {
      return;
    }
    
	new Ajax.Request('/?call_element=component.frgCard',
	{
		parameters: 
		{	
			id: elRow.getAttribute('_id'),
			type: $F('type'),
			isChecked: (evt.element().checked ? 1 : 0)
		}
	});    
  }
  
});
arrJsLoaded['component.frgCard.js']=true;init.jsLoaded("component.frgCard.js");
