/* //////////////////////////////////////////////////////////////////////////
 *	Purpose: This file contains commonly used JavaScript Utility Functions
 * /////////////////////////////////////////////////////////////////////////
*/

//Removes Leading Spaces from a string
function leftTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	
	return sString;
}
//Removes Trailing Spaces from a string
function rightTrim(sString)
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//Removes Leading & Trailing Spaces from a string
function allTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	
	return sString;
}

//Ensures that only numeric data is entered for keypress
function ensureInteger(e)
{
	var charAllowed = false;
	var key = window.event ? e.keyCode : e.which;
	
	//If numeric
	if(key >= 48 && key <=57)
	{
		charAllowed = true;
	}
	
	//If Backspace
	if(key == 8)
	{
		charAllowed = true;
	}
	
	//suppress char 
	if(charAllowed == false)
	{
		return false;
	}
}

//Checks if a valid email address is entered
function isValidEmail(email) {
	var reEmail = /^.+\@.+\..+$/
	return reEmail.test(email)
}
