function checkAllInputs(obj){
    obj_from = document.getElementById('origin').value;
    obj_to = document.getElementById('dest').value;
    obj_flight = document.getElementById('flt').value;
    obj_class = document.getElementById('cls').value;
    
    
    
    JsHttpRequest.query('ajax/mile.php',{obj_from: obj_from, obj_to:obj_to, obj_flight:obj_flight, obj_class:obj_class}, 
    function(result, errors) {calc(result);}, true);
}  

function calc(result){
	if(!result)
		return false;
    
    obj_from = document.getElementById('origin');
    obj_to = document.getElementById('dest');
    obj_flight = document.getElementById('flt');
    obj_class = document.getElementById('cls');
    obj_miles = document.getElementById('miles');

    while(obj_to.options.length > 1) obj_to.options[1] = null;
    while(obj_flight.options.length > 1) obj_flight.options[1] = null;
    while(obj_class.options.length > 1) obj_class.options[1] = null;
    
    if (result['changeTo']){  
      i=1;
      for (var key in result['To']){
        obj_to.options[i] = new Option();
        obj_to.options[i].text = result['To'][key];
        obj_to.options[i].value = key;
        i++;
      }
      obj_to.selectedIndex = result['changeToSelected'];
    }  
    if (result['changeFlight']){  
      i=1;
      for (var key in result['Flight']){
        obj_flight.options[i] = new Option();
        obj_flight.options[i].text = result['Flight'][key];
        obj_flight.options[i].value = key;
        i++;
      }
      obj_flight.selectedIndex = result['changeFlightSelected'];
    }  
    if (result['changeClass']){  
      i=1;
      for (var key in result['Class']){
        obj_class.options[i] = new Option();
        obj_class.options[i].text = result['Class'][key];
        obj_class.options[i].value = key;
        i++;
      }
      obj_class.selectedIndex = result['changeClassSelected'];
    }  
    if (result['mile'] != ''){
      obj_miles.innerHTML = result['mile'];
    }
}

function reportError(request){
		alert('Ajax do not supported...');
}

