$(document).ready(function(){
	
	$("#searchBilinfo").click(function(){
			$.cookie("department", $("#department").val());
			$.cookie("type", $("#type").val());
			$.cookie("price_min", $("#price_min").val());
			$.cookie("price_max", $("#price_max").val());
			$.cookie("models", $("#models").val());
			$.cookie("brands", $("#brands").val());
	});
	
	if($.cookie("department")) $("#department").val($.cookie("department"));
	if($.cookie("type")) $("#type").val($.cookie("type"));
	if($.cookie("price_min")) $("#price_min").val($.cookie("price_min"));
	if($.cookie("price_max")) $("#price_max").val($.cookie("price_max"));
	if($.cookie("models")) $("#models").val($.cookie("models"));
	if($.cookie("brands")) $("#brands").val($.cookie("brands"));
});

function populateBrands(){
	for(i = 0; i < brands.length; i++){
		document.getElementById('brands').options[document.getElementById('brands').length] = new Option(brands[i],brands[i]);
	}
}


function populateModels(){
	
	//clear
	document.getElementById('models').options.length = 0;
	document.getElementById('models').options[0] = new Option('Alle','*');
	
	//add new
	//for(index in models){
	for(index=0;index<models.length;index++){
		var mini = models[index].split('___');

		if(mini[0] == document.getElementById('brands').options[document.getElementById('brands').selectedIndex].value)
			document.getElementById('models').options[document.getElementById('models').length] = new Option(mini[1],mini[1]);
	
	}
}

