// Lifeline 1.0
// Written & designed by David Correll with some help from Travis Sinnott, Adam Berlin and the interwebs.
// Licensed under a Creative Commons Attribution, Noncommercial, Share Alike 3.0 United States License	

// addLoadEvent written by Simon Wilson
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
	var oldOnLoad = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldOnLoad();
			func();
		}
	}
}    
                                   
var currentWidth = 0;

function updateLayout() {
	if (window.innerWidth != currentWidth) {
		currentWidth = window.innerWidth;

		var orient = currentWidth == 320 ? "profile" : "landscape";
		document.body.setAttribute("orient", orient);
		setTimeout(function() {
			window.scrollTo(0, 1);
		}, 100);            
 	}
}
setInterval(updateLayout, 400);
addLoadEvent(updateLayout);
