/* ************************************************************************ */
/* 																	[TAB:4]	*/
/* 	Do-Entry JavaScript														*/
/* 																			*/
/* ************************************************************************ */

/* ************************************************************************ */
/*	半角カナ文字不可	半角カナ→全角カナ　全角英数→半角ASCII				*/
/* ************************************************************************ */
function convHan( obj )
{
	var str;
	
	with ( obj )
	{
		str = value;
		str = str.toNormal();
		value = str;
	}
}

/* ************************************************************************ */
/*	機種依存文字不可														*/
/* ************************************************************************ */
function convNotDepend( obj )
{
	var str;
	
	with ( obj )
	{
		str = value;
		str = str.toNotDepend();
		value = str;
	}
}

/* ************************************************************************ */
function convMailName( obj )
{
	var str;
	
	with ( obj )
	{
		str = value;
		str = str.toNotDepend();
		str = str.toZenkakuKana();
		value = str;
	}
}
/* ************************************************************************ */
/*	貼り付け禁止															*/
/* ************************************************************************ */
function notPast( obj )
{
	alert('貼り付けはできません。入力してください。'); 
	return false;
}

/* ************************************************************************ */
/* 	項目の表示・非表示														*/
/* ************************************************************************ */
function block_disp ( baseid, count, disp )
{
	if (! document.getElementById ) return;
	
	var last_count = ( parseInt( count )  - 1 );
	
	// 各種項目表示
	document.getElementById( baseid + '_' + count ).style.display = disp;
	
	if ( disp == "none" )
	{
		// 項目の非表示
		document.getElementById( baseid + '_' + count + '_id').value = "";
		
		// 追加ボタンの表示
		document.getElementById( baseid + '_' + last_count + '_add' ).style.display = "block";
	}
	else if ( disp == "block" )
	{
		// 項目の表示
		document.getElementById( baseid + '_' + count + '_id').value = count;
		
		// 追加ボタンの非表示
		document.getElementById( baseid + '_' + last_count + '_add' ).style.display = "none";
	}
}

/* ************************************************************************ */
/* Tab On / Off 															*/
/* ************************************************************************ */
// hpref = tab header prefix
// bpref = tab body prefix
// id_max
// selected
function selTab( hpref, bpref, id_max, selected, className ) 
{
	if ( ! document.getElementById ) return;
	
	for ( var i = 1; i <= id_max; i++ ) 
	{
		if ( ! document.getElementById( bpref + "_" + i ) ) continue;
		if ( ! document.getElementById( hpref + "_" + i ) ) continue;
		
		var tab_body 	= document.getElementById( bpref + "_" + i );
		var tab_header 	= document.getElementById( hpref + "_" + i );
		
		if ( i == selected ) 
		{
			tab_body.style.visibility = "visible";
			tab_body.style.display = "block";
			tab_body.style.position = "";
			tab_header.className = className + "_open";
			
		} 
		else 
		{
			tab_body.style.visibility = "hidden";
			tab_body.style.display = "none";
			tab_body.style.position = "absolute";
			tab_header.className = className +  "_close";
		}
		
		if ( document.getElementById( hpref + "_" + i + "_L" ) )
		{
			var tab_header_L = document.getElementById( hpref + "_" + i + "_L" );
			if ( i == selected ) 
			{
				tab_header_L.className = className + "_open_L";
			}
			else
			{
				tab_header_L.className = className + "_close_L";
			}
		}
		
		if ( document.getElementById( hpref + "_" + i + "_C" ) )
		{
			var tab_header_C = document.getElementById( hpref + "_" + i + "_C" );
			if ( i == selected ) 
			{
				tab_header_C.className = className + "_open_C";
			}
			else
			{
				if ( i + 1 == selected)
				{
					tab_header_C.className = className + "_close_C";
				}
				else
				{
					tab_header_C.className = className + "_close_C_2";
				}
			}
		}
		
		if ( document.getElementById( hpref + "_" + i + "_R" ) )
		{
			var tab_header_R = document.getElementById( hpref + "_" + i + "_R" );
			if ( i == selected ) 
			{
				tab_header_R.className = className + "_open_R";
			}
			else
			{
				tab_header_R.className = className + "_close_R";
			}
		}
	}
}

/* ************************************************************************ */
// history.backが成功したかどうかを判別する
/* ************************************************************************ */
// 使い方
// 戻るに失敗したときの処理
// try_back(function(){window.status="戻る失敗"});
// もしくは戻るに失敗したときにジャンプするURL
// try_back("http://example.com");
// 
// http://la.ma.la/blog/diary_200609011825.htm
/* ************************************************************************ */
function try_back(errback)
{
	var bs = false;
	
//	Event.observe(window,"unload",function(){bs=true});
//	Event.observe(window,"beforeunload",function(){bs=true});
	history.back();
	
	switch(typeof errback)
	{
		case "function": setTimeout(function(){if(!bs) errback()},100); break;
		case "string"  : setTimeout(function(){if(!bs) location.href=errback},100); break;
	}
	return bs;
}
/* ************************************************************************ */
//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
//
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
/* ************************************************************************ */
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

/* ************************************************************************ */
/* [EOF]																	*/
/* ************************************************************************ */

