/* @cc_on _d=document;eval('var document=_d')@ */

new function () {

var kanaPanel = {
	buttonList : null,
	load : function () {
		var list = [];
		$("#up_kanaList, #down_kanaList").find("a").each(function (i, ele) {
			ele.realHref = ele.href;
			list.push(ele);
		});
		this.buttonList = list;
	},
	change : function (realList, suffix) {
		$(this.buttonList).attr("className", "off");
		$(this.buttonList).attr("href", "#none");
		if (realList == null) {
			return;
		}

		$(this.buttonList).each(function (i, ele) {
			var kana = ele.innerHTML;
			if (kana in realList) {
				ele.className = "on";
				ele.href = ele.realHref+suffix;
			}
		});
	}
};
kanaPanel.load();

var now = {
	tab : null,
	list : null,
	romanList : null,
	"load" : function () {
		this.tab = $("#topTab, #bottomTab").find(".now");
		this.list = $("#nowList");
		if (this.list.length == 0) {
			return;
		}

		var tmp = {};
		this.list.find("h2").each(function(i, ele) {
			var kana = $(ele).text().slice(0, 2);
			tmp[kana] = "dummy";
		});
		this.romanList = tmp;
	},
	"on" : function () {
		this.tab.parent().attr("className", "on");
		this.list.show();

		kanaPanel.change(this.romanList, "_now");
	},
	"off" : function () {
		this.tab.parent().attr("className", "off");
		this.list.hide();
	}
}
now.load();

var defunct = {
	tab : null,
	list : null,
	romanList : null,
	"load" : function () {
		this.tab = $("#topTab, #bottomTab").find(".defunct");
		this.list = $("#defunctList");
		if (this.list.length == 0) {
			return;
		}

		var tmp = {};
		this.list.find("h2").each(function(i, ele) {
			var kana = $(ele).text().slice(0, 2);
			tmp[kana] = "dummy";
		});
		this.romanList = tmp;
	},
	"on" : function () {
		this.tab.parent().attr("className", "on");
		this.list.show();

		kanaPanel.change(this.romanList, "_defunct");
	},
	"off" : function () {
		this.tab.parent().attr("className", "off");
		this.list.hide();
	}
}
defunct.load();

now.tab.click(function () {
	now.on();
	defunct.off();
});
defunct.tab.click(function () {
	defunct.on();
	now.off();
});

var images = [];
new function () {
	if (now.romanList != null) {
		kanaPanel.change(now.romanList, "_now");
		$(document).ready(function () {
			$("#defunctList img").each(function (ele) {
				ele.orgSrc = ele.src;
				ele.src = "/cmn/seoCatalog-images/1x1.gif";
				images.push(ele);
			});

			defunct.tab.one("click", function () {
				$(images).each(function (ele) {
					ele.src = ele.orgSrc;
				});
			});
		});
	}else{
		kanaPanel.change(defunct.romanList, "_defunct");
	}
}();

}();

