--
Please use jsFiddle or jsbin to provide test cases instead of pasting large blocks of code in the ticket.