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 checkSmoker(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check smoker, YES / NO.\n";
    }
return error;    
}


function ValidateContactForm(F)
{
    if ( IsEmpty(F.firstname) )
        {
        alert("Please enter your first name.");
        F.firstname.focus();
        }
    else 
	if ( IsEmpty(F.lastname) )
        {
        alert("Please enter your last name.");
        F.lastname.focus();
        }
    else 
	if ( IsEmpty(F.email) || !IsEmail(F.email) )
        {
        alert("Please enter a valid e-mail address.");
        F.email.focus();
        }
    else 
    if ( IsEmpty(F.phone) )
        {
        alert("Come on, tell us your phone number. And we promise, no telemarketers!");
        F.phone.focus();
        }
   else 
   if ( IsEmpty(F.state) )
        {
        alert("Hey, we promise not to drop in without calling first.");
        F.state.focus();
        }
    else 
    if ( IsEmpty(F.howheard) )
        {
        alert("Tell us how you heard about us. It really boosts our ego!");
        F.howheard.focus();
        }
    else     
    if ( IsEmpty(F.cd1) )
        {
        alert("What, you would just sit there in silence?");
        F.cd1.focus();
        }
    else 
    if ( IsEmpty(F.cd2) )
        {
        alert("You need more than one CD. What if the other one gets scratched?");
        F.cd2.focus();
        }
    else 
    if ( IsEmpty(F.cd3) )
        {
        alert("You need more than two CDs. What if the other two get scratched?");
        F.cd3.focus();
        }
    else 
	if ( IsEmpty(F.tvshow) )
        {
        alert("Don't you watch TV?");
        F.tvshow.focus();
        }
    else
    if ( IsEmpty(F.book) )
        {
        alert("Haven't read anything lately?");
        F.book.focus();
        }
    else 
	if ( IsEmpty(F.outrage) )
        {
        alert("Come on, tell us about your crazy antics.");
        F.outrage.focus();
        }
    else 
	if ( IsEmpty(F.important) )
        {
        alert("Now is your time to shine!");
        F.important.focus();
        }
    else 
	if ( IsEmpty(F.problems) )
        {
        alert("Aw come on, we said briefly...");
        F.problems.focus();
        }
    else 
	if ( IsEmpty(F.cartoon) )
        {
        alert("Everyone likes cartoons, don't they?");
        F.cartoon.focus();
        }
    else 
	if ( IsEmpty(F.element1) )
        {
        alert("We bet you can think of at least one.");
        F.element1.focus();
        }
    else 
	if ( IsEmpty(F.element2) )
        {
        alert("Just two more!");
        F.element2.focus();
        }
    else 
	if ( IsEmpty(F.element3) )
        {
        alert("Last one, you can do it!");
        F.element3.focus();
        }
    else 
	if ( IsEmpty(F.weak1) )
        {
        alert("Come on, we all have weaknesses.");
        F.weak1.focus();
        }
    else 
	if ( IsEmpty(F.weak2) )
        {
        alert("Some of us have more than one.");
        F.weak2.focus();
        }
    else 
	if ( IsEmpty(F.weak3) )
        {
        alert("Many people even have 3.");
        F.weak3.focus();
        }
    else 
	if ( IsEmpty(F.mistake) )
        {
        alert("Unfortunately, we have all made mistakes. Surely you can think of one.");
        F.mistake.focus();
        }
    else 
	if ( IsEmpty(F.people) )
        {
        alert("What do you like the most about meeting new people?");
        F.people.focus();
        }
    else 
	if ( IsEmpty(F.miscon) )
        {
        alert("We love secrets! Tell us what other people don't know about you.");
        F.miscon.focus();
        }
    else 
	if ( IsEmpty(F.surprised) )
        {
        alert("Surprise us! Tell us something about yourself.");
        F.surprised.focus();
        }
    else 
	if ( IsEmpty(F.web1) )
        {
        alert("Open up those bookmarks and find your favorite!");
        F.web1.focus();
        }
    else 
	if ( IsEmpty(F.web2) )
        {
        alert("Now tell us what your second favorite site is.");
        F.web2.focus();
        }
    else 
	if ( IsEmpty(F.web3) )
        {
        alert("And a third? Everyone has at least 3!");
        F.web3.focus();
        }
    else 
	if ( IsEmpty(F.bear) )
        {
        alert("Think about this one. There is a right answer, but the wrong one can be just as good.");
        F.bear.focus();
        }
    else
    
    for (i=0, n=F.smoker.length; i<n; i++) {
   		if (F.smoker[i].checked) {
      		var checkvalue = F.smoker[i].value;
      		break;
 	  	}
	}
	
 	if (checkvalue == " Yes" && IsEmpty(F.ifyeswhy) )
        {
        alert("No skipping this one. It's important to us. Besides, we know the answer is yes if you tried to bypass it so just be honest and let us know why. Thanks.");
        F.ifyeswhy.focus();
        }
	else
	if (checkvalue != " No" && checkvalue != " Yes")
	{
		alert("C'mon! Do you smoke or not?");
	}

    else
	 
   return( true );
    
    return( false );
}