Get device orientation I feel like I can vastly improve this. Any ideas?

// get orientation of device
getOrientation();

// animate
var num = 400;

if( $('body').hasClass("landscape") ) {
    $('.example').animate({'bottom', 0});
} else {
    $('.example').animate({'bottom', num});
}


function getOrientation(){

    switch(window.orientation) {  
     case -90:
     case 90:
    $('body').addClass("landscape");
        // alert('landscape');
        break; 
     default:
       //alert('portrait');
       $('body').addClass("portrait");
       break; 
     }
}

window.onorientationchange = function() {
  getOrientation();
};
Well for starters bind the event using the jQuery standard

var $win = $(window).bind('orientationchange', function(){
    // math.abs to reduce logical operators   
    $('body').removeClass('landscape portrait') // reset
        .addClass(Math.abs(this.orientation) === 90 ? "landscape" : "portrait");     
});

// now you can trigger the orientation manually on doc ready to set the class
$win.trigger('orientationchange');

var num = 400,
    $body = $('body'),
    $example = $('.example');

if($body.hasClass("landscape"))
    $example.animate({'bottom', 0});
else
    $example.animate({'bottom', num});