//========================================================
//  引数の日付時刻文字列を変換して返す
//-------------------------------------------------
//  引数1：日付文字列(YYYYMMDDHHMI) 12桁
//  引数2：変換モード
//  戻値 ：変換結果文字列
//========================================================
function JS_ChangeYmdFormat(yyyymmddhhmi,mode){
	input = yyyymmddhhmi ;
	if( (input.length == 0) || (input == "null") ){
		return "　　" ;
	}
	switch(mode){
	case 0:		// YYYY/MM/DD　HH:MI
		str = input.substr(0,4) + "/" + input.substr(4,2) + "/" + input.substr(6,2) + "　" + input.substr(8,2) + ":" + input.substr(10,2) ;
		break ;
	case 1:		// YY/MM/DD　HH:MI
		str = input.substr(2,2) + "/" + input.substr(4,2) + "/" + input.substr(6,2) + "　" + input.substr(8,2) + ":" + input.substr(10,2) ;
		break ;
	case 2:		// MM/DD　HH:MI
		str = input.substr(4,2) + "/" + input.substr(6,2) + "　" + input.substr(8,2) + ":" + input.substr(10,2) ;
		break ;
	case 3:		// HH:MI
		str = input.substr(8,2) + ":" + input.substr(10,2) ;
		break ;
	case 4:		// HH:MI形式で１時間前を取得する
		str = input.substr(8,2) - 1 + ":" + input.substr(10,2) ;
		break ;
	case "day":	// 日報用（YYYY年MM月DD日）
		str = input.substr(0,4) + "年" + input.substr(4,2) + "月" + input.substr(6,2) + "日" ;
		break ;
	case "month":	// 月報用（YYYY年MM月）
		str = input.substr(0,4) + "年" + input.substr(4,2) + "月" ;
		break ;
	case "year":	// 年報用（YYYY年）
		str = input.substr(0,4) + "年" ;
		break ;
	default:
		str = input ;
	}
	return str ;
}


//======================================================
// 入力文字を全角=2とした文字長を返す
//======================================================
function JS_GetLength(moji){
	//alert(moji+":"+moji.length);
	var i,moji_leng = 0 ;
	for(i=0; i<moji.length; i++){
		if(escape(moji.charAt(i)).length >= 4 )
			moji_leng+=2 ;
		else
			moji_leng++;
	}
	//alert(moji_leng) ;
	return moji_leng ;
}

//======================================================
// 引数の秒数時間が経過したら終了する。
//======================================================
function JS_Sleep(sec){
	sec = parseInt(sec) ;

	// 現在時刻を取得
	sdate = new Date() ;
	// 1970/1/1 00:00:00から何秒経過しているか
	spasstime = sdate.getTime() ;
	spasstime = spasstime / 1000 ;

//	str = "1970/1/1 00:00:00から" + spasstime + "秒経過しました" ;
//	status = str ;

	cnt = 0 ;
	npasstime = 0 ;
	flg = false ;	// 無限ループさせる為のﾀﾞﾐｰのﾌﾗｸﾞ
	while(!flg){
//		status = cnt ;

		// 現在時刻を取得
		now = new Date() ;
		// 1970/1/1 00:00:00から何秒経過しているか
		npasstime = now.getTime() ;
		npasstime = npasstime / 1000 ;
		// はじめに取得した時刻との差(秒)が引数の値を超えたらループを抜ける
		if(npasstime - spasstime > sec){
			break ;
		}
		cnt ++ ;
	}
//	status += "end(cnt[" + cnt + "])" ;
	return true ;
}

