var lastID = null; //This is the variable that remembers the last ID, must be created outside the function swap
function swap (targetId) 
{  var target = document.getElementById(targetId);
   if (target != null)
   {
       	if (target.style.display == "none")
	    target.style.display = "block";
	else
	    target.style.display = "none";

	//set the lastID as the current target id
	lastID = targetId; 
   }
}

function hideAll()
{
    //if the lastID has been set, set the element style to none
    if (lastID != null)
    {
        var temp = document.getElementById(lastID);
        if (temp != null)
	    temp.style.display = "none";
	   
    }
    
}