function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];
	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}

/*------------------------------------------------------------------------*/

function chkSpace(txtfield)
{
	var i,j;
	j=0;
	txtfield=eval(txtfield)
	var txtval=txtfield.value;
	for(i=0;i<txtval.length;i++)
	{
		j++
		if(txtval.substr(i,1)!=" ")
			break;
	}
	txtval=txtval.substr(j-1,txtval.length);
	if(txtval==" ")
	   txtval="";

	txtfield.value=txtval;
	return(txtval);

}

/*------------------------------------------------------------------------*/
var errMsg="";
function SendNewsLetterInfo()
{

	ObjForm=document.FrmNews;
	if(chkSpace(ObjForm.fname)=="")
		errMsg="- First Name";
	if(chkSpace(ObjForm.lname)=="")
		errMsg+="\n- Last Name";
	if(checkEmail(ObjForm.email.value)==0)
		errMsg+="\n- Valid email address";
	if(errMsg=="")
	{
		ObjForm.method="post";
		ObjForm.action=SendNewsLetterInfo.arguments[0];
		ObjForm.submit();
	}
	else
	{
		alert("Please kindly fill out the following missing information:\n---------------------------------------------------------------\n"+errMsg)
		errMsg="";
	}
}

function SendContactInfo()
{
	ObjForm=document.FrmContact;
	if(chkSpace(ObjForm.FullName)=="")
		errMsg="- Full Name";
	if(checkEmail(ObjForm.Email.value)==0)
		errMsg+="\n- Valid email address";
	if(chkSpace(ObjForm.Message)=="")
		errMsg+="\n- Comments or Inquiry";
	if(errMsg=="")
	{
		ObjForm.method="post";
		ObjForm.action=SendContactInfo.arguments[0];
		ObjForm.submit();
	}
	else
	{
		alert("Please kindly fill out the following missing information:\n---------------------------------------------------------------\n"+errMsg)
		errMsg="";
	}
}
