JavaScript Capture IOS7 iPad Screen Orientation Change

Code snippet to capture ipad device change (IOS7) tested.

jQuery(document).ready(function($) {
//capture ipad device change (IOS7) tested.
function doOnOrientationChange()
{
  // alert(window.orientation);
  switch(window.orientation)
  {
    case 0:
    case 90:
      alert('portrait');
      $('html').removeClass('landscape').addClass('portrait');
      break;
    case -90:
      alert('landscape');
      $('html').removeClass('portrait').addClass('landscape');
      break;
    default:
      break;
  }
}
});