What is electrolysis, and how does it work?

Check any text. This is far too broad a subject to discuss at length. Here is a site you can read on the Internet.

http://en.wikipedia.org/wiki/Electrolysis