That works great until the user inputs a category such as "Category 1" with a space. Spaces are obviously not desirable as CSS classes so if we could maybe just have a dash added to replace the space that would be perfect - just not sure how to accomplish that?

Thanks for the response! All i see for working examples on their reference page however is to use a specific title, mine is dynamic depending on the category so Im not too sure how to add this to my function unfortunately.
–
Mr.BrownJan 13 '13 at 1:24

Really appreciate the help AKTed, I +1'd your response since you went out of the way to show me a working example...I decided to go with pogoking answer since though since his answer was a much cleaner solution. Both are viable options though so thank you!
–
Mr.BrownJan 13 '13 at 3:37