/**
 * Short description for file
 * 
 * @author		Tajs Seelen
 * 
 * Optional parameters:
 * @category		Googlemaps
  * @version			1.0
 */

var GMapFilter = function()
{

	var _container; // container waar alle filter fields instaan
	var _filters = new Array();

	/**
	 * function _register
	 * register de container en de daarin staande filtervelden
	 */
	this._register = function(s)
	{
		this._container = s;
		$("#"+this._container+" li.filterProperty").hover(
			function(){
				$(this).addClass("over");
				$("#propertyLabel").html($(this).find("img").attr("alt"));
			},
			function(){
				$(this).removeClass("over");
				$("#propertyLabel").html("");
		});

		$("#"+this._container+" li.filterProperty").bind("click", {gf:this}, function(e){
			xajax_xajax_filter_toggle('property', $(this).find("input").val());
			if (!$(this).find("input").attr('checked')) {
				$(this).find("input").attr('checked', 'checked');
				$(this).addClass("active");

			} else {
				$(this).find("input").removeAttr('checked');
				$(this).removeClass("active");

			}
			
			e.data.gf._filterMarkers("property");
		});

		$('#'+this._container+' input.province').bind("click", {gf:this}, function(e) {
			xajax_xajax_filter_toggle('province', this.value);
			e.data.gf._filterMarkers("province");
		});

	}
	
	this._filterMarkers = function()
	{

		var mode;

		if ($("#"+this._container+" input.province:checked").length > 0) {
			$("#"+this._container+" input.province").each(function(i){
				if (this.checked) {
					toggleProvince(this.value, 'on');

				} else {
					toggleProvince(this.value, 'off');

				}

			});
		} else {
			$("#"+this._container+" input.province").each(function(i){
				toggleProvince(this.value, 'ghost');
				mode = 'ghost';
				
			});
		}

		var l_aProperties = new Array();
		$("#"+this._container+" input.property:checked").each(function(i){
			l_aProperties.push(this.value);
			
	  });
		
		if (l_aProperties.length > 0)
			toggleProperties(l_aProperties, mode);
			
	}
}
var gf = new GMapFilter;
