﻿function validEmail(email)
{
	invalidChars=" /:,;";	
	//If email contain invalid characters ---> 
	for (i=0; i<invalidChars.length; i++)	
		{
		badChar=invalidChars.charAt(i);
		if (email.indexOf(badChar,0)>-1) 
			return false;
		}	
	var atPos = email.indexOf("@",1);
	if (atPos==-1) 
		return false;
	if (email.indexOf("@",atPos+1)>-1) 
		return false;
	var periodPos = email.indexOf(".",atPos);
	if (periodPos == -1)	
		return false;
	
		return true;
}
function isNumber(Number)
{
	var  strNumber="abcdefghijklmnopqrstuvwxyz/\;'{}*?@^&)(_+=$!%";
	Number=Number.toLowerCase();
	for (i=0;i<Number.length;i++)
	{
		oneChar=Number.charAt(i);
		if (strNumber.indexOf(oneChar,0)>-1)
			return false;			
	}
	return true;
}
function onSubmitContactForm(theForm)
{
	if(theForm.name.value =="")
	{
		alert("Please enter your name.");
		theForm.name.focus();
		return false;
	}
	
	if(theForm.message.value =="")
	{
		alert("Please enter a message.");
		theForm.name.focus();
		return false;
	}

	if(theForm.email.value =="")
	{		
		alert("Please enter an email address.");
		theForm.email.focus();
		return false;
	}
	else
	{
		if (!validEmail(theForm.email.value))
		{
			alert("Please enter a valid email address.");
			theForm.email.focus();
			return false;
		}
	}
	
	return true;
}
function onSubmitPromoForm(theForm)
{
	if(theForm.name.value =="")
	{
		alert("Please enter your name.");
		theForm.name.focus();
		return false;
	}
	
	if(theForm.email.value =="")
	{		
		alert("Please enter an email address.");
		theForm.email.focus();
		return false;
	}
	else
	{
		if (!validEmail(theForm.email.value))
		{
			alert("Please enter a valid email address.");
			theForm.email.focus();
			return false;
		}
	}
	
	return true;
}