Replaced direct CSS through setting classes for marking possible fields. Added example how the source is structures (HAML is gread!).
Some comments, try to structure the function better.