/**
 * @author JP for JL Web Services use ONLY!
 * Created On: January 19, 2008
 */
<!--
function allNumeric( phoneNumber )
{
	// tests phone number for all numeric data
		var allNumericTest = /\d{9}/;
		return ( !allNumericTest.test( phoneNumber) );
} // end function allNumeric

function validate()
{
	var form = document.forms[ 0 ];
	var msg = "Please enter valid information in the following fields:\n";
	var errorCount = 0;
	
	// loop through each form element
	for( var i = 0; i < form.elements.length; i++ )
	{
		// look to see if the element type is of type text and its id is firstname
		if( form.elements[ i ].type == "text" && form.elements[ i ].id == "firstname" )
		{
			// if it is, make sure it is not null
			if( form.elements[ i ].value == "" )
			{
				msg += "First Name\n";
				errorCount++;
			}
		} // end if
		
		// look to see if the element type is of type text and its id is lastname
		if( form.elements[ i ].type == "text" && form.elements[ i ].id == "lastname" )
		{
			if( form.elements[ i ].value == "")
			{
				msg += "Last Name\n";
				errorCount++;
			}
		} // end if
										
		// look to see if the element type is of type text and its id is phone
		if( form.elements[ i ].type == "text" && form.elements[ i ].id == "phone" )
		{
			if( form.elements[ i ].value == "" )
			{
				msg += "Phone Number\n";
				errorCount++;
			}
		} // end if			
	} // end for loop

	// test the telephone number to ensure it is all numeric
	if ( allNumeric( document.inquiry.phone.value ) == true )
	{
		msg += "\nYour phone number must also be all numeric characters (0-9), and\nentered in the following format: 8045551212.";
		errorCount++;
	} // end if
			
	// get the value entered
	var emailAddress = document.getElementById( "email" ).value;
		
	// if a value was entered into the email address field
	if( emailAddress != "" )
	{
		// test to see if an @ sign appears in the email address, if not add to the msg
		if( emailAddress.indexOf( "@" ) == -1 )
		{
			msg += "\n\n\"" + emailAddress + "\" is an invalid email address.";
			errorCount++;
		}
	} // end if					
	
	// test if there is an error condition on the page if so alert and return false
	if( errorCount > 0 )
	{
		alert( msg );
		return false
	}
	
	// else submit the form
	else
		return true;
} // end function validate


var windowReference = null;

function getDirections()
{
	// hard coded destination
	var destination = "3981+Old+Buckingham+Rd.+Powhatan+VA+23139"
	
	var URL = "http://maps.google.com/maps?daddr=" + destination;

	if( windowReference == null || windowReference.closed )
	{
		windowReference = window.open( URL, "newWindow" );
	}

	else
	{
		windowReference.focus();
	};

}


// -->