function checkPhoneNumbers(PhoneTypes, RowNames, frm, isReq)
{
	var i;
	var isAtLeastOnePhone = false;

	var arrPhoneTypes = PhoneTypes.split(",");
	var arrRowNames = RowNames.split(",");
	for(i=0;i<arrPhoneTypes.length;i++)
	{
		var areaCode = frm[arrPhoneTypes[i] + "1"].value;
		var exchange = frm[arrPhoneTypes[i] + "2"].value;
		var plusFour = frm[arrPhoneTypes[i] + "3"].value;

		if(areaCode != "" || exchange != "" || plusFour != "")
		{
			if(!isValidPhone(areaCode,exchange,plusFour))
			{
				ThrowError(arrPhoneTypes[i],arrRowNames[i], frm);
				isAtLeastOnePhone = true;
			}
			else
			{
				removeErrorFormatting(arrPhoneTypes[i],arrRowNames[i], frm);
				isAtLeastOnePhone = true;
			}
		}
		else
		{
			if(frm[arrPhoneTypes[i] + "4"])
			{
				if(frm[arrPhoneTypes[i] + "4"].value != "")
					ThrowError(arrPhoneTypes[i],arrRowNames[i], frm);
			}
			removeErrorFormatting(arrPhoneTypes[i],arrRowNames[i], frm);
		}
	}

	if(!isAtLeastOnePhone && isReq.toLowerCase() == 'true')
	{
		for(i=0;i<arrPhoneTypes.length;i++)
		{
			ThrowError(arrPhoneTypes[i],arrRowNames[i], frm);
		}
	}

	return true;
	
}
//-----------------------------------------------------------------------------	


function isValidPhone(iAreaCode, iExchange, iPlusFour)
{

	var sFullPhone = iAreaCode + "-" + iExchange + "-" + iPlusFour;
	return phoneRegEx.test(sFullPhone);

}

//-----------------------------------------------------------------------------			
function isLengthZero(val)
{
	if(frm[val].value.length != 0)
		return false;
	else
		return true;
}
//-----------------------------------------------------------------------------			
function findMatch(arr,val)
{
	var returnVal = false;
	for(var i=0; i < arr.length; i++)
	{
		if(val == arr[i])
			returnVal = true;
	}
	return returnVal;			
}
//-----------------------------------------------------------------------------
function isPhoneEmpty(phoneType)
{
	if(isLengthZero(phoneType + phonePart + "1") && isLengthZero(phoneType + phonePart + "2") && isLengthZero(phoneType + phonePart + "3"))
	{
		return true;
	}
	else
	{
		return false;
	}
}
//-----------------------------------------------------------------------------
function getProperTypeName(val)
{
	switch (val)
	{
 		case "home" :
 			return "Evening";
 		case "work" :
			return "Day";
		case "cell" :
			return "Cell";
 	}
}

