function AdvancedSearch()
{
	var self = this;

	this.init = function()
	{
		$('#loader-wrap').css('opacity', 0.7);
		self.hideLoader();
	}

	this.showLoader = function()
	{
		$('#loader-wrap').css('height', $(document).height() - 300 );
		$('#loader')
			.css('opactiy', 0)
			.show()
			.animate({opacity: 1}, 300);
	}

	this.hideLoader = function()
	{
		$('#loader').animate({opacity: 0}, 600, function(){ $(this).hide() });
	}

	this.updateResults = function()
	{
		if ($.browser.msie || 1 == 1) {
			return;
		}

		self.showLoader();
		$.get("/index?ajax=1&zoek=1&", $("#advanced-search").serialize(), function(data){
			$('#car-overview-inner').html(data);
			self.hideLoader();
		}, 'html');
	}

	this.updateModels = function(brand, dealerId, model)
	{

		var url = '/default/index/model';
		if ( brand )
			url += '/id/' + brand;
		if ( dealerId )
			url += '/dealer/' + dealerId;


	    $('.techtwo-debug-logs').append('<pre>Updating models:<br/>'+"\t" + url + '</pre>');

		$.post(url,{},function(data){

			var output = '<option value="">Alle</option>';

			$.each(data, function(){
			    var selected = ( model == this.name ) ? ' selected="selected"' : '';
				output += '<option value="' + this.name + '"' + selected + '>' + this.name + '</option>';
			});
			$('#model').html(output);

		}, 'json');

	}

	this.updateMerken = function(dealerId, brand)
	{

	    var url = '/default/index/merk/dealer/' + dealerId;

	    $('.techtwo-debug-logs').append('- <pre>Updating brands:<br/>'+"\t" + dealerId + '</pre>');

		$.post(url,{},function(data){

			var output = '<option value="">Alle</option>';

			$.each(data, function(){
			    var selected = ( brand == this ) ? ' selected="selected"' : '';
				output += '<option value="' + this + '"' + selected + '>' + this + '</option>';
			});
			$('#merk').html(output);

		}, 'json');

	}

	this.init();
}