I have number of drop down menu's which gets called with a onClick event right below those specific div's,and i also have a window.onclick set inorder to retract those dropdowns(which are active) when a user clicks elsewhere.
Now,when i click on a div(which has a dropDown) the drop down is getting activated(menu gets created) and simultaneously retracting (because of the window.click ) 
The menu's are getting created and getting destroyed at the same time!,Any work arounds to perform the window.onclick iff the clicked element is not on of the div's with a dropdown??
Silly question,from a beginner.. thanks in advance!!
here's a sample code!!.. the onclick on the div is supposed to bring out the menu -- and the window.onclick is supposed to retract the menu(all he menu's which are expanded)
<html>
    <style type="text/css">
    .bar{
    width: 30px;
    height: 30px;
    background-color: black;
    display: none;
    }
    </style>
    <script type="text/javascript" >
    function fire(){
    document.getElementById("bar").style.display="block";
    }
    window.onclick=unfire;
    function unfire(){
    if(document.getElementById("bar").style.display== "block")
    document.getElementById("bar").style.display="none";
    }
    </script>
    <input type="button" value="foo" onclick="fire()">
    <div id="bar" class="bar"></div>
    </html>
Edit:added the code sample
 
     
     
     
     
    