<!--//--><![CDATA[//><!--
// RUNAT="server"
/** start trim function**/
function trim(Str)
{
	if((Str != null) && (Str != "") && (Str.indexOf(" ",0)!=-1))
	{
		var iMax = Str.length;
		var end = Str.length;
		var c;
		var i;
		for(i=0;1<iMax;i++)
		{
			c = Str.substring(0,1);
			if (c == " ")
			{
				Str=Str.substring(1,end);
				end = Str.length;
			}
			else
				break;
		}
		iMax = Str.length;
		end = Str.length;
		for(i=iMax;i>0;i--)
		{
			c = Str.substring(end-1,end)
			if (c == " ")
			{				
				Str=Str.substring(0,end-1);
				end = Str.length;
			}
			else
				break;
		}
	}
	return Str;
}

/** start isEmpty  function**/
function isEmpty(str)
{
	var trimmed = trim(str);
	return((trimmed==null) || (trimmed.length==0));
}

/** start IsValidEmail **/
/* This function has been modified from the original primitiveedits_js version. This
    version is only concerned with validating a string is in the correct format and
    returns trueor false. */
function isValidEmailFormat(strEmail)
{
	if (isEmpty(strEmail))
		return true;

	// match an Email, with 1 @ and at least one . with at least one alpha character after it
	EmailRegEx = /^[A-Za-z0-9_\.\-]+[@][\w{1,}\.\-]+\.\w+$/i;
	if (EmailRegEx.test(strEmail))
		return true;
	else 
		return false;
}

/** start IsValidEmail **/
/* This function has been modified from the original primitiveedits_js version. This
    version is only concerned with validating a string is in the correct format and
    returns trueor false. */

function isValidPhone(strPhone)
{
	if (isEmpty(strPhone))
		return true;

// match a phone of forms:	8037480506, 803 748 0506, 803-748-0506, 
//	(803)748 0506, (803)748-0506, (123) 456 7890, (123)-456-7890, (123) 456-7890
//  --(803)748-0506 x139, 803-748-0506 x139

	// Format for 9999999999
	PhoneRegEx = /^[1-9][0-9]{2}[1-9][0-9]{6}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for 999-999-9999
	PhoneRegEx = /^[1-9][0-9]{2}-[1-9][0-9]{2}-[0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for 999 999 9999
	PhoneRegEx = /^[1-9][0-9]{2}[ ][1-9][0-9]{2}[ ][0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for (999) 999 9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)][ ][1-9][0-9]{2}[ ][0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for (999)999 9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)][1-9][0-9]{2}[ ][0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for (999)-999-9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)]-[1-9][0-9]{2}-[0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for (999)999-9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)][1-9][0-9]{2}-[0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

	// Format for (999) 999-9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)][ ][1-9][0-9]{2}-[0-9]{4}$/i;
	if (PhoneRegEx.test(strPhone))
		return true;

/*
	// Format for (999)-999-9999 x 99 OR (999) 999-9999 x 9999
	PhoneRegEx = /^[\(][1-9][0-9]{2}[\)][ ]?-?[1-9][0-9]{2}-?[0-9]{4}[ ]?[xX][ ]?[0-9]{2,4}$/i;
	if (PhoneRegEx.test(fObj.value))
		return true;

	// Format for 999-999-9999 x 99 OR 9999999999 x 9999
	PhoneRegEx = /^[1-9][0-9]{2}-?[1-9][0-9]{2}-?[0-9]{4}[ ]?[xX][ ]?[0-9]{2,4}$/i;
	if (PhoneRegEx.test(fObj.value))
		return true;
*/
	return false;
}
//--><!]]>

