Better way to listen for click event
<p>I have a graph that is controlled by two calendars. If the user clicks and opens the one calendar to select a date then clicks anywhere off of the calendar that calendar should close. Since there is a "start date" and an "end date" calendar they are both closing each other. So I am attempting to come up with a new solution. My current solution looks something like this.</p>

<pre><code>$(document).click(function() {
    if (this !== $("#startDate") &amp;&amp; this !== #("#endDate")) {
        $("#startDate").hide();
        $("#endDate").hide();
    }
});
</code></pre>

<p>Obviously, this if statement fires on <em>every</em> click. I think this is a poor way of doing this but cannot think of a smarter way. Anyone have a better way? Remember, there are two calendar's that can't close each other.</p>
