// <!--
/*********************************************************************************************************
	This variable is the holder for the array of errors encountered while processing validations
	DEPENDS ON: none
*********************************************************************************************************/
var aErrors = new Array( );


/*********************************************************************************************************
	This function adds an error message to the array of errors.
	DEPENDS ON: none
*********************************************************************************************************/
function addError( vMessage )
{
	aErrors.push( vMessage );
}


/*********************************************************************************************************
	This function returns the first error message from the array of errors removing it from the array.
	DEPENDS ON: none
*********************************************************************************************************/
function shiftError( )
{
	return aErrors.shift( );
}

/*********************************************************************************************************
	This function checks the array of errors and formats any messages and displays them.  This function
	will return true if there are no errors found, and false if errors are present.
	DEPENDS ON: none
*********************************************************************************************************/
function parseErrors( )
{
	if( aErrors.length != 0 )
	{
		var vErrorMsg = "The following error(s) were encountered when\nattempting to submit your information:\n\n";

		for( var i=0;i < aErrors.length; i++ )
		{
			vErrorMsg += "\t..." + aErrors[i] + "\n";
		}

		vErrorMsg += "\nPlease correct the above error(s) and try again.";
		
		alert( vErrorMsg );

		// reset the error array so that is is clear for the next call
		aErrors = new Array( );
		
		return false;
	}

	return true;
}

/*********************************************************************************************************
   This function works like parseErrors except displays into a div passed, instead of an alert box.
   This function checks the array of errors and formats any messages and displays them.  This function
	will return true if there are no errors found, and false if errors are present.
	DEPENDS ON: getObjectFormat
*********************************************************************************************************/
function parseErrorsDiv( vDivID )
{
	var oDivID = getObjectFormat( vDivID );
	
	if( aErrors.length != 0 )
	{
		var vErrorMsg = "The following error(s) were encountered when attempting to submit your information:<br/><br/>";

		for( var i = 0; i < aErrors.length; i++ )
		{
			vErrorMsg += "..." + aErrors[i] + "<br/>";
		}

		vErrorMsg += "<br/>Please correct the above error(s) and try again.";
		oDivID.style.display = 'block'; // make sure div is visible
      oDivID.innerHTML = vErrorMsg;   

		// reset the error array so that is is clear for the next call
		aErrors = new Array( );
		return false;
	}
	
	oDivID.style.display = ''; // don't change style just blank the contents of the div
	oDivID.innerHTML = '';
	return true;
}
// -->


