function ValidatePhone(rawnum)
{
	num = stripAlphaChars(rawnum);
	var _return=false;

	if(num.length != 10)
	{ 
		_return=num;
	} 
	else
	{ 
		_return="(";
		var ini = num.substring(0,3);
		_return+=ini+") ";
		var st = num.substring(3,6);
		_return+=st+"-";
		var end = num.substring(6,10);
		_return+=end;
	}
	return _return; 
}

function stripAlphaChars(pstrSource) 
{ 
	var m_strOut = new String(pstrSource); 
	m_strOut = m_strOut.replace(/[^0-9]/g, ''); 
	
	return m_strOut; 
}

function ValidateSideContact()
{
	var yourname = trim(document.forms["contact"]["yourname"].value);
	var phone = trim(document.forms["contact"]["phone"].value);
	var email = trim(document.forms["contact"]["email"].value);

	var clear = true;
	
	if(yourname == "" || yourname == null)
	{
		document.form["contact"]["yourname"].style.backgroundImage = "url('images/red_x.png')";
		clear = false;
	}
	
	if((phone == "" || phone == null) && (email == "" || email == null))
	{
		clear = false;
	}

	return clear;
}

function trim(str)
{
	var trimmed = str.replace(/^\s+|\s+$/g, '') ;
	return trimmed;
}
