//===========================================================================
// Iterate through the form's validation controls and display the error 
// message for the first invalid control found.
//===========================================================================
function LookForErrors(arrValiditionControls, sMessageLineID) {
var iIndex;
var hCurrentControl;
var bReturnValue = true;

	//Iterate through the form's validation controls
	for (iIndex = 0; iIndex < arrValiditionControls.length; iIndex++) {
		
		//Save a reference to the current validation control.
		hCurrentControl = window.document.getElementById(arrValiditionControls[iIndex]);
		if (hCurrentControl != null) {
		
			//If the validation control is visible an error message will be displayed.
			//alert(arrValiditionControls[iIndex] + ': ' + hCurrentControl.style.display);
			if (hCurrentControl.style.display != 'none') {
				DisplayErrorMessage(hCurrentControl.children[0], sMessageLineID);
				bReturnValue = false;
				break;
			}
		}
	}	

	return bReturnValue;
}


//===========================================================================
// Display the error message and focus on the field that generated the error
//===========================================================================
function DisplayErrorMessage(hImage, sMessageLineID) {
var sErrorIcon = '<IMG src="ICON_FILE" align="absmiddle" height="17" width="17" style="MARGIN-RIGHT: 3px">'
var sImagePrefix = hImage.id.substring(0,4);
var sFocusControl;
var sContainerControl;
var iTagIndex;
	
	if (sImagePrefix == "img_")
	{
		sFocusControl = hImage.id.substring(4);
		sContainerControl = '';		
	}
	else
	{
		iTagIndex = hImage.id.indexOf('img_');
		sContainerControl = hImage.id.substring(0, iTagIndex);
		sFocusControl = sContainerControl + hImage.id.substring(iTagIndex + 6);
	}

	window.document.all(sContainerControl + sMessageLineID).innerHTML = sErrorIcon.replace(RegExp(/ICON_FILE/g), hImage.src.replace(RegExp(/ind/g), 'icon')) + hImage.alt;	
	window.document.getElementById(sFocusControl).focus(); 
	
}

