function ProcessJourneyCost(form) { var result = JourneyCost(form.distance.value, form.mpg.value, form.fuel.value) if (!isNaN(result)) { document.getElementById('JourneyCostResult').innerHTML = "
The data indicates that this journey would cost you around " + result.toFixed(2) +" in the local currency
"; var doublecost = (result*2); document.getElementById('doublecost').innerHTML = "The two way round trip cost in fuel for this journey would be around " + doublecost.toFixed(2) +" in the local currency for this place
"; } else { document.getElementById('JourneyCostResult').innerHTML = "Please enter numerical values!"; } } var Lig = 4.54609188; var Gil = 0.219969157; var Mik = 0.621371192; var Kim = 1.609344; function Gallons(FuelCost, Spend) { try { var Litres = (Spend/(FuelCost/100)); return (Litres * Gil); } catch (Error) { return -1; } } function RealMPG(FuelCost, Spend, Miles) { try { var g = Gallons(FuelCost, Spend); return (Miles/g); } catch (Error) { return -1; } } function RequiredFuel(Miles, MPG) { try { return (Miles/MPG); } catch (Error) { return -1; } } function JourneyCost(Miles, MPG, FuelCost) { try { var GallonsUsed; GallonsUsed = (Miles/MPG); return (((GallonsUsed* Lig) * FuelCost)/100); } catch (Error) { return -1; } } function ToLitresPer100KM(MPG) { try { return (100/((MPG*Kim)*Gil)); } catch (Error) { return Error; } } function ToMPG(LitresPer100KM) { try { return ((100/(LitresPer100KM * Gil)) * Mik); } catch (Error) { return -1; } } function ToMiles(KM) { try { return (KM * Mik); } catch (Error) { return -1; } } function ToKM(Miles) { try { return (Miles * Kim); } catch (Error) { return -1; } } function ahah(url, target) { document.getElementById(target).innerHTML = '
';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target);};
req.open("GET", url, true);
req.send("");
}
}
function ahahDone(url, target) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
}
}
}
function load(name, div) {
ahah(name,div);
return false;
}
function ut(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
/* if(ajaxRequest.readyState == 4){
document.form0.time.value = ajaxRequest.responseText;
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
*/
}
var distance = document.getElementById('drivingboxfuel').value;
var mpg = document.getElementById('mpg').value;
var price = document.getElementById('fuel').value;
var jc = $('#JourneyCostResult').text();
var gtw = $('#FuelRequired').text();
var queryString = "?dd=" + distance + "&mpg=" + mpg + "&price="+ price + "&datacalc=" + jc +" "+ gtw +"&ref=https://www.distantias.com/distance-to.php";
ajaxRequest.open("GET", "fuelview.php" + queryString, true);
ajaxRequest.send(null);
}
//-->