var currentWidth = null;
var currentRotation = null;
if (document.addEventListener) {
	addEventListener("load",function() {
		setTimeout(updateLayout,0);
	},false);
}
function updateLayout() {
	if (typeof window.innerWidth != 'undefined') {
		if (window.innerWidth != currentWidth) {
			currentWidth = window.innerWidth;
			var orient = currentWidth <= 320 ? "portrait" : "landscape";
			document.body.setAttribute("orient",orient);
			setTimeout(function(){
				window.scrollTo(0,1);
			}, 100);           
		}
	} else {
		if (typeof window.orientation != 'undefined') {
			if (currentRotation != window.orientation) {
				switch(window.orientation){
					case 0: orient = 'portrait'; break;
					case 90: orient = 'landscape'; break;
					case -90: orient = 'landscape'; break;
				}
				currentRotation = window.orientation;
				document.body.setAttribute("orient",orient);
				setTimeout(function(){
					window.scrollTo(0,1);
				}, 100);
			}
		}
	}
}
setInterval(updateLayout,400);
