function ConfirmAfterValidation() {
	var retval; //What our function will return
	var bConfirm; // A boolean flag. If it's true, we'll show the confirmation dialog
	var i; // a temporary integer storage
	var sTmp; // A temporary string
	var objWrongField;
	var sWrongFieldName;

	retval = false; // set the default return value for the function
	var bConfirm = true // set the default boolean flag as to whether to confirm with the user or not.
	
	oCol= document.getElementsByTagName('SPAN'); // get all the SPAN elements on the page.
 
	// Loop through them.
	for (i=0; i<oCol.length; i++)
	{ 
		// Get the ControlToValidate attribute. Only a RFV will have this 
		// (unless you are using this yourself somewhere [not recommended])
		sTmp = oCol[i].getAttribute('ControlToValidate'); 
		
		//Did this attribute exist on the span?
		if (!(sTmp == null))
		{ 
			//What there a value in this attribute?
			if(!sTmp.length==0) 
			{
				//Is this SPAN currently displayed?
				if ((oCol[i].style.visibility == 'visible') || (oCol[i].style.display == 'inline'))
				{
					//Since the span is visible, the Control it's validating failed.
					bConfirm = false;
					sWrongFieldName = sTmp;
					// Since we only want the user to confirm once they've correctly
					// filled out the form we set the boolean flag as to whether to 
					// show the "are you sure" dialog to false.
					// remember it defaults to true.					
				}
			}
		}
	}
	
	//is our flag to display still true? It will be false
	//if (bConfirm == true)
	//{ 
	//	//Confirm with the user
	//	retval = window.confirm('Confermi?')
	//	
	//	//Did they click cancel or not confirm?
	//	if (!retval) { 
	//		// If so, then let's enforce that they never clicked the button at all
	//		window.event.returnValue = false; 
	//	}			
	//}
	//else
	if (bConfirm != true)
	{
		alert('Alcuni valori inseriti sono errati: controllare prima di procedere');
		objWrongField = document.getElementsByName(sWrongFieldName);
		objWrongField(0).focus();
	}

	//Return the retval
	return retval; 

}

