dojo.declare("com.mgh.CentersController", null, {
	constructor : function (id){
		this.allCentersId = id;
	},
	
	GetData : function(id,name,type){	
		var qs = new com.mgh.QueryString(null);
		var centerId;
		try {
			id = id == '' ? this.allCentersId : id;
			dojo.xhrGet({
				url: '/assets/processing/GetCenters.ashx?id=' + id,
				handleAs: "json",				
				load : function (response,ioArgs){	
					centerId = qs.params['center'];
					if(centerId != undefined){					
						dojo.publish('preSelectedCentersDataReady',[centerId,response,type]);							
						dojo.publish('getPreSelectedPrograms',[centerId,name,type]);					
					} else {
						dojo.publish('centersDataReady',[response,type]);						
					}													
				},
				error : function(response, ioArgs){
					alert("An error occurred, with response: " + response);
				}
			});
		} catch (e) {
			console.log('CentersController.GetData Error: ' + e);			
		}
	},
		
	GetCentersByLocation : function(id,name,type){
		try {
			dojo.xhrGet({
				url: "/assets/processing/GetCentersByLocation.ashx?id=" + id,
				handleAs: "json",
				load : function (response,ioArgs){					
					dojo.publish('centersDataReady',[response]);
				},
				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.center = id;
		mySearch.getXmlString();	
	}
});