/*******************************************************************************
 *
 * class UI.Accordion
 *
 ******************************************************************************/


Accordion.rb.prototype = new Control();
Accordion.prototype.constructor = Accordion;

function Accordion( jquery_element ) {
  Control.call( this, jquery_element );
}

UI.Accordion = Accordion;

Accordion.add = function( properties ) {
  // Build DOM objects.
  var $control = $('<label/>');
  $control.addClass('control control-toggle');
  var $label = $('<span/>');
  var $type = $('<div/>');
  var $checkbox = $('<input type="checkbox" checked/>');
  $checkbox.appendTo( $control );
  
  $type.addClass('slider_toggle round');
  $type.appendTo( $control );
  
  $label.addClass('label_tonge');
  $label.appendTo( $control );
  // Initialize wrapper.
  var control = new Accordion( $control );
  control.update( properties );
  // Set up events.
  UI.add_event( 'change', $control, $checkbox );
  // Attach to document.
  control.attach();
  return control;
}

Accordion.prototype.set_checked = function( value ) {
  $checkbox = this.control.children('input');
  $checkbox.prop( 'checked', value );
  return value;
};

Accordion.prototype.set_label = function( value ) {
  $label = this.control.children('span');
  $label.text( value );
  return value;
};

Accordion.prototype.set_tab_index = function( value ) {
  $checkbox = this.control.children('input');
  $checkbox.attr( 'tabIndex', value );
  return value;
};
