function CUtils(strForm)
{
    // Class constants
    var kDateYear = 0;									///< Year offset in date array
    var kDateMonth = 1;									///< Date offset in date array
    var kDateDay = 2;									///< Day offset in date array
    // Class variables
    var intMouseX = 0;									///< Stores the mouse X position
    var intMouseY = 0;                  				///< Stores the mouse Y position
    // Set up the form variables
    var m_objForm = eval(strForm);						///< Contains the reference to the form object
	var m_strForm = strForm;							///< Contains the form name as a string - used for eval expressions
    // Set up the function calls in the class
    this.updateMousePosition = updateMousePosition;
	this.updateCalendarPosition = updateCalendarPosition;
	this.handleSelect = handleSelect;
    this.checkEmailAddress = checkEmailAddress;
    this.checkPassword = checkPassword;
    this.checkText = checkText;
    this.checkMultiSelect = checkMultiSelect;
    this.checkSelect = checkSelect;
    this.checkDate = checkDate;
    this.checkUnsignedInt = checkUnsignedInt;
    this.checkUnsignedFloat = checkUnsignedFloat;
    this.setSearchPage = setSearchPage;
    this.checkFileType = checkFileType;

    /**
	* checkEmailAddress;  Performs basic checking of email address. Verifies that the address has
	*					  an '@' symbol and has text on either side, including at least one '.' in the domain name.
	*
	* @access public
	* @return bool
	*/
	function checkEmailAddress(objField, strMessage) {
		// Retrieve the string value
   		var strValue = objField.value.replace(/ */, "");
		// Create the regular expression object
    	var objRegExp = new RegExp('([^@]*)@([^.@]*)\.([^@]*)');
		// Check that the email address matches
		if (!objField.value.match(objRegExp)) {
			// Alert the user
			alert(strMessage);
			// Indicate the bad data
			return false;
	  	}
		// Otherwise, return true
		return true;
	}

    /**
	* checkPassword;  	Checks that a password is valid and that the
	* 					verification field matches
	*
	* @access public
	* @return bool
	*/
	function checkPassword(objField, objFieldVerify, strMessage) {
        // Check that the password meets a set of requirements
		if ((objField.value.length < 6) || (!objField.value.match(/\d+/gi)) || (!objField.value.match(/[a-z]+/gi))) {
            // Indicate  the requirements
			alert(strMessage + "\n\nMinimum of 6 ALPHANUMERIC characters.\nMust be at least one letter and one numeral in the password.");
            // Reset the password value
			objField.value = objFieldVerify.value = "";
			// Give the password field focus
			objField.focus();
			//  Indicate the error
			return false;
		} else if (objField.value != objFieldVerify.value) {
            // Passwords don't match
			alert("Please ensure that your passwords match");
            // Reset the password value
			objField.value = objFieldVerify.value = "";
			// Give the password field focus
			objField.focus();
			//  Indicate the error
			return false;
		}
        // Passwords match and are valid
		return true;
	}

    /**
	* checkText; Checks that a text field is valid
	*
	* @access public
	* @return bool
	*/
	function checkText(objField, strMessage) {
        // Strip spaces from the field
    	var strFieldValue = objField.value.replace(/ */, "");
        // If the parsed value is empty, the data is invalid
        if (strFieldValue == '') {
            // Alert the user
			alert(strMessage);
            // Reset the field value
			objField.value = "";
			// Give the field focus
			objField.focus();
			// Indicate the error
			return false;
		}
        // If we get here, the data is valid
		return true;
	}
	
	/**
	* checkUnsignedInt; Checks that an integer field is valid and the number is > 0
	*
	* @access public
	* @return bool
	*/
	function checkUnsignedInt(objField, strMessage) {
        // Convert the field to an integer
    	var intFieldValue = parseInt(objField.value);
    	// If the parsed value is empty, the data is invalid
        if (isNaN(intFieldValue) || (intFieldValue < 0)) {
            // Alert the user
			alert(strMessage);
            // Reset the field value
			objField.value = "";
			// Give the field focus
			objField.focus();
			// Indicate the error
			return false;
		}
        // If we get here, the data is valid
		return true;
	}

	/**
	* checkUnsignedFloat; Checks that an float field is valid and the number is > 0
	*
	* @access public
	* @return bool
	*/
	function checkUnsignedFloat(objField, strMessage) {
        // Convert the field to an integer
    	var fltFieldValue = parseFloat(objField.value);
    	// If the parsed value is empty, the data is invalid
        if (isNaN(fltFieldValue) || (fltFieldValue < 0)) {
            // Alert the user
			alert(strMessage);
            // Reset the field value
			objField.value = "";
			// Give the field focus
			objField.focus();
			// Indicate the error
			return false;
		}
        // If we get here, the data is valid
		return true;
	}

    /**
	* checkSelect; Checks that a dropdown field has been selected
	*
	* @access public
	* @return bool
	*/
	function checkSelect(objField, strMessage) {
        // If the selected value is empty, the data is invalid
        if (objField.options[objField.selectedIndex].value == '') {
            // Alert the user
			alert(strMessage);
            // Give the field focus
			objField.focus();
			// Indicate the error
			return false;
		}
        // If we get here, the data is valid
		return true;
	}
	
	/**
	* checkMultiSelect; Checks that at least one option value is selected
	*
	* @access public
	* @return bool
	*/
	function checkMultiSelect(objField, strMessage) {
        // Loop through the select options
        for (var i=0; i<objField.options.length; i++) {
			// Is this value selected?
			if (objField.options[i].selected) {
				// Item is selected	
				return true;
			}        	
        }
        // Alert the user
		alert(strMessage);
        // Give the field focus
		objField.focus();
        // No items selected
        return false;
	}

    /**
	* checkDate; Checks that a a date has been entered
	*
	* @access public
	* @return bool
	*/
	function checkDate(objField, strMessage) {
        // If the selected value is empty, the data is invalid
        if (objField.value == 'dd/mm/yyyy') {
            // Alert the user
			alert(strMessage);
            // Give the field focus
			objField.focus();
			// Indicate the error
			return false;
		}
        // If we get here, the data is valid
		return true;
	}
	
	/**
	* checkFileType; Checks that the uploaded file matches one of the allowed extensions
	*
	* @access public
	* @return bool
	*/
	function checkFileType(objField, strMessage, strAllowedExtensions) {
        // Split the allowed extensions into an array
        var arFileTypes = strAllowedExtensions.split(",");
		// Initialize the valid file variable
		var bValidFile = false;
        // Loop through the extensions
        for (x in arFileTypes) {
			// Test this extension        	
        	if (objField.value.lastIndexOf(arFileTypes[x]) != -1) {
				// Found a valid match
				bValidFile = true;
        	}
        }
		// Do we have a valid file?
		if (!bValidFile) {
			// Indicate to the user
			alert(strMessage + ' - Allowed extensions: ' + strAllowedExtensions);
		}		
        // Return the result
		return bValidFile;
	}

    /**
	* handleSelect; Handles a calendar select event and updates the
	* 				corresponding text box.
	*
	* @access public
	* @return void
	*/
	function handleSelect(strType, arArgs, objCalendar) {
        // Parse the argument array
		var arDates = arArgs[0];
		// Retrieve the date component
		var arDate = arDates[0];
		// Retrieve the text input object
		var objTextInput = document.getElementById(objCalendar.id + "_input");
		// Update the text input value
		objTextInput.value = arDate[kDateDay] + "/" + arDate[kDateMonth] + "/" + arDate[kDateYear];
		// Hide the calendar
        document.getElementById(objCalendar.id + "_container").style.display = "none";
	}

    /**
	* updateCalendarPosition; 	Moves the calendar control to hver abve the button
	*
	* @access public
	* @return void
	*/
	function updateCalendarPosition(strId) {
		/// Get access to the calendar div
        objCalendar = document.getElementById(strId);
        // Only update the values if the calendar isn't visible
        if (objCalendar.style.display == 'none') {
	        // Update the left position
	        objCalendar.style.left = intMouseX + 'px';
	        // Update the top position
	        objCalendar.style.top = intMouseY + 'px';
		}
	}

    /**
	* updateMousePosition; 	Updates the mouse position for use in positioning the calendar
	*
	* @access public
	* @return void
	*/
	function updateMousePosition(event) {
		// Update the X position
	    intMouseX = event.clientX + document.body.scrollLeft;
        // Update the Y position
	    intMouseY = event.clientY + document.body.scrollTop;
	}
	
    /**
	* setSearchPage; 	Sets the current search results page
	*
	* @access public
	* @return void
	*/
	function setSearchPage(strStartRecord) {
		// Set the start record
		m_objForm.start_record.value = strStartRecord;
		// Submit the form
		m_objForm.submit();
	}

}
