
function StartSet()
{
	//theForm.DocLimiteSel.selectedIndex = theForm.DocLimiteNo.value;
	var cnt=document.QueryForm.DocLimiteNo.value;
	document.QueryForm.DocLimiteSel[cnt].checked = "true";
	if(document.QueryForm.DispLink.value == "ON")
		document.QueryForm.ChkDispLink.checked = true;
	if(document.QueryForm.DispIBOnly.value == "ON")
		document.QueryForm.ChkDispIBOnly.checked = true;
	if(document.QueryForm.DispImg.value == "ON")
		document.QueryForm.ChkDispImg.checked = true;
}

function SetTextRestriction(theForm)
{
	// 期限の設定
	var i;
	for(var i=0; i <= 3; i++){
		if(theForm.DocLimiteSel[i].checked){
			theForm.DocLimiteNo.value = theForm.DocLimiteSel[i].value;
		}
	}

	if(theForm.DocLimiteNo.value == 1)			// １ヶ月前
		//theForm.DocLimite.value = "@write > " + GetBeforeDateByMonth(1);
		theForm.DocLimite.value = " and (write > '" + GetBeforeDateByMonth(1) + "')";
	else if(theForm.DocLimiteNo.value == 2)		// １週間前
		//theForm.DocLimite.value = "@write > " + GetBeforeDateByDay(7);
		theForm.DocLimite.value = " and (write > '" + GetBeforeDateByDay(7) + "')";
	else if(theForm.DocLimiteNo.value == 3)		// 当日
		//theForm.DocLimite.value = "@write > " + GetBeforeDateByDay(0);
		theForm.DocLimite.value = " and (write > '" + GetBeforeDateByDay(0) + "')";
	else
	{
		theForm.DocLimiteNo.value = 0;
		theForm.DocLimite.value = "";
	}

	var string = Trim(theForm.DispKeyword.value);
	theForm.Keyword.value = "";

	// スペースで区切られていたら分解して、andで結合
	while(true)
	{
		var iIndex1 = string.indexOf(" ");			// " "を検索
		var iIndex2 = string.indexOf("　");			// "　"を検索
		if(iIndex1 == -1 && iIndex2 == -1)
		{
			if(theForm.Keyword.value != "")
				theForm.Keyword.value += " and ";
			theForm.Keyword.value += string;
			break;
		}
		else if(iIndex2 == -1)
			iIndex1 = iIndex1;
		else if(iIndex1 == -1 || iIndex1 > iIndex2)
			iIndex1 = iIndex2;

		if(theForm.Keyword.value != "")
			theForm.Keyword.value += " and ";
		theForm.Keyword.value += string.substring(0, iIndex1);
		string = Trim(string.substring(iIndex1, string.length));
	}

	if(theForm.ChkDispLink.checked)
		theForm.DispLink.value = "ON";
	else
		theForm.DispLink.value = "";

	if(theForm.ChkDispIBOnly.checked)
		theForm.DispIBOnly.value = "ON";
	else
		theForm.DispIBOnly.value = "";

	if(theForm.ChkDispImg.checked)
		theForm.DispImg.value = "ON";
	else
		theForm.DispImg.value = "";

	//return true;
	theForm.submit();
}

function Clear(theForm)
{
	if(theForm.DispGakunen.value == "サンプル教材")
	{
		theForm.DocLimiteNo.value = 0;
		var cnt = theForm.DocLimiteNo.value;
		theForm.DocLimiteSel[cnt].checked="true";
	}
	else
	{
		//theForm.DocLimiteNo.value = 1;
		//var cnt = theForm.DocLimiteNo.value;
		var cnt = theForm.DefLimNo.value;
		theForm.DocLimiteSel[cnt].checked="true";
	}

	theForm.DispKeyword.value = "";
	theForm.ChkDispLink.checked = false;
	theForm.ChkDispIBOnly.checked = false;
	theForm.ChkDispImg.checked = false;
}


function SetLimiteText(theForm)
{
	if(theForm.DocLimiteNo.value == "0")
		return "全文書中";
	else if(theForm.DocLimiteNo.value == "1")
		return "最近１ヶ月以内に登録された文書のうち";
	else if(theForm.DocLimiteNo.value == "2")
		return "最近１週間以内に登録された文書のうち";
	else if(theForm.DocLimiteNo.value == "3")
		return "今日、登録された文書のうち";
}

