// ----------------------------------------------------------------------
// Javascript form validation routines.
// ----------------------------------------------------------------------

emptyString = /^\s*$/

/******************************************************
 * Trim function.  Call it by "stringVariable.trim()"
 ******************************************************/
String.prototype.trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

// -----------------------------------------
// Another trim function.
// Trim leading/trailing whitespace off string
// -----------------------------------------
function trim(str)
{
  	return str.replace(/^\s+|\s+$/g, '')
};

// -----------------------------------------
// Check if a value is present for the given field.
// Returns true (validation passed) or 
//         false (validation failed)
// -----------------------------------------

function validatePresentByID (ifld)   // ID of element to be validated           
{
  	var elem = document.getElementById(ifld);
  	
  	if (emptyString.test(elem.value)) 
  		return false;
    
  	return true;
}

// -----------------------------------------
// Check if a value is present for the given field.
// Returns true (validation passed) or 
//         false (validation failed)
// -----------------------------------------

function validatePresent (value)   // value to be validated           
{
  	if (emptyString.test(value)) 
  		return false;
    
  	return true;
}

