var WREvent = {
  e: null,
  page : null,
  link: null,
  otherOptions: null,
  
  observe: function (event){    
    options = $A(arguments);
    e = options[0];
    page = options[1];
    link = options[2];    
    otherOptions = options[3];
    
      WREvent.timeout();
    
  },
  timeout: function(){
      clearTimeout(Event.element(e).timer);
      Event.element(e).timer = setTimeout('WREvent.doEvent()' ,400);     
  },
                
  doEvent: function (){
    ajaxRequest(page + 'FormBean', $H({'sourcePage': page, 'isForm': true, 'pressedLink' : 'button#' + link}).merge(otherOptions))
  }
  
  }

function RadioRequest(page,link,field,lastValue,otherOptions){
	ajaxRequest(page + 'FormBean', $H({'sourcePage': page, 'isForm': true, 'pressedLink' : 'button#' + link}).merge(otherOptions))
}

function CheckboxRequest(page,link,field,lastValue,otherOptions){
    ajaxRequest(page + 'FormBean', $H({'sourcePage': page, 'isForm': true, 'pressedLink' : 'button#' + link}).merge(otherOptions))
}

Form.Element.RadioEventObserver = Class.create(Abstract.EventObserver,{
   initialize: function(form, name, callback) {
    this.elements = Form.getInputs(form, 'radio', name);
    this.callback = callback;
    for (var i = 0; i < this.elements.length; i++) {
      this.registerCallback(this.elements[i]);
    }
  },
  
  onElementEvent: function(event) {
    var element = Event.element(event);

   	this.callback(element, Form.Element.getValue(element)); 
  }
});


Form.Element.CheckboxEventObserver = Class.create(Abstract.EventObserver,{
  
  initialize: function(form, name, callback) {
  	this.elements = Form.getInputs(form, 'checkbox', name);
    this.callback = callback;
	for (var i = 0; i < this.elements.length; i++) {
      this.registerCallback(this.elements[i]);
    }
  },
  
  onElementEvent: function(event) {
   var element = Event.element(event);

   this.callback(element, Form.Element.getValue(element)); 
  }
  
});