function get_ajax() {
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();

    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

    }



  return xmlhttp;
}



function send_tyre_width() {

  var ajax = get_ajax();
  ajax.onreadystatechange= function () {
    if (ajax.readyState==4)
    {
      // process whatever has been sent back here
      $('#tyre_profile').html(ajax.responseText);
      $('#tyre_profile').attr('disabled','');
      $('#tyre_size').attr('disabled','disabled');
      $('#tyre_size').html('<option>PLEASE SELECT PROFILE</option>');
      $('#tyre_speed').attr('disabled','disabled');
      $('#tyre_speed').html('<option>PLEASE SELECT PROFILE</option>');
      
       
    }
  };
  if ($('#tyre_width').attr('value') == "") {
    return;
  }
  var url = "/_template/tyres/tyre_width.php";
  var params = "width=" + $('#tyre_width').attr('value');
  ajax.open("POST",url,true);
  //Send the proper header information along with the request
  ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax.setRequestHeader("Content-length", params.length);
  ajax.setRequestHeader("Connection", "close");

  ajax.send(params);
}

function send_tyre_profile() {

  var ajax = get_ajax();
  ajax.onreadystatechange= function () {
    if (ajax.readyState==4)
    {
      // process whatever has been sent back here
      $('#tyre_size').html(ajax.responseText);
      $('#tyre_size').attr('disabled','');
      $('#tyre_speed').attr('disabled','disabled');
      $('#tyre_speed').html('<option>PLEASE SELECT SIZE</option>');
      $('#tyre_speed').attr('disabled','disabled');
      $('#tyre_speed').html('<option>PLEASE SELECT SIZE</option>');
      
       
    }
  };
  if ($('#tyre_profile').attr('value') == "") {
    return;
  }
  var url = "/_template/tyres/tyre_profile.php";
  var params = "width=" + $('#tyre_width').attr('value') + "&profile=" + $('#tyre_profile').attr('value');
  ajax.open("POST",url,true);
  //Send the proper header information along with the request
  ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax.setRequestHeader("Content-length", params.length);
  ajax.setRequestHeader("Connection", "close");

  ajax.send(params);
}

function send_tyre_size() {

  var ajax = get_ajax();
  ajax.onreadystatechange= function () {
    if (ajax.readyState==4)
    {
      // process whatever has been sent back here
      $('#tyre_speed').html(ajax.responseText);
      $('#tyre_speed').attr('disabled','');

    }
  };
  if ($('#tyre_size').attr('value') == "") {
    return;
  }
  var url = "/_template/tyres/tyre_size.php";
  var params = "width=" + $('#tyre_width').attr('value') + "&profile=" + $('#tyre_profile').attr('value') + "&size=" + $('#tyre_size').attr('value');
  ajax.open("POST",url,true);
  //Send the proper header information along with the request
  ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax.setRequestHeader("Content-length", params.length);
  ajax.setRequestHeader("Connection", "close");

  ajax.send(params);
}


function send_landrover_make() {

  var ajax = get_ajax();
  ajax.onreadystatechange= function () {
    if (ajax.readyState==4)
    {
      // process whatever has been sent back here
      $('#model_landrover').html(ajax.responseText);
      $('#model_landrover').attr('disabled','');

    }
  };
  if ($('#make_landrover').attr('value') == "") {
    $('#model_landrover').attr('disabled','disabled');
    $('#model_landrover').html('<option value="">Please select make</option>');
    return;
  }
  var url = "/_template/tyres/vehicle_make.php";
  var params = "make=" + $('#make_landrover').attr('value');
  ajax.open("POST",url,true);
  //Send the proper header information along with the request
  ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax.setRequestHeader("Content-length", params.length);
  ajax.setRequestHeader("Connection", "close");

  ajax.send(params);
}

