arrCostPerDay      = new Array();
arrCostPerDay[1]  = 20;
arrCostPerDay[2]  = 25;
arrCostPerDay[3]  = 30;
arrCostPerDay[4]  = 35;
arrCostPerDay[5]  = 37;
arrCostPerDay[6]  = 40;
arrCostPerDay[7]  = 45;
arrCostPerDay[8]  = 48;
arrCostPerDay[9]  = 50;
arrCostPerDay[10] = 52;

arrCostPerDay[11] = 54;
arrCostPerDay[12] = 56;
arrCostPerDay[13] = 58;
arrCostPerDay[14] = 60;
arrCostPerDay[15] = 62;
arrCostPerDay[16] = 65;
arrCostPerDay[17] = 65;
arrCostPerDay[18] = 65;
arrCostPerDay[19] = 65;
arrCostPerDay[20] = 65;

arrCostPerDay[21] = 70;
arrCostPerDay[22] = 70;
arrCostPerDay[23] = 70;
arrCostPerDay[24] = 75;
arrCostPerDay[25] = 75;
arrCostPerDay[26] = 75;
arrCostPerDay[27] = 80;
arrCostPerDay[28] = 80;
arrCostPerDay[29] = 80;
arrCostPerDay[30] = 80;
arrCostPerDay[31] = 80;

floCostPerMonthDay  = 6;

arrCostPerMonth     = new Array();
arrCostPerMonth[1]  = 80;
arrCostPerMonth[2]  = 135;
arrCostPerMonth[3]  = 180;
arrCostPerMonth[4]  = 250;
arrCostPerMonth[5]  = 280;
arrCostPerMonth[6]  = 310;
arrCostPerMonth[7]  = 360;
arrCostPerMonth[8]  = 410;
arrCostPerMonth[9]  = 460;
arrCostPerMonth[10] = 510;
arrCostPerMonth[11] = 560;
arrCostPerMonth[12] = 600;
arrCostPerMonth[13] = 600;

arrVehicleType      = new Array();
arrVehicleType['car'] = 1;
arrVehicleType['van'] = 2;

arrDaysPerMonth     = new Array(31,28,31,30,31,30,31,31,30,31,30,31)

var floParkingCost    = 0;

function lUpdateCost()
{
	objDocument  = parent.document.quoteform;

	objStartDate = objDocument.dc1;
	strStartDate = objStartDate.value;

	objEndDate   = objDocument.dc2;
	strEndDate   = objEndDate.value;

	// If the user hasn't picked both dates yet its a wee bit hard to see if they are going outside of the range!
	if(strStartDate == 'dd/mm/yyyy' || strEndDate == 'dd/mm/yyyy')
	{
		Hide('parkingCost');
		return false;
	}

	arrStartDate  = strStartDate.split('/');

	strStartTime  = document.quoteform.departtime.value;
	intStartHours = parseInt(strStartTime.substring(0,2));
	if(strStartTime.substring(0,1) == '0')
	{
		intStartHours = parseInt(strStartTime.substring(1,2));
	}
	intStartMins = parseInt(strStartTime.substring(3));

	objStartDate = new Date();
	objStartDate.setFullYear(arrStartDate[2], arrStartDate[1]-1, arrStartDate[0]);
	objStartDate.setHours(intStartHours,intStartMins,0,0);
	floMSStart = objStartDate.getTime();

	arrEndDate    = strEndDate.split('/');

	strEndTime    = document.quoteform.returntime.value;
	intEndHours   = parseInt(strEndTime.substring(0,2));
	if(strEndTime.substring(0,1) == '0')
	{
		intEndHours = parseInt(strEndTime.substring(1,2));
	}
	intEndMins   = parseInt(strEndTime.substring(3));

	objEndDate = new Date();
	objEndDate.setFullYear(arrEndDate[2], arrEndDate[1]-1, arrEndDate[0]);
	objEndDate.setHours(intEndHours,intEndMins,0,0);
	floMSEnd   = objEndDate.getTime();

	// Sanity Check 1 - Come back AFTER we've left NOT before
	if(floMSEnd <= floMSStart)
	{
		objEndDate.value = 'dd/mm/yyyy';
		alert('Return date must come after departure date');
		//Hide('parkingCost');
		return false;
	}

	// Ensure that Start date is > now + 12 hours
	objDate  = new Date();
	floMSNow = objDate.getTime();
	floDifference = (floMSStart - floMSNow) / 3600000;
	if(floDifference < 12)
	{
		alert('If you want to book for the next 12 hours please call us 626 674 496');
		//Hide('parkingCost');
		return false;
	}

	intDays       = parseInt(document.notused.days.value);
	intMonths     = parseInt(document.notused.months.value);


	// Have we just spanned another day?
	if(((intEndHours * 60) + intEndMins) > ((intStartHours * 60) + intStartMins))
	{
		++intDays;
	}

	floCost = 0;
	if(intMonths > 0)
	{
		for (intCurrentMonth in arrCostPerMonth)
		{
			if(intCurrentMonth <= intMonths && arrCostPerMonth[intCurrentMonth] > 0)
			{
				floCost  = arrCostPerMonth[intCurrentMonth];
			}
		}
	}

	// We need to modify for months that are 7-11... by adding the number of days in our previous month(s) to it...
	if(arrCostPerMonth[intMonths] == 0)
	{
		if(intMonths == 1)
		{
			intDays += arrDaysPerMonth[11];
		}
		else
		{
			intDays += arrDaysPerMonth[intMonths-2];
		}
	}


	if(intDays > 0)
	{
		if(intMonths == 0)
		{
			floCost += arrCostPerDay[intDays];
		}
		else
		{
			floCost += intDays * floCostPerMonthDay;
		}
	}

	// Now check to see if the cost > advancing a month and use that instead
	for (intCurrentMonth in arrCostPerMonth)
	{
		if(intCurrentMonth > intMonths)
		{
			if(arrCostPerMonth[intCurrentMonth] < floCost && arrCostPerMonth[intCurrentMonth] > 0)
			{
				floCost = arrCostPerMonth[intCurrentMonth];
			}
		}
	}

	strVehicleType = document.quoteform.vehicle.value;
	floShowCost    = floCost * arrVehicleType[strVehicleType];

	/*
		Rounding
	*/
	floShowCost    = Math.ceil(parseInt(floShowCost*100)/100);

	document.quoteform.cost.value=floShowCost;
}

