

JRILIB.SiteTopDefaultStyle =''
+'<style type="text/css">'
+'#contents-container #content-foot .notice-block .notice-main .economy-block,'
+'#contents-container #content-foot .notice-block .notice-main .management-block,'
+'#contents-container #content-foot .notice-block .info-block ul li'
+'{display: none;}'
+'</style>';
document.write(JRILIB.SiteTopDefaultStyle);


/* ----------------------------------------------------------------------------------- */

JRILIB.SiteTopTabNavi = function () {
	this.tabNavi  = $("#tab-navi li span");
	this.tabNaviIdSuffix = "-tab";
	this.tabPanel = $("#tab-navi-block .tab-panel");
	this.cname_active = "active";
	this.cname_hover = "hover";

	if (this.tabNavi.length && this.tabPanel.length) {
		this.init();
	}
}

JRILIB.SiteTopTabNavi.prototype.init = function () {
	this.setEvent();
	$("#contents-container #content-foot .notice-block .notice-main ul li.news span").addClass(this.cname_active);
}

JRILIB.SiteTopTabNavi.prototype.setEvent = function () {
	var _this = this;
	_this.tabNavi.click(function (e) {
		e.preventDefault();

		if ($(this).hasClass(_this.cname_active)) {
			return;
		}

		_this.tabNavi.each(function () {
			$(this).removeClass(_this.cname_hover);
			$(this).removeClass(_this.cname_active);
		});

		_this.tabPanel.hide();

		var reg = new RegExp(_this.tabNaviIdSuffix);
		var id = $(this).attr("id").replace(reg, "");
		var el = $("#"+id);

		el.show();
		if (jQuery.browser.msie && jQuery.browser.version<=7) {
			var lh = el.css("line-height");
			el.css({"line-height":"0"});
			el.css({"line-height":lh});
		}

		$(this).addClass(_this.cname_active);
	});

	if (jQuery.browser.msie && jQuery.browser.version<=6) {
		_this.tabNavi.mouseover(function (e) {
			$(this).addClass(_this.cname_hover);
		})
		.mousemove(function (e) {
			$(this).addClass(_this.cname_hover);
		})
		.mouseout(function (e) {
			$(this).removeClass(_this.cname_hover);
		});
	}
}

/* ----------------------------------------------------------------------------------- */

JRILIB.SiteTopInfoTicker = function () {
	this.infoList = $("#info-list li");
	this.itemLength = this.infoList.length;
	this.prefix = "info-item-";
	this.activeId = 1;
	this.delay = 4000;
	this.effectStarted = false;
	this.timer = null;

	if (this.itemLength >= 2) {
		this.init();
	}
	else if (this.itemLength == 1) {
		this.infoList.show();
	}
}

JRILIB.SiteTopInfoTicker.prototype.init = function () {
	var _this = this;
	this.infoList.each(function(index) {
		var i = index + 1;
		var id = _this.prefix + i;
		$(this).attr({"id": id});
	});

	$("#"+this.prefix+this.activeId).show();

	this.startTimer();

	$(this.infoList).mouseover(function() {
		if (!_this.effectStarted) { _this.clearTimer(); }
	})
	.mouseout(function() {
		if (!_this.effectStarted) { _this.startTimer(); }
	});
}

JRILIB.SiteTopInfoTicker.prototype.startTimer = function () {
	var _this = this;
	this.clearTimer();
	this.timer = setTimeout(function() {
		_this.fadeInOut();
	}, _this.delay);
}

JRILIB.SiteTopInfoTicker.prototype.clearTimer = function () {
	clearTimeout(this.timer);
}

JRILIB.SiteTopInfoTicker.prototype.fadeInOut = function () {
	this.effectStarted = true;
	var selectorOut = "#"+this.prefix+this.activeId;
	var _this = this;

	$(selectorOut).fadeOut("slow", function() {
		_this.activeId = (_this.activeId == _this.itemLength) ? 1 : (_this.activeId+1);
		var selectorIn = "#"+_this.prefix+_this.activeId;

		$(selectorIn).fadeIn("slow", function() {
			_this.effectStarted = false;
			_this.startTimer();
		});
	});
}

/* ----------------------------------------------------------------------------------- */

$(function () {
	new JRILIB.SiteTopTabNavi();
	new JRILIB.SiteTopInfoTicker();
});


