/******************************************************************************
* Name					:	chkUsername
* Purpose				:	Check for valid email address
* Input Parameters		:	val		element value
* Return				:	False if whitespace only in field
* Notes:
*/
function chkUsername(field)
{
	if(!chkEmail(field.value))
	{
		alert("The address you entered is not the correct format");
		field.focus();
		field.select();
		return(false);
	}
	else
	{
		return(true);
	}
}
/********************* End of function chkUsername(field) ***************************/

/*******************************************************************************
* Name				:	chkAnswer
* Purpose			:	Check for only whitespace entered
* Input Parameters	:	val		element value
* Return			:	False if whitespace only in field
*/
function chkAnswer(f)
{
	/*
	The following pattern specifies the following:
	0 or more digits (\d*)
	zero or more digits followed by a decimal point (\d*\.),
	followed by exactly 2 digits (\d{2}).
	
	var check = /^\d*$|^\d*\.\d{2}$/;
	
    if (!(check.test(val)))
	{	
		alert("Please enter a valid dollar amount");
		return false;
	}
*/
	var val = f.answer.value;

	//val.replace(/^\s*/, '').replace(/\s*$/, ''); 	
    // this will get rid of leading spaces 
    while (val.substring(0,1) == ' ')
	{
        val = val.substring(1, val.length);
	}

    // this will get rid of trailing spaces 
    while (val.substring(val.length-1,val.length) == ' ')
	{
        val = val.substring(0, val.length-1);
	}

	if(val.length > 0)
	{
		var ch = val.charAt(0);
		if((ch != '\n') && (ch != '\t'))
			return(true);
		else
		{
			return(false);	// Value contains whitespace only
		}
	}
	else
	{
		return (false);
	}
}
/************************ End of function chkSpaces(val) ****************************/

/********************************************************************
*	Function:	submitRetrieval(f)
*	Purpose:	submit form to processing page
*	Parameters:	f form being submitted
*	Return:		none
*/
function submitRetrieval(f)
{
	f.method="get";
	if(f.name == "frmMainLogin")
	{
		f.action="binders/forgotten_password.php";
	}
	else
	{
		f.action="../binders/forgotten_password.php";	// path name of xt page.  Dependant on specific app
	}
	f.submit();
}
/******************* End of function submitRetrieval(f) *******************/

function regular(str)
{
	/*
	The following pattern specifies the following:
	0 or more digits (\d*)
	zero or more digits followed by a decimal point (\d*\.),
	followed by exactly 2 digits (\d{2}).
	*/
	var check = /^\d*$|^\d*\.\d{2}$/;
	
    if (!(check.test(str)))
	{	
		alert("Please enter a valid dollar amount");
	}
}
