tx_xanlitegmaps_productsFilter = {
	ref: null,
	config: null,
	origPoiListURL: "",
	orig_makeMarker: null,
	productId: 0,
	
	init: function(){
		if(jQuery("#"+this.ref.mapId+" #tx-xanlitegmaps-products").length > 0) {
			var mod = this;		
			this.getProductId();
					
			jQuery("#"+this.ref.mapId+" #tx-xanlitegmaps-products").change(function(){
				mod.getProductId();
				mod.ref.addMarkersToManager();
			});
			
			jQuery.extend(this.ref, {
				tx_xanlitegmaps_productsFilter_MakeMarker: this.ref.makeMarker,
				makeMarker: function(node){
					if(this.modules.tx_xanlitegmaps_productsFilter.checkMarker(node)) {
						return this.tx_xanlitegmaps_productsFilter_MakeMarker(node);
					} else return null;
				}
			});
		}
	},

	start: function(){
	},
	
	getProductId: function(){
		this.productId = jQuery("#"+this.ref.mapId+" #tx-xanlitegmaps-products").val();
	},
	
	checkMarker: function(node){
		if(!this.productId || this.productId == 0) return true;
		var prods = node.attr("products");
		var ok = typeof(prods) != "undefined" 
			&& (prods.indexOf(this.productId+",") != -1
			|| prods.indexOf("," + this.productId+",") != -1
			|| prods.indexOf("," + this.productId) != -1);

		return ok;
	}
};
