changed tabs to spaces
too tired to finish anything else

using http://jsfiddle.net/greypants/9d2Dn/ as a reference