Javascript on Tab Selection

I am trying to call the javascript when Tab is selected to refresh the model with custom conditions. But couldnt find the right way.  Pls share any ideas on this. 

You may want to check out this post for ideas

Thanks Irvin… I will check this one.