LocationService.prototype = {};

function LocationService(config)
{
	var location = basePath; // Service location, basePath needs to befined outside and before this js file

	this.searchLocations = function(searchString, searchType, response)
	{
		this.request = jQuery.ajax({
			
			dataType : "xml",
			url : location + "/" + searchString + "/" + searchType,
			success : function(data, textStatus, xhr)
			{
				data = jQuery(data);
				
				var result = [];
				
				data.find("location").each(function()
				{
					var location = jQuery(this);
					
					result.push({
						label : location.find("name").text(), 
						value : location.find("name").text(), 
						type : location.find("type").text(),
						id : location.find("id").text()
					});
				});
				
				response(result);
			}
		
		});
	};
}

DVLocationService = new LocationService();
