You're not going to be able to use a switch to deal with the multiple levels of nested if statements. Also switch statements are not really conducive to multi-condition if statements.
It's really hard to tell what is going on from this code but could you split it up into two functions, one for "right" and one for "left"?
My knowledge of javascript is not the best but given the complexity of what appears to be done I would recommend that if this code works well now and does what it is supposed to, I would consider commenting it so that when you or someone else comes back to look at it again in the future it will be easier to understand what is going on.