/**
 * Home Class
 **/

// Initiate cufon before document is ready for IE reasons
Cufon.replace('.home h2', {
	fontFamily: 'Fabian',
	hover: true,
	separate: 'none'
});
Cufon.replace('.home h3', {
	fontFamily: 'Fabian',
	separate: 'none',
	textShadow: '#FFFFFF 1px 1px, #73766E 2px 2px, #73766E 1px 3px'
});
Cufon.replace('.home p', {
	fontFamily: 'Tall Dark And Handsome',
	hover: true
});
Cufon.replace('.home p a', {
	fontFamily: 'Tall Dark And Handsome',
	hover: true
});

var _Home = new Home();
function Home() {
	var _l0 = this;
	$(document).ready(function() {
		_l0.build();
	});
};

Home.prototype.build = function() {
	var _l0 = this;
	// Resizing
	if (isMobileClient(navigator.userAgent)) {
		// Adapt width
		$('.home', _l0.doc).width($('body').width()-292);
		// Apply scrolling
		$('#tinyscroll1', _l0.doc).attr('class', 'news-feed verttinyscroll');
		$('#tinyscroll1', _l0.doc).height(510);
		var ipad = $('#tinyscroll1', _l0.doc).tinyscrollbar({
			axis : 'y',
			sizethumb : 148
		});
		// Refresh Cufon
		Cufon.refresh();
		// Check orientation
		var supportsOrientation = (typeof window.orientation == 'number' && typeof window.onorientationchange == 'object');
		if(supportsOrientation) {
			window.addEventListener('orientationchange', function() {_l0.updateElementsOnStage(); }, false);
		}
		_l0.updateElementsOnStage();
	} else {
		// Resizing
		$(window).resize(function() {		
			_l0.updateElementsOnStage();
		});
	}
	_l0.updateElementsOnStage();
	// Fix for cufon hover
	$('.home p a').click(function() {
		Cufon.refresh();
	});
};

Home.prototype.updateElementsOnStage = function() {
	var _l0 = this;
	if (isMobileClient(navigator.userAgent)) {
		var orientation = (window.innerWidth > window.innerHeight) ? 'landscape' : 'portrait';
		if (orientation == 'landscape') {
			$('#tinyscroll1', _l0.doc).height(510);
		} else {
			$('#tinyscroll1', _l0.doc).height(1190);
		}
		$('#tinyscroll1', _l0.doc).tinyscrollbar_update();
	} else {
		$('.home', _l0.doc).css({
			'overflow-y' : 'auto',
			'width' : ($('body').width()-292)+'px'
		});
	}
};
