$(document).ready(function(){
	$('#cwrap').hide("fast");
	$('#swrap').hide("fast");

	function getValue(id){
		var i;
		$('#'+id).find('option').each(function(){if(this.selected) i = $(this).val();});
		return i;
	}

	// Get products
	$.post('http://www.blvh.co.uk/quote_calculator/vehicle.php',{id:1},function(rsp){
		// Remove options first;
		$('#vehicle').removeOption('*');

		// Add new options
		eval('var members = {'+rsp+'}');
		$('#vehicle').addOption(members,false);
	});

	// Get colours for body colours
	$('#vehicle').bind('change',function(){
		$.post('http://www.blvh.co.uk/quote_calculator/destination.php',{id: getValue('vehicle')},function(rsp){
			// Remove options first;
			$('#destination').removeOption('*');

			// Add new options
			eval('var members = {'+rsp+'}');
			$('#destination').addOption(members,false);
		});
		$('#cwrap').show("normal");
	});

	// Get sizes for trim colours
	$('#destination').bind('change',function(){
		$.post('http://www.blvh.co.uk/quote_calculator/days.php',{id: getValue('destination')},function(rsp){
			// Remove options first;
			$('#days').removeOption('*');

			// Add new options
			eval('var members = {'+rsp+'}');
			$('#days').addOption(members,false);
		});
		$('#swrap').show("normal");
	});
});