function GW_isDefined(strValue)
//RECEIVES:  strValue - string to look at to see if it is defined
//RETURNS:  true if strValue is defined
{
	return (new String(strValue) != 'undefined');
}

function GW_isString()
{
	if (typeof arguments[0] == 'string')
		return true;
	if (typeof arguments[0] == 'object')
	{
		var testing = arguments[0].constructor.toString().match(/string/i);
		return (testing != null);
	}
	return false;
}

function GW_DateToSmallDateStr(fullDate)
{
	with (fullDate)
		var result = '' + (getMonth()+1) + '/' + getDate() + '/' + getYear() + ' ' + 
				getHours() + ':' + getMinutes();
	return result;
}

function GW_charCount(charValue, strValue)
//RECEIVES:  strValue - string to look within to count the matching characters
//           charValue - character to look for within the string
//RETURNS:  the number of times the character specified is within the string
{
	var result = 0;
	for (var counter = 0; counter < strValue.length; counter++)
		if (strValue.charAt(counter) == charValue)
			result++;
	return result;
}

function GW_RplSubString(strOrigFull, strOrigSub, strNewSub)
//RECEIVES:  strOrigFull - the full string to look within
//           strOrigSub - the substring to replace
//           strNewSub - the substring to replace with
//RETURNS:  the original string with the substrings replaced as specified
{
	var strTemp = strOrigFull + '';
	while (strTemp.indexOf(strOrigSub) > -1)
	{
		pos = strTemp.indexOf(strOrigSub);
		strTemp = "" + (strTemp.substring(0,pos) + strNewSub +
			strTemp.substring((pos + strOrigSub.length), strTemp.length));
	}

	return strTemp;
}

function GW_InsertString(strOrig, strInsert, index)
{
	return strOrig.substring(0,index) + strInsert + strOrig.substring(index, strOrig.length);
}

function GW_FixCharacter(strOrig,chrFix)
//RECEIVES:  strOrig - string to use for fixing the quotes in
//           chrFix - character to fix by adding a \ in front of it
{
	var result = "" + strOrig;
	var counter = 0;		
	while (counter < result.length)
	{
		if (result.charAt(counter) == chrFix)
		{
			result = GW_InsertString(result, '\\', counter);
			counter++;
		}
		counter++;
	} 
    return result;	
}

function GW_isIP(strIP)
//RECEIVES:  strIP - string to check to see if it is an ip address
//RETURNS:  true if this appears to be an ip address
{
	if (GW_charCount('.',strIP) != 3)
		return false;
	for(var counter=0; counter < strIP.length; counter++)
		if ((strIP.charAt(counter) != '.') && 
			((strIP.charAt(counter) < '0') ||  (strIP.charAt(counter) > '9')))
			return false;
	return true;
}

function GW_DomainSuffix(domain)
//RECEIVES:  domain - domain to return the suffix from
//RETURNS:  the domain suffix (i.e. www.gateway.com returns gateway.com)
{
	var result = "" + domain;
	if (GW_isIP(domain)) //don't crop if it is an ip address
		return result;

	if (result.indexOf('.') != -1)
			result = result.substring(result.indexOf('.') + 1,result.length);
	return result;
}


/***********************begin added 8-17-01*************************************/
function GW_IntToCommaStr(intToConvert)
//RECEIVES:  intToConvert - an integer to convert to a string
//RETURNS:  a string that represents the given int formatted with commas
{
	var result = '' + intToConvert;
	for (var counter = result.length -4; counter >= 0; counter = counter - 3)
		result = GW_InsertString(result,',',counter+1);
	return result;
}

function GW_CommaStrToInt(strToConvert)
{
	var result = '' + strToConvert;

	result = GW_RplSubString(result,',','');

	return new Number(result);

}
//***********************end added 8-17-01*************************************

//**********************begin added 2-27-02***********************************
function GW_IsAlphaNumeric(strToTest)
//RECEIVES: strToTest - a string to check for alphanumeric characters
//RETURNS:  true if all characters are alphanumeric else false
{
	var result = true; //default result
	var charsOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	for (var counter=0; counter < strToTest.length; counter++)
	{
		if (charsOK.indexOf(strToTest.charAt(counter)) == -1)
			result =false;
	}
	return result;
}
//***********************end added 2-27-02************************************

function GW_LTrim ( strToFix )
{
	return strToFix.replace( /^\s*/, "" )
}

function GW_RTrim ( strToFix )
{
	return strToFix.replace( /\s*$/, "" );
}

function GW_Trim ( strToFix )
{
	return GW_RTrim(GW_LTrim(strToFix));
}

