function solicita(){
  // Ajax Form Demo
  $('boto-solicitar').observe('click', function(event) {
  	
    event.stop();
	Lightview.show({
	  href: url_solicita,
	  rel: 'ajax',
	  title: '',
	  options: {
	    width: 732,
	    height: 450,
		ajax: {
		  onComplete: function(){		  	
		    // once the request is complete we observe the submit button
			$('enviar').observe('click', function (event) {
				submitAjaxForm(event);
			});
		  } 
	    }
	  }
	});
  });
  
}

function submitAjaxForm(event) {
  // block default form submit  
  event.stop();
  
  if (! validarFormulari()) {
	$('form-solicita-error').show();
	return;
  }
	  
  Lightview.show({
    href: url_envia,
    rel: 'ajax',
    options: {
      title: 'results',
	  menubar: false,
	  topclose: true,
	  width: 400,
	  height: 100,
      ajax: {
        parameters: Form.serialize('form-solicita') // the parameters from the form
      }
    }
  });
}

function validarFormulari() {
	var fields = $A(['nom', 'cognoms', 'email', 'referencia']);
	var el;
	var hasErrors = false;
	fields.each(function (v) {
		el = $('form-solicita').getInputs('text', v)[0];
		el.setStyle({backgroundColor: 'white'});
		if ($F(v) == '') {
			el.setStyle({backgroundColor: '#fbb'});
			hasErrors = true;
		}
	});
	
	//Textarea
	el2 = $('us');
	el2.setStyle({backgroundColor: 'white'});
	if(el2.value == '') {
		el2.setStyle({backgroundColor: '#fbb'});
		hasErrors = true;
	}
	
	return ! hasErrors;
}