function noSpace(sInput)	
{
	regex = /\W/g;
	return sInput.replace(regex,'');
}
	
function isCreditCardValid(CCNum)	
{
	x = noSpace(CCNum);
	if (x.length % 2 == 0)	
	{
		m = 2;
	} else	{
		m = 1;
	}
	j = 0;
	for (i=0;i<x.length;i++)	
	{
		g = x.slice(i,i+1);
		if (g * m  > 9 )	
		{
			j = j + (((g * m)-10) + 1);
		} else	{
			j = j + (g * m);
		}
		if (m == 1)	
		{
			m = 2;
		} else	{
			m = 1;
		}
	}
	if (j % 10 == 0)	
	{
		return true;
	} else	{
		return false;
	}
}

	

function isZipCode(zipVal)	
{
	var z = /^[0-9]{5}$/;
	return z.test(zipVal);
}
		
function isEmail(posEmail)	
{
	var g = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[1-9]{1,3})(\]?)$/;
	return g.test(posEmail);
}
		
function isAreaCode(ACValue)	
{
	var ac = /^[2-9][0-9]{2}$/;
	if (!ac.test(ACValue)) return false;
	var a800 = /800|888|555|900|976/;
	if (a800.test(ACValue)) return false;
	return true;
}

function isChecked(element)
{
	var bChecked = false;
	for (i=0;i<element.length;i++)
	{
		bChecked = element[i].checked ? true : bChecked;
	}
	return bChecked;
}

function hasVal(arg)
{
	return (arg.length > 0) ? true : false;
}

function isNumeric(numval)	{
		numval = numval + '';
		if (numval== '')	{
			return false;
			}
		var x = numval.length;
		g = /\d{1}/
		for (i=0;i<x;i++)	{
			f = numval.slice(i,i+1);
			h = g.test(f);
			if (!h)	{
			 return false;
			 }
			}
		return true;
		}
	

		
	function isPhone(phoneVal)	{
		//remove all non alpahnumerics
		var j = noSpace(phoneVal);
		//check to make sure there are no alphas
		if (!isNumeric(j))	{
			return false;
			}
		//test the length for a valid phone number length
		if (j.length != 7 && j.length != 10 && j.length != 11)	{
			return false;
			}
		//phone numbers cant start with '0'
		if (j.slice(0,1) == '0')	{
			return false;
			}
		//phone numbers can only start with 1 is it is preceeding an area code
		if (j.slice(0,1) == '1' && j.length !== 11)	{
			return false;
			}
		return true;
		}	
		
	function isAreaCode(ACVal)	{
		var j = noSpace(ACVal);
		if (j.length != 3)	{
			return false;
			}
		if (!isNuermic(j))	{
			return false;
			}
		var re = /^[0-1]/
		if (re.test(j))	{
			alert(re);
			return false;
			}
		if (j.slice(0,1) == "1" || j.slice(0,1) == "0") {
			return false;
			}
		return true;
		}
