var Orientation = Orientation || {};
var Orientation = {
	
	init: function()
	{
		var self = this;
		addEventListener('load', function() { self.check(); }, false);
		addEventListener('orientationChange', function() { self.check(); }, false);
		addEventListener('orientationchange', function() { self.check(); }, false);
	},
	
	adjust: function()
	{
		if (window.orientation == 0 || window.orientation == 180)
		{
			$('#main').removeClass('horizontal').addClass('vertical');
			if (Gallery.active == true) {
				Gallery.refresh();
			}
		} else {
			$('#main').removeClass('vertical').addClass('horizontal');
			if (Gallery.active == true) {
				Gallery.refresh();
			}
		}	
		setTimeout(scrollTo, 100, 0, 1);
	},
	
	check: function()
	{
		setTimeout(this.adjust, 0);
	}

}

Orientation.init();



