function VacanciesView(id, model) {	
	this.htmlid = id;	
	this.model = model;
	this.tableSorter =""


	this.tableSorter 
	
	this.renderResults();
} 

VacanciesView.prototype.renderResults = function(){
	var mainObject = this;
	var results = this.model.getVacancies();
	
	var resultsFilters = this.model.getFilters();
	var searchModel = this.model.searchmodel;
	var presearchmodel = this.model.presearchmodel;

	var htmlid = this.htmlid;
	var filterids =  this.model.filterids;
	var termsFound =[];
	var paragraph;
	var resultsFoundText
	var logoType;
	//Empty the html container
	$(htmlid).empty();
	
	//Make table if results > 0
 	if(results.vacancies.length > 0){
		$(htmlid).css("display","block");
		$("#noresults").css("display","none");
		var header =  $("<h2></h2>").attr('class','').html(yourSearchResult);
		$(htmlid).append(header)
			
		//Display search & filter terms
		$.each(resultsFilters.filters, function(index, filter){
			$.each(filter.options, function(index, filteroptie){
				//console.log(filteroptie.name)
				if (presearchmodel.filterOptionExists(filter.filterid,filteroptie.id,false)){
					termsFound.push(" "+filteroptie.name)
				}
				if (searchModel.filterOptionExists(filter.filterid,filteroptie.id,true)){
					termsFound.push(" "+filteroptie.name)
				}
			});
		});

		//resultsFoundText = mainObject.model.LanguageSettings[1].resultsFound[mainObject.model.language]
		resultsFoundText = resultsFound;		

		paragraph =  $("<p></p>").attr('class','').html(results.vacancies.length + resultsFoundText);
		if(termsFound.length > 0){
			 //resultsFoundText = mainObject.model.LanguageSettings[2].resultsFoundFor[mainObject.model.language];
			resultsFoundText = resultsFoundFor;
			paragraph =  $("<p></p>").attr('class','').html(results.vacancies.length+" "+ resultsFoundText +"<strong>"+termsFound+"</strong>");
		}
		
		$(htmlid).append(paragraph)

		//generate table results
		var tableResult =  $("<table></table>").attr('class','searchresult');
		$(htmlid).append(tableResult)
		//var tableHeaders = mainObject.model.LanguageSettings[3].tableHeaders[mainObject.model.language];
		$(tableResult).append(tableHeaders);
		
		$.each(results.vacancies, function(index, value){
			

			if(value.features.bedrijfsonderdeellogo == "ING" ){
				logoType ="ing";
			}
			else if(value.features.bedrijfsonderdeellogo =="RVS"){
				logoType ="rvs";
			}
			else if(value.features.bedrijfsonderdeellogo =="NN"){
				logoType ="nn";
			}
			else{
				logoType = "";
			}
			var vacancyDetaillink =  mainObject.model.linkSettings[1].vacancyDetaillink;

			if(gup("htmlid")!=''){
				
			    var seoParams = '&htmlid=' + gup("htmlid");
				
				if(gup("location") != '' ){
					seoParams = seoParams + "&location=" + gup("location");
				}
				
				if(gup("expertise") != ''){
					seoParams = seoParams + "&expertise=" + gup("expertise");
				}
					
				$(tableResult).append("<tr><td>"+value.jobid+"</td><td><a href='"+ vacancyDetaillink + "vacancyId=" + value.jobid+ "&lang=" + mainObject.model.language + seoParams+"'>"+value.jobtitle +"</a></td><td>"+value.date+"</td><td>"+value.features.location1 + " "+value.features.location2+"</td><td class='logo " + logoType + "'>"+value.features.bedrijfsonderdeellogo+"</td></tr>");
			}else{
				$(tableResult).append("<tr><td>"+value.jobid+"</td><td><a href='"+ vacancyDetaillink + "vacancyId=" + value.jobid+ "&lang=" + mainObject.model.language + "'>"+value.jobtitle +"</a></td><td>"+value.date+"</td><td>"+value.features.location1 + " "+value.features.location2+"</td><td class='logo " + logoType + "'>"+value.features.bedrijfsonderdeellogo+"</td></tr>");
			}
		});
		//show pager if results > 30
		if(results.vacancies.length > 30){
			//console.log("draw pager")
			//var pagerText = mainObject.model.LanguageSettings[4].pagerText[mainObject.model.language];
			var pager = $("<div></div>").attr('id','pager').attr('class','pager').html(pagerText)
			$(htmlid).append(pager)
		}


		//Apply the table sorter to table
		this.tableSorter = new VacancyTablesorter(tableResult,this.model);
		this.tableSorter.renderResults();
	
	}
	else {

		$(htmlid).css("display","none");
		$("#noresults").css("display","block");
		
	}

}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}