$('select#make').change(function(e) {
	var make = $(this).val();
	var data = { 'mode' : 'models', 'make' : make, 'hash' : hash };		

	$.getJSON (ajax_request_url, data, function(data, textStatus) {
		if (!data.errors)
		{ 
			populateSelect('model', data.data); 
		}
	});
});

$('select#category').change(function(e) {
	var category = $(this).val();
	var data = { 'mode' : 'makes', 'category' : category, 'hash' : hash};

	$.getJSON (ajax_request_url, data, function(data, textStatus) {
		if (!data.errors)
		{ 
			populateSelect('make', data.data);
			//changed the makes, so clear the models
			populateSelect('model', {'' : 'Please Select'}); 
		}
	});
});

function populateSelect(id, options)
{		
	var select = document.getElementById(id);
	select.options.length = 0;
	for (var key in options)
	{
		var option = new Option(options[key], key); 		
		select.options[select.options.length] = option;		
	}
	
}



//when user clicks on the link we want to highlight the form header so they know
//what's up
$('a.information_request_link').click(function(e) {

	var url = $(this).attr('href');
	popup (url, 'information_request_window');
	return false;

});

$('a.testdrive_link').click(function(e) {
	var url = $(this).attr('href');
	popup (url, 'testdrive_booking_window', 550, 600, 'yes');
	return false;
});

