﻿var phone = "()- 0123456789";
var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789";

function res(t,v)
	{
	var w = "";
	var i;
	for (i=0; i < t.value.length; i++)
		{
		var x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
		w += x;
		}
	t.value = w;
	} 


function checkForm( form )
	{
		
	if (form.custname.value == "")
		{
		alert( "Please enter your name." );
		form.custname.focus();
		return false;
		}

	if (form.custcompany.value == "")
		{
		alert( "Please enter your company name." );
		form.custcompany.focus();
		return false;
		}
						
	if (form.custaddress.value == "")
		{
		alert( "Please enter your address." );
		form.custaddress.focus();
		return false;
		}

	if (form.custcity.value == "")
		{
		alert( "Please enter your city." );
		form.custcity.focus();
		return false;
		}

	if (form.custzip.value == "")
		{
		alert( "Please enter your address." );
		form.custzip.focus();
		return false;
		}

if (form.custtele.value == "")
		{
		alert( "Please enter your telephone number." );
		form.custtele.focus();
		return false;
		}

	if (form.custemail.value == "")
		{
		alert( "Please enter your Email address." );
		form.custemail.focus();
		return false;
		}
}

	
function checkForm( form )
	{
		
	if (form.earthname.value == "")
		{
		alert( "Please enter your name." );
		form.earthname.focus();
		return false;
		}

	if (form.earthcompany.value == "")
		{
		alert( "Please enter your company name." );
		form.earthcompany.focus();
		return false;
		}
						
	if (form.earthaddress.value == "")
		{
		alert( "Please enter your address." );
		form.earthaddress.focus();
		return false;
		}

	if (form.earthcity.value == "")
		{
		alert( "Please enter your city." );
		form.earthcity.focus();
		return false;
		}

	if (form.earthzip.value == "")
		{
		alert( "Please enter your address." );
		form.earthzip.focus();
		return false;
		}

if (form.earthtele.value == "")
		{
		alert( "Please enter your telephone number." );
		form.earthtele.focus();
		return false;
		}

	if (form.earthemail.value == "")
		{
		alert( "Please enter your Email address." );
		form.earthemail.focus();
		return false;
		}
}

//====================== functions ========================
//------------------------------------------------------------------
// If the string matches the regular expression it is a well formed email address
function emailCheck(x)
	{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
		{
		return true;
		}
	else
		{
		return false;
		}
	}

//------------------------------------------------------------------
// If the string matches the regular expression it is all letters
function alphaCheck(msg)
	{
	var alphaExp = /^[a-zA-Z]+$/;
	if(msg.match(alphaExp))
		{
		return true;
		}
	else
		{
		return false;
		}
	}

//------------------------------------------------------------------
// If the string matches the regular expression it is all numbers	
function numberCheck(msg)
	{
	var numericExpression = /^[0-9]+$/;
	if(msg.match(numericExpression))
		{
		return true;
		}
	else
		{
		return false;
		}
	}

//------------------------------------------------------------------
	
