// 2000/08/01 ポート番号対応
// window.location.hostname から window.location.host へ変更

function JumpHome(bfmtc)
{
	var strHomeURL = "/" + Const_ALIAS + "/";				// HomeのURL
	if(bfmtc == "1")
		strHomeURL += "tc.htm";
	window.location = strHomeURL;
}

function JumpBbsMenu(bfmtc)
{
	// BbsMenuのURL
	var strBbsMenu = "http://" + window.location.host + "/" + Const_ALIAS + "/scr/board/Query.asp";
    strBbsMenu = strBbsMenu + "?fmtc=" + bfmtc;

	window.location = strBbsMenu;
}

function JumpLibMenu(bfmtc)
{
	// LibMenuのURL
	var strLibMenu = "http://" + window.location.host + "/" + Const_ALIAS + "/scr/library/Query.asp";
    strLibMenu = strLibMenu + "?fmtc=" + bfmtc;

	window.location = strLibMenu;
}

function JumpArcMenu(bfmtc)
{
	// ArcMenuのURL
	var strArcMenu = "http://" + window.location.host + "/" + Const_ALIAS + "/scr/Archive/Query.asp";
    strArcMenu = strArcMenu + "?fmtc=" + bfmtc;

	window.location = strArcMenu;
}

function Trim(string)			// Call by value
{
	var iLen;
	if((iLen = string.length) == 0)
		return "";

	var strCheck;
	for(var iLC1 = 0; iLC1 < iLen; iLC1++)			// 前の空白を削除
	{
		if(string.charAt(iLC1) == " " || string.charAt(iLC1) == "　")
			continue;
		if(iLC1 != 0)
			string = string.substring(iLC1, iLen);
		break;
	}
	if(iLC1 == iLen)								// すべて空白
		return "";

	iLen = string.length;
	for(var iLC1 = iLen - 1; iLC1 >= 0; iLC1--)		// 後の空白を削除
	{
		if(string.charAt(iLC1) == " " || string.charAt(iLC1) == "　")
			continue;
		if(iLC1 != 0)
			string = string.substring(0, iLC1 + 1);
		break;
	}

	return string;
}


// 月の日数を求める(iMonth 0-11)
function GetMonthDays(iYear, iMonth)
{
	var iMonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

//	if(iYear < 80)				// 2桁のとき
//		iYear += 2000;
//	else if(iYear < 100)			// 80-99
//		iYear += 1900;

	// 閏年かどうかを調べる
	if(((iYear % 4 == 0) && (iYear % 100 != 0)) || (iYear % 400 == 0))
		iMonthDays[1] = 29;

	return iMonthDays[iMonth];
}


// (iSubMonth)ヵ月前の日付を求める[GMT]
function GetBeforeDateByMonth(iSubMonth)	// Call by value
{
	var date = new Date();
	var iYear = date.getFullYear();
//	if(iYear < 80)				// 2桁のとき
//		iYear += 2000;
//	else if(iYear < 100)			// 80-99
//		iYear += 1900;

	var iMonth = date.getMonth();	// 0-11
	if(iMonth >= iSubMonth)
		iMonth -= iSubMonth;
	else
	{
		iMonth += 12 - iSubMonth;
		iYear--;
	}

	var iDate = date.getDate();
	var iMonthDays = GetMonthDays(iYear, iMonth);
	if(iDate > iMonthDays)
		iDate = iMonthDays;

	date.setYear(iYear);
	date.setDate(iDate);		// 先にDateをセットしておくこと（自動繰り上がりに注意）1999/05/31修正
	date.setMonth(iMonth);
	date.setHours(0);			// 00:00:00にセット
	date.setMinutes(0);
	date.setSeconds(0);
	date.setTime(date.getTime() + (date.getTimezoneOffset() * 60 * 1000));

	var iYear = date.getFullYear();
//	if(iYear < 80)				// 2桁のとき
//		iYear += 2000;
//	else if(iYear < 100)			// 80-99
//		iYear += 1900;

	var strBeforeDate = iYear + "/" + (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();

	return strBeforeDate;
}


// (iSubDay)日前の日付を求める[GMT]
function GetBeforeDateByDay(iSubDays)	// Call by value
{
	var date = new Date();
	date.setHours(0);			// 00:00:00にセット
	date.setMinutes(0);
	date.setSeconds(0);

	date.setTime(date.getTime() - (iSubDays * 24 * 60 * 60 * 1000) + (date.getTimezoneOffset() * 60 * 1000));

	var iYear = date.getFullYear();
//	if(iYear < 80)				// 2桁のとき
//		iYear += 2000;
//	else if(iYear < 100)			// 80-99
//		iYear += 1900;

	var strBeforeDate = iYear + "/" + (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();

	return strBeforeDate;
}



