function toggle(id, id2)
{
  var e1 = document.getElementById(id);
  var e2 = document.getElementById(id2);

  if (e1.style.display == 'block')
  {
    e1.style.display = 'none';
    e2.innerHTML = '+';
  }
  else
  {
    e1.style.display = 'block';
    e2.innerHTML = '-';
  }
}

function moreInfo(id)
{
  var e1 = document.getElementById('moreInfo' + id);
  var e2 = document.getElementById('toggle' + id);

  if (e1.style.display == 'block')
  {
    e1.style.display = 'none';
    e2.innerHTML = '+';
  }
  else
  {
    e1.style.display = 'block';
    e2.innerHTML = '-';
  }
}


  function hideShipping() 
 {
  document.getElementById('shipping_reg').style.display="none";
  document.getElementByName('shipping_billing_same').value=1;
 }

  function showShipping() 
 {
  document.getElementById('shipping_reg').style.display="block";
  document.getElementsByName('shipping_billing_same').value=0;
 }
 function vehicle_info()
 {
  document.getElementById('vehicle_info_div').style.display="block";
 }

function hideDiv(id) 
{ 
  var e = document.getElementById(id);
  e.style.display = 'none';
}

function showDiv(id) 
{ 
  var e = document.getElementById(id);
  e.style.display = 'block';
}


  function formValidator()
   {
// Make quick references to our fields
     var name = document.getElementByName('contact_name');
     var email = document.getElementById('email');
     var confirm_email = document.getElementById('confirm_email');
     var password = document.getElementById('password');
     var confirm_password = document.getElementById('confirm_password');
     var bill_name = document.getElementById('bill_name');
     var bill_address1 = document.getElementById('bill_address1');
     var bill_city = document.getElementById('bill_city');
     var bill_state = document.getElementById('bill_state');
     var bill_zipcode = document.getElementById('bill_zipcode');
     var bill_phone = document.getElementById('bill_phone');
     var shipping_reg = document.getElementById('shipping_reg');
     var ship_name = document.getElementById('ship_name');
     var ship_address1 = document.getElementById('ship_address1');
     var ship_city = document.getElementById('ship_city');
     var ship_state = document.getElementById('ship_state');
     var ship_zipcode = document.getElementById('ship_zipcode');
     // Check each input in the order that it appears in the form
     alert(document.getElementByName('contact_name').value);
     if(document.getElementByName('contact_name').value == " ")
      {
        alert("Please enter a valid email address");
        name.focus();
        return false;
      }

     if(emailValidator(email))
      {
        alert("Please enter a valid email address");
        email.focus();
        return false;
      }
     if(email.value != confirm_email.value)
      {
       alert("Email and confirm email do not match");
       confirm_email.focus();
       return false;
     }
    if(lengthRestriction(password, 6, 16))
     {
       alert("Password must be at least 6 characters long");
       password.focus();
       return false;
     }
    if(password.value != confirm_password.value)
    {
      alert("Password and confirm password do not match");
      confirm_password.focus();
      return false;
    }
    if(notEmpty(bill_name))
    {
      alert("Please enter a billing name");
      bill_name.focus();
      return false;
    }
   if(notEmpty(bill_address1))
    {
     alert("Please enter a valid billing address");
     bill_address1.focus();
     return false;
    }
   if(notEmpty(bill_city))
    {
     alert("Please enter a valid billing city");
     bill_city.focus();
     return false;
    }
   if(madeSelection(bill_state))
   {
      alert("Please enter a billing state");
      bill_state.focus();
      return false;
   }
   if(notEmpty(bill_zipcode))
   {
      alert("Please enter a valid billing Zip Code");
      bill_zipcode.focus();
      return false;
   }
   if(notEmpty(bill_phone))
    {
      alert("Please enter a valid billing phone");
      bill_phone.focus();
      return false;
    }
   if(shipping_reg.style.display == "block")
    {
       if(notEmpty(ship_name))
          {
             alert("Please enter a shipping name");
             ship_name.focus();
             return false;
          }
       if(notEmpty(ship_address1))
          {
              alert("Please enter a valid shipping address");
              ship_address1.focus();
              return false;
          }
       if(notEmpty(ship_city))
         {
           alert("Please enter a valid shipping city");
           ship_city.focus();
           return false;
         }
       if(madeSelection(ship_state))
         {
          alert("Please enter a shipping state");
          ship_state.focus();
          return false;
         }
       if(notEmpty(ship_zipcode))
         {
          alert("Please enter a valid shipping Zip Code");
          ship_zipcode.focus();
          return false;
         }
     return true;
   }
  else
  {
  return true;
  }

 }
 

  function paymentValidator()
  {
   var bill_type = document.getElementById('bill_type');
   var bill_account_number = document.getElementById('bill_account_number');
   var bill_account_additional = document.getElementById('bill_account_additional');
   var bill_bank_phone = document.getElementById('bill_bank_phone');

  if(bill_type.selectedIndex == 0) 
 { 
  alert("Please select a payment type");
  bill_type.focus();
  return false;
 }
 if(isNumeric(bill_account_number))
  {
  alert("Please enter a valid credit card number");
  bill_account_number.focus();
  return false;
 }
 if(isNumeric(bill_account_additional))
  {
  alert("Please enter a cvv code");
  bill_account_additional.focus();
  return false;
  }
 if(bill_bank_phone.value =="")
  {
  alert("Please enter a valid bank phone");
  bill_bank_phone.focus();
  return false;
  }
 else
 {
  return true;
 }
}
  function isNumeric(elem)
    {
        var numericExpression = /^[0-9]+$/;
        if(elem.value.match(numericExpression))
          {
                return false;
          }
        else
          {
                return true;
          }
    }


