var _isIE=navigator.userAgent.toLowerCase().indexOf("msie")!=-1;
var _isMozilla=!_isIE&&navigator.userAgent.toLowerCase().indexOf("mozilla")!=-1;
var _isMac=navigator.userAgent.toLowerCase().indexOf("mac")!=-1;
var _isIMobile=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1||navigator.userAgent.toLowerCase().indexOf("ipod")!=-1;

// Shortcut for document.getElementById()
function $e(id) {
	return (typeof id == "string") ? document.getElementById(id) : id;
}

// iPhone
function updateIMobileLayout() {
	switch(window.orientation) { 
	case 0:
	case 180:	
		// Portrait
		document.body.setAttribute("class", "portrait");
		break; 
	case -90:
	case 90: 
		// Landscape
		//alert("landscape");
		document.body.setAttribute("class", "landscape");
		//setTimeout(function(){landscape();}, 500);
		break; 
	} 
		
	// Scroll past the toolbar
	setTimeout(function(){window.scrollTo(0, 1);}, 100);
};

function landscape() {
	document.getElementById("viewport").setAttribute("content","width=620;", false)
}

try {
	if (_isIMobile) {
		addEventListener('orientationChange', updateIMobileLayout);
		addEventListener('load', updateIMobileLayout);
	}
} catch(ex) {
	//alert("error");
}