

function IsEmpty( text )
{
    if( text.value.length == 0 ) 
        return( true );
    for( var i=0; i<text.value.length; ++i )  
    {
        var ch = text.value.charAt(i);
        if( ch != ' ' && ch != '\t' ) 
            return( false );
    }
    return( true );
}


function IsEmail( text )
{
    if( text.value.length == 0 ) 
        return( false );
    if( text.value.indexOf("@") == -1 || text.value.indexOf(".") == -1 )
        return( false );
    return( true );
}


function ValidateGuideRequestForm(F)
{
    if ( IsEmpty(F.required_name) )
        {
        alert("Please enter your name.");
        F.required_name.focus();
        }
    else 
	if ( IsEmpty(F.required_company) )
        {
        alert("Please enter the name of your company.");
        F.required_company.focus();
        }
     else
		    /* check whether any selection was made */
    if( F.startMonth[F.startMonth.selectedIndex].value == '' )
        {
        alert("Please select a starting month.");
        F.startMonth.focus();
        }
	else
	if( F.startDate[F.startDate.selectedIndex].value == '' )
        {
        alert("Please select a starting day.");
        F.startDate.focus();
        }
	else
	if( F.startYear[F.startYear.selectedIndex].value == '' )
        {
        alert("Please select a starting year.");
        F.startYear.focus();
        }
	else
	if( F.endMonth[F.endMonth.selectedIndex].value == '' )
        {
        alert("Please select an ending month.");
        F.endMonth.focus();
        }
	else
	    if( F.endDate[F.endDate.selectedIndex].value == '' )
        {
        alert("Please select an ending day.");
        F.endDate.focus();
        }
	else
	    if( F.endYear[F.endYear.selectedIndex].value == '' )
        {
        alert("Please select an ending year.");
        F.endYear.focus();
        }
	else
	if ( IsEmpty(F.required_number_in_group) )
        {
        alert("Please enter the number of people in your group.");
        F.required_number_in_group.focus();
        }
     else
    if ( IsEmpty(F.required_addr1))
        {
        alert("Please enter your mailing address. Use the second line for your Apt/Suite number if applicable.");
        F.required_addr1.focus();
        }
   else
   if ( IsEmpty(F.city) )
        {
        alert("Please enter your city.");
        F.city.focus();
        }
    else 
   if ( IsEmpty(F.state) )
        {
        alert("Please enter your state.");
        F.state.focus();
        }
    else 
   if ( IsEmpty(F.zip) )
        {
        alert("Please enter your zip code.");
        F.zip.focus();
        }
    else 
	if ( IsEmpty(F.required_country) )
        {
        alert("Please enter your country.");
        F.required_country.focus();
        }
    else 
    if ( IsEmpty(F.required_voicearea) )
        {
        alert("Please enter your area code.");
        F.required_voicearea.focus();
        }
    else 
    if ( IsEmpty(F.required_voicephone) )
        {
        alert("Please enter your phone number.");
        F.required_voicephone.focus();
        }
    else 
    if ( IsEmpty(F.required_email) || !IsEmail(F.required_email) )
        {
        alert("Please enter a valid e-mail address.");
        F.required_email.focus();
        }
    else {
        return true;
    }
    
    return( false );
}

