The code below allows me to display an item. However, it does not hide previous displayed items.

What addition do I make to this code in order to only show what is clicked and hide all others.

Code:
<script type="text/javascript">
function changeme(id, action) {
       if (action=="hide") {
            document.getElementById(id).style.display = "none";
       } else {
            document.getElementById(id).style.display = "inline";
       }
}
</script>