
var v_faq = {
	a_dt : new Array(),
	a_dd : new Array(),

	f_setList : function() {
		if(location.href.indexOf("#printView") == -1) {
			v_faq.a_dt = $$(".faqQ");
			v_faq.a_dd = $$(".faqA");

			var f_setOnClick = function() {
				for(var i = 0; i < v_faq.a_dt.length; i ++) {
					if(v_IE) {
						v_faq.a_dd[i].style.cssText = "display:none;";
						v_faq.a_dt[i].getElementsByTagName("a")[0].setAttribute("onclick", new Function("Effect.toggle('dd_" + i + "','appear', {duration : 0.2}); v_faq.f_setClass(" + i + "); return false;"));
					}

					if(!v_IE) {
						v_faq.a_dd[i].setAttribute("style", "display:none;");
						v_faq.a_dt[i].getElementsByTagName("a")[0].setAttribute("onclick", "Effect.toggle('dd_" + i + "','appear', {duration : 0.2}); v_faq.f_setClass(" + i + "); return false;");
					}

					v_faq.a_dd[i].setAttribute("id", "dd_" + i);
					v_faq.a_dt[i].getElementsByTagName("a")[0].setAttribute("href", "#dd_" + i);
				}
			};

			if(v_faq.a_dt.length == v_faq.a_dd.length) f_setOnClick();
		}
	},

	f_setClass : function(num) {
		num = num - 0;

		var v_nClass = v_faq.a_dt[num].getElementsByTagName("a")[0].getAttribute(v_class);

		switch(v_nClass) {
			case null : // another IE first time
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "openAnswer");
				break;
			case "" : // IE first time
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "openAnswer");
				break;
			case "openAnswer" :
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "visitedAnswer");
				break;
			case "visitedAnswer" :
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "openVisitedAnswer");
				break;
			case "openVisitedAnswer" :
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "visitedAnswer");
				break;
			default :
				v_faq.a_dt[num].getElementsByTagName("a")[0].setAttribute(v_class, "visitedAnswer");
				break;
		}
	},

	f_openClose : function(num, t) {
		switch(num) {
			case "" :
				var v_dtTag = $$(".faqQ");

				var v_flag = t.getAttribute("href").split("#")[1];
				var v_status;
		
				if(v_flag == "open") {
					v_status = "none";
					t.setAttribute("href", "#close");
					t.innerHTML = '<img src="/common/img/jp/co_bt_04_on.gif" alt="回答をすべて非表示" width="127" height="13" />';
				}
				if(v_flag == "close") {
					v_status = "";
					t.setAttribute("href", "#open");
					t.innerHTML = '<img src="/common/img/jp/co_bt_04_off.gif" alt="回答をすべて表示" width="127" height="13" />';
				}

				for(var i = 0; i < v_dtTag.length; i ++) {
					var v_target = v_dtTag[i].getElementsByTagName("a")[0].getAttribute("href").split("#")[1];

					if($(v_target).style.display == v_status) {
						Effect.toggle(v_target,'appear', {duration : 0.2});
						v_faq.f_setClass(v_target.split("_")[1]);
					}
				}
				break;
			default :
				var v_dtTag = $$(".c_qg_0" + num);
				var v_ddTag = $$(".c_ag_0" + num);

				var v_flag = t.getAttribute("href").split("#")[1];
				var v_status;
		
				if(v_flag == "open") {
					v_status = "none";
					t.setAttribute("href", "#close");
					t.innerHTML = '<img src="/common/img/jp/co_bt_03_on.gif" alt="このカテゴリの回答をすべて非表示" width="187" height="13" />';
				}
				if(v_flag == "close") {
					v_status = "";
					t.setAttribute("href", "#open");
					t.innerHTML = '<img src="/common/img/jp/co_bt_03_off.gif" alt="このカテゴリの回答をすべて表示" width="187" height="13" />';
				}

				for(var i = 0; i < v_dtTag.length; i ++) {
					var v_target = v_dtTag[i].getElementsByTagName("a")[0].getAttribute("href").split("#")[1];

					if($(v_target).style.display == v_status) {
						Effect.toggle(v_target,'appear', {duration : 0.2});
						v_faq.f_setClass(v_target.split("_")[1]);
					}
				}
				break;
		}
	},

	f_btnAreaAll : function() {
		if(location.href.indexOf("#printView") == -1) {
			document.write('<p class="c_showHideBtnAll">');
			document.write('<a href="#open" onclick="v_faq.f_openClose(\'\', this); return false;">');
			document.write('<img src="/common/img/jp/co_bt_04_off.gif" alt="すべての回答を表示" width="127" height="13" />');
			document.write('</a>');
			document.write('</p>');
		}
	},

	f_btnArea : function(num) {
		if(location.href.indexOf("#printView") == -1) {
			document.write('<p class="c_showHideBtn">');
			document.write('<a href="#open" onclick="v_faq.f_openClose(' + num + ', this); return false;">');
			document.write('<img src="/common/img/jp/co_bt_03_off.gif" alt="このカテゴリの回答をすべて表示" width="187" height="13" />');
			document.write('</a>');
			document.write('</p>');
		}
	}
};

