function ValidateForm(theForm, requiredFields, requiredFieldsCompare){
	var requiredFieldsArray = requiredFields.split(','); 
	var requiredFieldsCompareArray = requiredFieldsCompare.split('|');
	var currentField = ""; 
	var returnString = "";
	var returnFinalString = "";
	var browserType = ""
	
	browserType = BrowserDetect.browser; //This is the browser that is currently being used
	
	//loop through required fields and ensure that something is entered
	for(i=0;i<requiredFieldsArray.length;i=i+1){
		currentField = eval("theForm." + requiredFieldsArray[i]);
		if(currentField.value == ""){
			if (browserType == "Explorer" && currentField.friendlyName){
				returnString += "\n    - " + currentField.friendlyName;
			} else {
				returnString += "\n    - " + currentField.name;
			}
			// highlight the field
			currentField.className='requiredFormFieldAction';
		}
	}
	
	//Append the final string with the blank field data
	if (returnString != ""){
		returnFinalString += "Please enter a value for: " + returnString;
	}
	
	//reset the returnString element so the comparison engine can check it.
	returnString = "";
	
	// Here do the comparison basedo nthe passed in data
	if(requiredFieldsCompareArray != ""){
		for(i=0;i<requiredFieldsCompareArray.length;i=i+1){
		
			currentPairSet = requiredFieldsCompareArray[i].split(",");
			currentPairSetOne = eval("theForm." + currentPairSet[0]);
			currentPairSetTwo = eval("theForm." + currentPairSet[1]);
			
			if(currentPairSetOne.value !== currentPairSetTwo.value){
				if (browserType == "Explorer"){
					returnString += "\n    - " + currentPairSetOne.friendlyName + " and " + currentPairSetTwo.friendlyName;
				} else {
					returnString += "\n    - " + currentPairSetOne.name + " and " + currentPairSetTwo.name;
				}
			}	
		
		}
	}
	
	//Append the final string with the non matching field data
	if (returnString != ""){
		returnFinalString += "\n\nThe following fields do not have matching data: " + returnString;
	}
	
	//Do not allow form to submit and alert the final message
	if(returnFinalString != ""){
		alert(returnFinalString);
		return false;	
	}
}
