private IQuery GetMediaItemQuery(string search)
		{
			IQuery query = null;
		
			if (!string.IsNullOrEmpty(search))
			{
                IList<IExpression> filters = new List<IExpression>();
                StringBuilder queryString = new StringBuilder("FROM MediaItem WHERE");

				int number;
				bool isNumber = int.TryParse(search, out number);
				
				DateTime date;
				bool isDate = DateTime.TryParse(search, out date);
				
				TimeSpan duration;
				bool isDuration = TimeSpan.TryParse(search, out duration);
				
				Uri path;
				bool isPath = Uri.TryCreate(search, UriKind.Absolute, out path);
				
				filters.Add(GetMediaItemFilter("Title", "LIKE", search));
                queryString.AppendFormat(" (\"Title\" LIKE '%{0}%')", search);

				filters.Add(GetMediaItemOrFilter("Artist", "LIKE", search));
                queryString.AppendFormat(" OR (\"Artist\" LIKE '%{0}%')", search);

                filters.Add(GetMediaItemOrFilter("Album", "LIKE", search));
                queryString.AppendFormat(" OR (\"Album\" LIKE '%{0}%')", search);

                if (isNumber)
                {
                    filters.Add(GetMediaItemOrFilter("Number", "=", number));
                    queryString.AppendFormat(" OR (\"Number\" = {0})", number);
                }

                if (isDate)
                {
                    filters.Add(GetMediaItemOrFilter("Date", "=", date));
                    queryString.AppendFormat(" OR (\"Date\" = '{0}')", date.ToString("s"));
                }

                if (isDuration)
                {
                    filters.Add(GetMediaItemOrFilter("Duration", "=", duration));
                    queryString.AppendFormat(" OR (\"Duration\" = '{0:D2}:{1:D2}:{2:D2}.{3:D3}')", duration.Hours, duration.Minutes, duration.Seconds, duration.Milliseconds);
                }

                if (isPath)
                {
                    filters.Add(GetMediaItemOrFilter("Path", "=", path));
                    queryString.AppendFormat(" OR (\"Path\" = '{0}')", path);
                }

                query = new Query("MediaItem", queryString.ToString());
                foreach (IExpression filter in filters)
                    query.Filters.Add(filter);
			}
			
			return query;
		}