function validateField(namefield, len) {
    if (namefield.length < len) {
        return false;
    } else {
        return true;
    }
}

function validateEmail(email) {
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return false;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function areFreeTrialFieldsComplete() {
	//if (passwd == 'bob') {
	//    return true;
	//}
	//alert(destination_form)
	//alert("Changes cannot be submitted!  Please check that all pertinent fields have been filled out correctly and then re-submit the form.");
	//return false;
    var error_text = '';
    var error_count = 0;
    var thisform = document.forms['freetrial'];

    //Check firstname is okay
    if (!validateField(thisform.free_trial_firstname.value, 2)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'First Name';
    }

    //Check lastname valid
    if (!validateField(thisform.free_trial_lastname.value, 2)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'Last Name';
    }

    //Check address valid
    if (!validateField(thisform.free_trial_address.value, 6)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'Street Address';
    }

    //Check city valid
    if (!validateField(thisform.free_trial_city.value, 2)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'City';
    }

    //Check state selected
    if (!validateField(thisform.free_trial_state.value, 2)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'State';
    }

    //Check postal code valid
    if (!validateField(thisform.free_trial_postal.value, 5)) {
        error_count++;
        if (error_text.length >0) {
            error_text += '\n';
        };
        error_text += 'Zip/Postal Code';
    }

    //Check email is okay
    if (!validateEmail(thisform.free_trial_email.value)) {
        error_count++;
        if (error_text.length > 0) {
            error_text += '\n';
        }
        error_text += 'E-Mail Address';
    }

    if (error_count > 0) {
        var alert_text = '';
        alert_text += 'Your form cannot be submitted due to the following field(s) being either left blank or filled out incorrectly: \n\n';
        alert_text += error_text;
        alert(alert_text);
        return false;
    } else {
        thisform.submit_token.value = 'valid';
        return true;
    }
}