/**
 *  Form Control, version 1.0.0
 *  (c) 2007 Arturo La Monaca - GSSI srl <arturo.lamonaca@gssi.it>
 */

wsm.include("jtajax.js");
 
function wsm_formConsulenza_Submit(baseUrl) {
	var errors = "";
	var theForm = $('formConsulenzaFS');
	theForm.this_href.value = document.location.href;
	var mandatoryFields = theForm.MandatoryFields.value.split(",");
	for(var i=0; i<mandatoryFields.length; i++) { 
		var elm = $N(mandatoryFields[i])[0];  
    if (elm.value.trim() == "") {
    	errors += (errors != "" ? "\n" : "") + "- " + elm.getAttribute("label");
    }
  }
  if (errors != "") {
  	alert("I seguenti campi vanno inseriti obbligatoriamente:\n" + errors);
  	return false;
  } else {
	  wsm_callAction(baseUrl, "wsm.securityCodeCheck.act", 
	  	{passline: theForm.passline.value, passline_enc: theForm.passline_enc.value}, 
	  	function(retValue) {
	  		if (retValue != "ok") 
	  			errors = retValue;
	  	}, {async: false});
	}
  
  if (errors != "") {
  	alert(errors);
  	return false;
  } 
  
  return true;
}