function loadYears(year, make, model)
{
	
	new Ajax.Request('./service.php?query=years',
	{
		method:'get',
		onSuccess: function(transport,json)
		{
			if(json.status == 'OK')
			{				
				var select = document.getElementById('year');
				var option = document.createElement('option');
				option.value = 0;
				option.text = 'Please select';
				try 
				{
					select.add(option, null); // standards compliant; doesn't work in IE
				}
				catch(ex) 
				{
					select.add(option, select.selectedIndex); // IE only
				}		
				for(i = 0; i < json.data.length; i++)
				{
					option = document.createElement('option');
					option.value = json.data[i];
					option.text = json.data[i];
					try 
					{
						select.add(option, null); // standards compliant; doesn't work in IE
					}
					catch(ex) 
					{
						select.add(option, select.selectedIndex); // IE only
					}
					if(year == json.data[i])
					{
						select.selectedIndex = i + 1;
					}
				}
			}
			else
			{
				alert(json.error);
			}
		},
		onFailure: function()
		{
			alert('Something went wrong...')
		}
	});
	if(make && year)
	{
		loadMakes(year,make);
	}
	if(model && make && year)
	{
		loadModels(make,year,model);
	}
}
function loadMakes(year, make)
{
	var select = document.getElementById('make');
	select.options.length = 0;
	select = document.getElementById('model');
	select.options.length = 0;
	new Ajax.Request('./service.php?query=makes&year=' + year,
	{
		method:'get',
		onSuccess: function(transport,json)
		{
			if(json.status == 'OK')
			{
				var select = document.getElementById('make');
				var option = document.createElement('option');
				option.value = 0;
				option.text = 'Please select';
				try 
				{
					select.add(option, null); // standards compliant; doesn't work in IE
				}
				catch(ex) 
				{
					select.add(option, select.selectedIndex); // IE only
				}
				for(i = 0; i < json.data.length; i++)
				{
					option = document.createElement('option');
					option.value = json.data[i];
					option.text = json.data[i];
					try 
					{
						select.add(option, null); // standards compliant; doesn't work in IE
					}
					catch(ex) 
					{
						select.add(option, select.selectedIndex); // IE only
					}
					if(make == json.data[i])
					{
						select.selectedIndex = i + 1;
					}
				}
			}
			else
			{
				alert(json.error);
			}
		},
		onFailure: function()
		{
			alert('Something went wrong...')
		}
	});
}
function loadModels(make, year, model)
{
	var select = document.getElementById('model');
	select.options.length = 0;
	new Ajax.Request('./service.php?query=models&year=' + year + '&make=' + make,
	{
		method:'get',
		onSuccess: function(transport,json)
		{
			if(json.status == 'OK')
			{
				var select = document.getElementById('model');
				var option = document.createElement('option');
				option.value = 0;
				option.text = 'Please select';
				try 
				{
					select.add(option, null); // standards compliant; doesn't work in IE
				}
				catch(ex) 
				{
					select.add(option, select.selectedIndex); // IE only
				}
				for(i = 0; i < json.data.length; i++)
				{
					option = document.createElement('option');
					option.value = json.data[i];
					option.text = json.data[i];
					try 
					{
						select.add(option, null); // standards compliant; doesn't work in IE
					}
					catch(ex) 
					{
						select.add(option, select.selectedIndex); // IE only
					}
					if(model == json.data[i])
					{
						select.selectedIndex = i + 1;
					}
				}
			}
			else
			{
				alert(json.error);
			}
		},
		onFailure: function()
		{
			alert('Something went wrong...')
		}
	});
}
function showHideDays(value)
{
    var days = document.getElementById('daysDriven');
    var distance = document.getElementById('distanceDriven');
    if(value == 'Pleasure')
    {
        days.style.display = 'none';
        distance.style.display = 'none';
    }
    else
    {
        days.style.display = 'block';
        distance.style.display = 'block';
    }
}

function showHideYears(value)
{
    var years = document.getElementById('yearsWithEmployer');
    if(value == 58)
    {
        years.style.display = 'none';
    }
    else
    {
        years.style.display = 'block';
    }
}



  