// Extension to Prototype's Form object

Object.extend(Form.Methods, {

  // Focuses the first non-empty element of a form
  focusFirstBlankElement: function(form) {
    form = $(form);
    var focussed = false;
    form.getElements().each(function(element) {
      if (!focussed && !element.value && !element.disabled) {
        focussed = true;
        element.focus();
      }
    });
  },
	//updates form elements with values in form_data
	//to do , update checkbox, update radio , update select boxes
	update : function (form_id,form_data) {
		if ($(form_id)){
			 $(form_id).reset();
			 
			 $(form_id).getElements().each(function (f){
					var keys =$H(form_data).keys();
					if(keys.include(f.id)){
						f.value = form_data[f.id];
					}
			 });
		}
	}
});

Object.extend(Form, Form.Methods);
Element.addMethods();
