function LDCar(id, prices) {
	this.id = id;
	this.prices = prices;
	this.getPrice = function(ndays) {
		for (var i=0;i<this.prices.length;i++) {
			if (ndays >= this.prices[i][0] && ndays <= this.prices[i][1]) {
				return ndays * this.prices[i][2];
			}
		}
		return 0;
	}
}

function calcprice() {
	var car = document.getElementById("voiture");
	var startdate = document.getElementById("dateRemise");
	var enddate = document.getElementById("dateRetour");
	if (voiture.value.length > 0 && startdate.value.length > 0 && enddate.value.length > 0) {
		var sdparts = startdate.value.split("/");
		var sd = new Date(parseInt(sdparts[2]), parseInt(sdparts[1])-1, parseInt(sdparts[0]));
		var edparts = enddate.value.split("/");
		var ed = new Date(parseInt(edparts[2]), parseInt(edparts[1])-1, parseInt(edparts[0]));
		var ndays = parseInt((ed.getTime()-sd.getTime())/86400000);
		var objCar = null;
		for (var i=0;i<arrCars.length;i++) {
			if (arrCars[i].id == car.value) {
				objCar = arrCars[i];
				break;
			}
		}
		if (objCar != null) {
			document.getElementById("cprice").innerHTML = "" + objCar.getPrice(ndays) + " &euro;";
		}
	}
}
Calendar.setup(
{
inputField : "dateRemise", // ID of the input field
ifFormat : "%d/%m/%Y" // the date format
//button : "trigger" // ID of the button
}
);
Calendar.setup(
{
inputField : "dateRetour", // ID of the input field
ifFormat : "%d/%m/%Y" // the date format
//button : "trigger" // ID of the button
}
);
var curdate = new Date();
document.getElementById("dateRemise").value = curdate.getDate() + "/" + (curdate.getMonth() + 1) + "/" + curdate.getFullYear();
curdate.setTime(curdate.getTime()+640800000);
document.getElementById("dateRetour").value = curdate.getDate() + "/" + (curdate.getMonth() + 1) + "/" + curdate.getFullYear();
