
var ToggleRadio = Class.create();

ToggleRadio.prototype = {
  
  initialize:    function (ids) {
              			this.ids = ids;
										for (var a = 0 ; a < this.ids.length ; a++)
			                Event.observe ($(this.ids[a][0]), 'click', this.actua.bindAsEventListener (this), true);
										this.actua ();
            },
            
  actua:      function (e) {
			              for (var a = 0 ; a < this.ids.length ; a++)
			              {
			                if ($ (this.ids [a][0]).checked === true) {
			                  if( $(this.ids[a][1]))
			                    $(this.ids[a][1]).style.display = 'block';
			                } else {
			                  if( $(this.ids[a][1]))
			                   $(this.ids[a][1]).style.display = 'none';
			                }											 
			              }
			             
            }
};

var ToggleSelect = Class.create();

ToggleSelect.prototype = {
  
  initialize: function (id_select, options) {
                this.id_select = id_select;
                this._options = options;
                Event.observe (this.id_select, 'change', this.actua.bindAsEventListener (this), true);
                this.actua ();
            },

  actua:      function (e) {
              var seleccionada = $F(this.id_select);
              var open_divs = new Array();
              for (var a = 0 ; a < this._options.length ; a++)
              {
                if( this._options[a][0] == seleccionada)
                  open_divs.push( this._options[a][1]);
                // style = this._options[a][0] == seleccionada ? 'block' : 'none';
                if( open_divs.in_array( this._options[a][1]))
                  style = 'block';
                else
                  style = 'none';
                if ($(this._options[a][1]))
                  $(this._options[a][1]).style.display = style;  
              }
            }
};

Array.prototype.in_array=function(){
    for(var j in this){
        if(this[j]==arguments[0]){
            return true;
        }
    }
    return false;    
}

var ToggleCheckBox = Class.create();

ToggleCheckBox.prototype = {
  
  initialize:   function (ids) {
             		this.input = ids[0];
              	this.div = ids[1];
								
								if (typeof this.input == 'string')
									this.input = [this.input];
								for (var i = 0 ; i < this.input.length ; i++)
								{
									Event.observe ($(this.input [i]), 'click', this.actua.bindAsEventListener (this), true);
								}
								this.actua ();
            },
            
  actua:      	function (e) {
								var checked = false;
								for (var i = 0 ; i < this.input.length ; i++)
										if ($(this.input [i]).checked == true)
											checked = true;
              	if (checked)
                	$(this.div).style.display = 'block';
              	else
                	$(this.div).style.display = 'none';
            }
};