function hideShowAddress()
{
  var selection = document.getElementById( "response" );
  var address = document.getElementById( "address" );
  var citystate = document.getElementById( "citystate" );
  if( selection.options[selection.selectedIndex].value == "Regular Mail" )
  {
    address.disabled = false;
    citystate.disabled = true;
  }
  else
  {
    address.disabled = true;
    citystate.disabled = false;
  }
}

function validate()
{
  var f = document.forms[0];
  var missing = new Array();
  var selection = document.getElementById( "response" );
  var address = document.getElementById( "address" );
  
  if( f.firstname.value == '' )
  {
    missing[missing.length] = "Name";
  }
  if( selection.options[selection.selectedIndex].value == "Regular Mail" )
  {
    if( f.address.value == '' )
    {
      missing[missing.length] = "Address";
    }
    f.citystate.value = "";
  }
  else
  {
    f.address.value = "";
  }
  if( f.email.value == '' )
  {
    missing[missing.length] = "Email Address";
  }
  if( f.manufac.value == '' )
  {
    missing[missing.length] = "Manufacturer";
  }
  if( f.model.value == '' )
  {
    missing[missing.length] = "Model";
  }
  if( f.description.value == '' )
  {
    missing[missing.length] = "Problem Description";
  }

  if( missing.length > 0 )
  {
    var errormsg = "Please enter the following fields:\n";
    for( var i in missing )
    {
      errormsg += "  " + missing[i];
      errormsg += "\n";
    }
    alert( errormsg );
    return false;
  }

  var re = /^\D*1?\D*(\d{3})?\D*(\d{3})\D*(\d{4})\D*(\d*)$/;
  if( f.phone.value != '' && !(f.phone.value.match( re ) ) )
  {
    alert( "Please enter a valid phone number" );
    return false;
  }
  if( f.fax.value != '' && !(f.fax.value.match( re ) ) )
  {
    alert( "Please enter a valid fax number" );
    return false;
  }

  return true;
}
