function registre(id){
  // Ajax Form Demo
  $('boto'+id).observe('click', function(event) {
  	
    event.stop();
	Lightview.show({
	  href: url_amic,
	  rel: 'ajax',
	  title: '',
	  options: {
	    width: 410,
	    height: 400,
		ajax: {
		  onComplete: function(){		  	
		    // once the request is complete we observe the submit button
			$('enviar').observe('click', function (event) {
				submitAjaxForm(event, id);
			});
		  } 
	    }
	  }
	});
  });
  
}

function submitAjaxForm(event, id) {
  // block default form submit  
  event.stop();

  if (! validarFormulari()) {
	$('form-amic-error').show();
	return;
  }	 
	 
  Lightview.show({
    href: url_amic2 + "?id=" + id,
    rel: 'ajax',
    options: {
      title: 'results',
	  menubar: false,
	  topclose: true,
	  width: 400,
	  height: 100,
      ajax: {
        parameters: Form.serialize('form-amic') // the parameters from the form
      }
    }
  });
}

function validarFormulari() {
	var fields = $A(['nom', 'nom2', 'mail', 'mail2']);
	var el;
	var hasErrors = false;
	fields.each(function (v) {
		el = $('form-amic').getInputs('text', v)[0];
		el.setStyle({backgroundColor: 'white'});
		if ($F(v) == '') {
			el.setStyle({backgroundColor: '#fbb'});
			hasErrors = true;
		}
	});
	return ! hasErrors;
}