//---------------------------------------------------------
// common.js
//----------------------------------------------------------

/**
 * ページが読込まれた時の処理を行う
 */
function pcpOnload()
{
    //ルビ振り種別ラジオボタンの初期値を設定する
    setTaggerMethod()
}

/**
 * 指定された名前の Cookie の値を取得する
 */
function getCookie(name)
{
	var search = name + '=';
    if (document.cookie.length > 0)
    {
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(';',offset);
			if (end == -1)
			{
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(offset,end));
		}
	}
	return '';
}

/**
 * ルビ振り種別を Cookie に設定する
 */
function setTaggerDispType()
{
	var formObj = document.form1;
	if (formObj != null)
	{
		if (formObj.ruby != null)
		{
			var i;
			i = formObj.ruby.selectedIndex;
			value = formObj.ruby.options[i].value;
		}
		else
		{
			value = 2;
		}
	}
	document.cookie = "TAGGER_DISP_TYPE=" + value + "; expires=Thu, 1-Jan-2030 00:00:00 GMT; path=/";
}

/**
 * Cookie 値より選択中のルビ振り種別を取得し、ラジオボタンを設定する
 */
function setTaggerMethod()
{
	var formObj = document.form1;
	if (formObj != null)
	{
		if (formObj.ruby != null)
		{
			var taggerDispType = getCookie("TAGGER_DISP_TYPE");
			if (taggerDispType == "3")
			{
				formObj.ruby.selectedIndex = 2;
			}
			else
			{
				formObj.ruby.selectedIndex = 1;
			}
		}
	}
}
