click event associated to two modal divs
===

I have an issue related to click events on different modal divs.

I have a modal div 'A' which shows an overlay div with some info. This div is show by clicking i.e. a button A. So, when it's shown if i click outside the overlapped div, i want this to close.

I have another div 'B' which shows an overlay div with some other info. This div is show by clicking i.e. a button B. So, when it's shown if i click outside the overlapped div, i want this to close.

In both cases i use $(window).click() for managing them.

The question is that i need that when once i click on button 'A', it's corresponding div come up and if i click on button 'B' I want div 'A' close and div 'B' come up and viceversa.

how can i handle multiple clicks events for multiple modal divs?

Thanks.y