Fix glitch on resize, get rid of globals, switch to jquery 'on' instead of 'live'

 - Fixed updating the mask correctly on resize while window is open
 - got rid of globals
 - Since 'live' was deprected since jquery-1.7, it was replaced with 'on'