function SearchView( model) {	
	this.model = model;
	this.totalVacancies;
	this.init();
} 

SearchView.prototype.init = function(){
 	var mainObject = this
	var selectoption

	$.each(this.model.allFilters.filters, function(index, filter){
		
		var selectContainerId = "#" + filter.filterid;
		//var selectToFill = $("select", $(selectContainerId));
		$(selectContainerId).html("");
		if(filter.filterid =="expertise" || filter.filterid =="location"  ){
			//add label name
			$(selectContainerId).prepend($("<span></span>").html(filter.name));
			//add the select
			var selectToFill = $("<select></select>").attr("class","filterselect")
			$(selectContainerId).append(selectToFill);
			//add the options
			$.each(filter.options, function(index, option){
			 	selectoption =  $("<option></option>").attr('value',filter.filterid + "_"+option.id).html(option.name);
				$(selectToFill).append(selectoption)
			});
			//add the empty option
			//var selectDefaultOption = mainObject.model.LanguageSettings[0].selectDefaultOption[mainObject.model.language]
			$(selectToFill).prepend("<option value='"+filter.filterid+"_' selected='selected'>"+selectDefaultOption+"</option>");
			$(selectToFill)[0].options[0].selected = true
		}
	});
	this.totalVacancies = this.model.getVacancies().vacancies.length;
	this.renderResults();
}

SearchView.prototype.renderResults = function(){
	
	var amountVacancies = formatToString(this.model.presearchids.length);

	$('#foundvacancies').text(amountVacancies);
	$('#totalvacancies').text(formatToString(this.totalVacancies));
	
	function formatToString(nr){
		var numberString = nr.toString();
		if(numberString.length==1){
			numberString = "000" + numberString;
		}
		else if(numberString.length==2){
			numberString ="00" + numberString;
		}
		else if(numberString.length==3){
			numberString = "0" + numberString;
		}

		
		return numberString;
	}
}


