1. Removed unnecessary TB_window selector
2. this.className == replaced with $(this).hasClass, $(this).addClass and  $(this).removeClass
3. Added allowed actions for check
4. Removed unused functions, unused code, error_log
5. fixed generateTabUrl to actual replace params