// Correct viewport when changing orientation
var lastmode = 0;

setInterval(
 function() {
  if (window.innerWidth == 320) {
   document.getElementById("viewport").setAttribute("content", "width=320;", false);
   if (lastmode != 320) {
    lastmode = 320;
    window.scrollTo(0,1);
   }
  } else if (window.innerWidth == 480) {
   document.getElementById("viewport").setAttribute("content", "width=480;", false);
   if (lastmode != 480) {
    lastmode = 480;
    window.scrollTo(0,1);
   }
  }
 }, 300);

