/**
 * 
 * @authors Your Name (you@example.org)
 * @date    2017-06-26 11:13:47
 * @version $Id$
 */
var EntryPageController = function () {
	// private data
	var entryPageEl = $('.m-entry');

	// private api
	var initBgAnim = function (name) {
		var hideOtherLogo = function () {
			if (name !== 'maoking') {
				$('.logo-maoking').fadeOut(300);
				$('.icon-maoking').fadeOut(300);
			}
			if (name !== 'radiooo') {
				$('.logo-radiooo').fadeOut(300);
				$('.icon-radiooo').fadeOut(300);
			}
			if (name !== 'maofm') {
				$('.logo-maofm').fadeOut(300);
				$('.icon-maofm').fadeOut(300);
			}
			$('.entry-light').hide();
		};

		var showOtherLogo = function () {
			if (name !== 'maoking') {
				$('.logo-maoking').fadeIn(300);
				$('.icon-maoking').fadeIn(300);
			}
			if (name !== 'radiooo') {
				$('.logo-radiooo').fadeIn(300);
				$('.icon-radiooo').fadeIn(300);
			}
			if (name !== 'maofm') {
				$('.logo-maofm').fadeIn(300);
				$('.icon-maofm').fadeIn(300);
			}
			$('.entry-light').fadeIn(500);
		};

		$('.logo-' + name).hover(
			function () {
				entryPageEl.hasClass('bg-' + name) || entryPageEl.addClass('bg-' + name);
				hideOtherLogo();
			},
			function () {
				entryPageEl.hasClass('bg-' + name) && entryPageEl.removeClass('bg-' + name);
				showOtherLogo();
			}
		);
	}

	// public api
	this.pageInit = function () {
		if (document.documentElement.clientWidth <= 1080) {
			$('.entry-icon').hide();
			$('.entry-text').hide();
		} else {
			initBgAnim('maoking');
			initBgAnim('radiooo');
			initBgAnim('maofm');
		}

		TD.imgPreload(function () {
			$('.m-loading').hide();
		});
	}
}


$(document).ready(function () {
	var entryPage = new EntryPageController();

	entryPage.pageInit();
});
