Why does'nt work this script?

function ChangeVis(id) {
if (document.getElementById(id).style.visibility="visible")
{
document.getElementById(id).style.visibility="hidden";
}
else if (document.getElementById(id).style.visibility="hidden")
{
document.getElementById(id).style.visibility="visible";
}
}