//--------------------------------------------------------------------
//
// Method Box Common JavaScript Library
//
// Modify History
//--------------------------------------------------------------------
// No.01 : 2004/03/23 Y.Gotoh Make
//--------------------------------------------------------------------

function openWindowApp( url , windowName ){
	cmnOpenFiexedWindow( url , windowName , 800 , 515 );
}

function openWindow4print( url , windowName ){
	win = window.open( url , windowName ,"width=671,height=445,scrollbars=yes,status=no,resizable=yes,toolbar=no,location=no,menubar=yes");
}

//--------------------------------------------------------------------
// 機能名：0サプライを行う(半角文字列専用)
//--------------------------------------------------------------------
// 【引数】
// str  [string] - 対象文字列
// keta [int]    - 桁数
//--------------------------------------------------------------------

function cmnZeroSupply( str , keta ){
	var tmp;
	tmp = new String(str);
	while( tmp.length < keta ){
		tmp = "0" + tmp;
	}
	return tmp;
}

//-------------------------------------------------------------------
// 機能名：ウィンドウを開く(標準的な設定)
//-------------------------------------------------------------------

function cmnOpenWindow( url , windowName , width , height ){
	var win = null;
	win = window.open( url , windowName ,"width=" + width + ",height=" + height + ",scrollbars=yes,status=no,resizable=no,toolbar=no,location=no,menubar=no");
	if( win != null ) win.focus();
}

function cmnOpenFiexedWindow( url , windowName , width , height ){
	var win = null;
	win = window.open( url , windowName ,"width=" + width + ",height=" + height + ",scrollbars=no,status=no,resizable=no,toolbar=no,location=no,menubar=no");
	if( win != null ) win.focus();
}

//-------------------------------------------------------------------
// 機能名：二重更新チェック
//-------------------------------------------------------------------

var flg_submit = 0;

function cmnSubmitCheck(){
	if( flg_submit == 0 ){
		flg_submit = 1;
		return true;
	}
	return false;
}

function cmnClearSubmitCheck(){
	flg_submit = 0;
}

//-------------------------------------------------------------------
// 機能名：二重更新チェック
//-------------------------------------------------------------------

var flg_submit = 0;

function cmnSubmitCheck(){
	if( flg_submit == 0 ){
		flg_submit = 1;
		return true;
	}
	return false;
}

function cmnClearSubmitCheck(){
	flg_submit = 0;
}

//-------------------------------------------------------------------
// 機能名：オブジェクトにフォーカスをセットします。
//-------------------------------------------------------------------
// 【引数】
// item [String] - 対象となるオブジェクト名 
//-------------------------------------------------------------------

function setFocusObject( item ){

	// 引数内容が空の場合抜ける
	if( item == "" ) return;
	
	// 2008/07/23 mozillaなど向けのバグフィックス
	// getElementById → getElementByName
	if( !document.getElementsByName( item ) ) {
		return;
	}
	
	if( document.getElementsByName( item ).length > 1 ) {
		return;
	}
	
	switch( document.getElementsByName( item )[0].type ){
		case 'button':
		case 'checkbox':
		case 'hidden':
		case 'password':
		case 'option':
		case 'radio':
		case 'select':
		case 'select-one':
		case 'select-multiple':
		case 'submit':
			document.getElementsByName( item )[0].focus();
			break;
		case 'text':
		case 'textarea':
		case 'file':
			document.getElementsByName( item )[0].select();
			document.getElementsByName( item )[0].focus();
	}
	
	/*
	if( !document.getElementById( item ) ) return;
	switch( document.getElementById( item ).type ){
		case 'button':
		case 'checkbox':
		case 'hidden':
		case 'password':
		case 'option':
		case 'radio':
		case 'select':
		case 'submit':
			document.getElementById( item ).focus();
			break;
		case 'text':
		case 'textarea':
		case 'file':
			document.getElementById( item ).select();
			document.getElementById( item ).focus();
	}
	*/ 
}

//-------------------------------------------------------------------
// 機能名：コンボボックスの内容更新
//-------------------------------------------------------------------
// 【引数】
// name     [String] - 対象となるオブジェクト名
// selVal   [int]    - コンボボックスで選択状態とする値
// aryLabel [Array]  - コンボボックスのラベル部を格納した一次元配列
// aryValue [Array]  - コンボボックスの値部を格納した一次元配列
// start    [int]    - 配列上の参照開始位置
// len      [int]    - 配列上での参照数(＝コンボボックスの要素数)
//-------------------------------------------------------------------

function cmnSetItemsForComboBox( name , selVal , aryLabel , aryValue , start , len ){

	var idx = document.getElementById( name ).selectedIndex;
	var objSel = document.getElementById('scid');
	var sel = 0;
	
	for ( i = 0; i < objSel.options.length; i++) {
		objSel.remove(i);
	}
	
	for( i = 0; i < len; i++ ){
		document.getElementById(name).options[ i ] = new Option( aryLabel[ start + i ] , aryValue[ start + i ] );
		if(  aryValue[ start + i ] == selVal ) sel = i;
	}
	
	document.getElementById( name ).selectedIndex = sel;
	
}


