dojo.declare("com.mgh.LocationsController", null, {
	constructor : function (id,url){
		this.allLocationsId = id;
		this.url = url;
	},
	
	GetAllLocations : function(id,name,type){
		try {
			id = id == '' ? this.allLocationsId : id;
			dojo.xhrGet({
				url: this.url + 'getAllLocations.ashx?id=' + id,
				handleAs: "json",
				load : function (response,ioArgs){					
					dojo.publish('locationsDataReady',[response, type]);
				},
				error : function(response, ioArgs){
					alert("An error occurred, with response: " + response);
				}
			});
		} catch (e) {
			console.log('LocationsController.GetAllLanguages Error: ' + e);			
		}
	},
	
	GetCenterLocations : function(id,name,type){		
		try {
			dojo.xhrGet({
				url: this.url + 'GetCenterLocations.ashx?id=' + id,
				handleAs: "json",
				load : function (response,ioArgs){					
					dojo.publish('locationsDataReady',[response, type]);
				},
				error : function(response, ioArgs){
					alert("An error occurred, with response: " + response);
				}
			});
		} catch (e) {
			console.log('LocationsController.GetLocationsByCenter Error: ' + e);			
		}		
	},
	
	Filter : function(id,name){
		showTimer();
		mySearch.queryParams.location = id;
		mySearch.getXmlString();	
	},
	
	ResetLocations : function(id,name,type){
		mySearch.queryParams.location = '';
	}	
});
