The simplest solution to hide calendar on blur or click
<p><a href="http://jsfiddle.net/SXrAb/" rel="nofollow">http://jsfiddle.net/SXrAb/</a></p>

<p>Following the jsfiddle link there is a simplified sample of what I need. Currently it shows the calendar on button click, and hides it on input blur.</p>

<p>What I cannot implement additionally is hiding calendar on button click.</p>

<p>So - calendar should:</p>

<ol>
<li><strike>open on button click if hidden</strike> (done)</li>
<li><strike>hide on blur</strike> (done)</li>
<li>hide on button click if opened (this is what I'm in stuck with, because blur is triggered before button click event so I have no chance to handle it properly)</li>
</ol>

<p><strong>UPD</strong>:</p>

<p>the solution is expected to work correctly in all cases, like "mousedown on button, drag below, mouseup" (otherwise I wouldn't ask it ;-)</p>
