Is there a specific part ot the process you don't understand, or are you asking for a general, high-level design for this functionality, or what? The more specific you can make your question, the more likely it is to get a specific answer. It may also help to show us what you've coded so far.
Another thing to consider, do you really gain anything from this separate "availability" process versus simply having the user submit his registration, then if the user name is already in use just returning to the registration form with an appropriate error message?