var agencyFinderRef; 
	
function agencyFinderDidYouMean(link) {
	agencyFinderRef.onDidYouMean(link);
}

function AgencyFinder () {

}
	
AgencyFinder.prototype = {
	geoDefault: null // where map will be positioned, if no results are found
    // classes
    ,agencyMap: null			// holding instance of class.AgencyMap
	    // value objects
	    ,search: {}
	    ,result: {}
	    // filtered Location items
	    ,items: []
	    // runtime
	    ,pageItems: 10
	    ,page: 0
	    ,pageNum: 0
	    // IE6 fix - IE6 got in checkbox change recursive thing
	    ,checkChangeStop: false
	    // some kind of constructur :9
	    ,init: function(){
			var me = this;
			
			this.geoDefault = {
				geo_b: '51.3171621795287' 
				,geo_l: '9.49079659015147' 
			};
			
		}
		,setMap: function(agencyMap) {
			this.agencyMap = agencyMap;
		}
		,onFormSuccess: function(transport) {
			this.result = $.evalJSON(transport);
			/**
			 * TODO: in der geoL und geoB geschichte ist noch der wurm drin, was ist LAT LNG zu L B ?
			 */
			this.performResult();
		}
		,performResult: function() {

			this.agencyMap.clearMap();
			this.showResults();
		}
		,showResults: function() {
			this.items = [];
			for (var index = 0; index < this.result.locations.length; index++) {
				var item = this.result.locations[index];
				this.items.push(item);
			}
			
			// adding icons to items according to their type and index
			for (var index = 0; index < this.items.length; index++) {
				var item = this.items[index];
				item.icon = 'img/finder/dynamic.php?';
				if (item.type == 'handel') {
					item.icon += 'sprechblase_dunkel_';
				}
				else {
					item.icon += 'sprechblase_hell_';				
				}
				
				item.icon += (index + 1) + '.png';
//				if (index < 10) {
//					item.icon += (index + 1) + '.png';
//				}
//				else {
//					item.icon += '0.png';
//				}
			}
			
			this.agencyMap.clearMap();
			this.agencyMap.setCenter(this.result.geoStandort);
			this.agencyMap.populate(this.items);
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	