There is no need to use javascript for this.
You can do it this way:
#logo {
position: absolute;
left:50%;
margin-left:-50px;
width:100px;
}
Note, that the element needs to have a width, and the negative left margin is half the width.