//CHECKS THAT A STRING IS NUMBER
function isNumber( incomingValue ) 
{
  var numberString = "0123456789-";
  var thisCaracter;
  var counter = 0;
  
  incomingValue = incomingValue.replace(/ /gi,'');
  
  for ( var nextCharacter = 0; nextCharacter < incomingValue.length; nextCharacter++ )  
  {
     currentCharacter = incomingValue.substring( nextCharacter, nextCharacter+1 );
     if ( numberString.indexOf( currentCharacter ) != -1 ) counter++;
  }

  if ( counter == 0 ) return (false);

  if ( counter == incomingValue.length )
  {
     return(true);
  }
  else
  {
	 return(false); 
  }   
}

function isRealNumber( incomingValue ) 
{  	
	if ( incomingValue != '')
	{
		if( isNumber( incomingValue ) )
		{
			return( true );
		}
		else
		{
			num = parseFloat( incomingValue );
			if ( incomingValue != '' + num ) return(false);
			else return(true);
		}
	}
	else
	{
		return(false);
	}
}

function isNotEmail( incomingValue ) 
{ 
	var p,a,errors = '';
	
	a=incomingValue.indexOf('@');
	p=incomingValue.indexOf('.');
		   
    if ( ( a<1 || a==( incomingValue.length-1 ) ) || ( p<1 || p==( incomingValue.length-1) ) ) return true ;
}

function isEmpty( incomingValue )
{
	if ( incomingValue == "") return true;
}
			
function checkForm( theForm ) 
{
	var email = theForm.email;
	var name = theForm.name;
	var phone = theForm.phone;
	var service = theForm.service;
	var comments = theForm.comments;

	if ( isEmpty( email.value ) ) 
	{
		alert("Please enter your e-mail address.");
		theForm.email.focus();
		return false;
	} 
	else if ( isNotEmail( email.value ) ) 
	{
		alert("Please enter a valid email address.");
		theForm.email.focus();
		return false;
	} 
	else if ( isEmpty( name.value ) ) 
	{
		alert("Please enter your name.");
		theForm.name.focus();
		return false;
	}
	else if ( isEmpty( phone.value ) ) 
	{
		alert("Please enter your phone number.");
		theForm.phone.focus();
		return false;
	}
	else if ( !isNumber( phone.value ) ) 
	{
		alert("Please enter your phone number.");
		theForm.phone.focus();
		return false;
	}
	else if ( isEmpty( phone.comments ) ) 
	{
		alert("Please give some details about your inquiry.");
		theForm.comments.focus();
		return false;
	}
}