﻿var updateLayout=function(){
  if(window.innerWidth!=currentWidth){
    currentWidth=window.innerWidth;
    var orient=(currentWidth==320)?"profile":"landscape";
    document.body.setAttribute("orient",orient);
    window.scrollTo(0,1);
  }
};
iPhone.DomLoad(updateLayout);
setInterval(updateLayout,500);

/* 320px */
@media only screen and (max-width:320px) and (orientation:portrait and landscape){
  .selector{padding:0;margin:0}
  aside,sidebar{display:none}
  body,html{-webkit-text-size-adjust:none;-ms-text-size-adjust:100%}
}

/* 321–480px */
@media only screen and (min-width:321px) and (max-width:480px) and (orientation:portrait and landscape){
  .selector{padding:0;margin:0}
  aside,sidebar{display:none}
  body,html{-webkit-text-size-adjust:none;-ms-text-size-adjust:100%}
}

/* 481–640px */
@media only screen and (min-width:481px) and (max-width:640px) and (orientation:portrait and landscape) and (-webkit-min-device-pixel-ratio:1){
  .selector{padding:1px;margin:1px}
  body,html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
}

/* 641–728px */
@media only screen and (min-width:641px) and (max-width:728px) and (orientation:portrait and landscape) and (-webkit-min-device-pixel-ratio:2){
  .selector{padding:2px;margin:2px}
  body,html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
}

/* 729–1080px */
@media only screen and (min-width:729px) and (max-width:1080px) and (orientation:portrait and landscape) and (-webkit-min-device-pixel-ratio:2){
  .selector{padding:2px;margin:2px}
  body,html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
}
