function Frontend() {
	
	this.init = function () {
		this.initFilters();
		this.initPriceFilters();
		this.initOutlinks();
		
	}
	
	this.initOutlinks = function() {
		
		$('a.outlink').click( function() {
			var iProduct = $(this).attr('productid');
			$.get(LINKROOT+'/do/product/click/'+iProduct);
		});
		
	}
	
	this.initFilters = function() {
		$('input.filter').change(this.applyFilters);
		iActiveCount=0;
		oChecked = false;
		oFirst = false;
		$('input.filter').each( function() {
			bChecked = $(this).attr('checked');
			if(bChecked) {
				iActiveCount++;
				oChecked = this;
			}  else if(!oFirst) {
				oFirst = this;
			}
		});
		
		if(iActiveCount == 1) {
			$(oChecked).attr({disabled: true});
		} else if(iActiveCount == 0 && oFirst) {
			oFirst.click();
		}
		
	}
	
	this.deletedProduct = function(sUrl) {
		if(confirm("Deze reis is niet langer beschikbaar, klik op OK om soortgelijke vakanties te bekijken")) {
			document.location.replace(sUrl);
		}
	}
	
	this.initPriceFilters = function() {
		$('a.pricefilter').click(this.applyPriceFilter);
	}
	
	
	this.applyPriceFilter = function() {
		
		aParts = $(this).attr('id').split('_');
		
		$.get(LINKROOT+'/do/product/setpricefilter/'+aParts[1], function() {
			$('#results').load(URL+'?page=1 #results', function() {
				oFrontend = new Frontend();
				oFrontend.init();
				statistic('listviews');
			});
		});
				
	}
	
	/**
	 * Apply (category) filters
	 */
	this.applyFilters = function() {
		
		var oFilters = new Object();
		iActiveCount = 0;
		
		$('input.filter').each( function() {
			bChecked = $(this).attr('checked');
			if(bChecked) {
				iActiveCount++;
			} 
			oFilters['filter_'+$(this).attr('value')] = bChecked;
		});
		
		if(iActiveCount == 0) {
			return false;			
		}
		
		sFilters = $.param(oFilters);
		$.get(LINKROOT+'/do/product/setfilters/?'+sFilters, function() {
			$('#results').load(URL+'?page=1 #results', function() {
				oFrontend = new Frontend();
				oFrontend.init();
				statistic('listviews');
			});
		});

	}
}