// Validate_Length(STRING string, INTEGER length, STRING error)
// Returns true if length of string 'string' is within 'length'.
// If not, an alert box pops up with a standard message incorporating
// the specified 'error' string.
function Validate_Length(s, l, e) {
	the_length=s.length;
	var the_count=0;
	var y=0;
	for (i=0; i<the_length; i++) {
		foundOffset = s.indexOf("\r\n",y);
		if (foundOffset != -1) 
			{ the_count=the_count+1;
			y=foundOffset+1; }
		}
	the_length=(the_length + (3*the_count))
	if (the_length > l) {		
		alert("Please edit the " + e + " to make it shorter.\r\rThe " + e + " you have entered is " + the_length + " characters long.\rThe maximum number of characters allowed is " + l + ".");
		return false;
	}
	
	return true;
}

function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 
