﻿/****************************************************************
  関数名：fTrim
  戻り値：トリム後の文字列
  用途　：文字列の先頭または末尾の全角・半角スペースを除く
****************************************************************/
String.prototype.fTrim = function() {
    return this.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"");
}

/*************************************************************
 関数名：fOnKeypress()
 引数１：イベント
 引数２：Clickイベントを実行するボタンID
 用途　：キー押下時の処理。
         Enterが押下された場合はClickイベントを呼び出す。
*************************************************************/
function fOnKeypress(e, btnID) {
  //Enterの場合は検索
  if(e.keyCode==13)
  {
    document.getElementById(btnID).click();
    return false;
  }
  return true;
  
}
/****************************************************************
  関数名：fBrowserInfo
  戻り値：なし
  用途　：クライアントのブラウザ情報を取得
****************************************************************/
function fBrowserInfo(userAgent) {

	/*****************************************
	 * IEバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.ieVersionChecker = function(){
		var ienum = this.ua.match(new RegExp("MSIE [0-9]{1,2}\.[0-9]{1,3}"));
		return ( ienum == null ) ? -1 : parseFloat(String(ienum).replace("MSIE ",""));
	}
	

	/*****************************************
	 * Firefoxバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.firefoxVersionChecker = function(){
		var num = this.ua.match(new RegExp("Firefox/[0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Firefox/",""));
	}

	/*****************************************
	 * Operaバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.operaVersionChecker = function(){
		var num = this.ua.match(new RegExp("Opera[/ ][0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).substr(6));
	}

	/*****************************************
	 * Safariバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.safariVersionChecker = function(){
		var num = this.ua.match(new RegExp("Safari/[0-9]{1,4}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Safari/",""));
	}

	/*****************************************
	 * Netscapeバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.netscapeVersionChecker = function(){
		var num = this.ua.match(new RegExp("Netscape[0-9]?/[0-9]{1,2}\.[0-9]{1,3}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace(new RegExp("Netscape[0-9]?/"),""));
	}

	/*****************************************
	 * Mozillaバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.mozillaVersionChecker = function(){
		var num = this.ua.match(new RegExp("Mozilla/[0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Mozilla/",""));
	}
	// -- コンストラクタ --

	this.ua = (userAgent) ? userAgent : navigator.userAgent;

	this.ieVersion = this.ieVersionChecker();
	this.ieMVersion = Math.floor(this.ieVersion);
	this.ie = ( this.ieVersion >= 3 );
	this.macie = ( this.ua.match("Mac_PowerPC") != null );
	// IE8の互換ビュー
	this.isIE8CompatibleView = ( this.ieMVersion == 7 && this.ua.indexOf('Trident/4.0') > -1 );

	this.firefoxVersion = this.firefoxVersionChecker();
	this.firefoxMVersion = Math.floor(this.firefoxVersion);
	this.firefox = (this.firefoxVersion > 0 );

	this.safariVersion = this.safariVersionChecker();
	this.safariMVersion = Math.floor(this.safariVersion);
	this.safari = (this.safariVersion > 85 );

	this.operaVersion = this.operaVersionChecker();
	this.operaMVersion = Math.floor(this.operaVersion);
	this.opera = (this.operaVersion > 1 );
	
	this.netscapeVersion = this.netscapeVersionChecker();
	this.netscapeMVersion = Math.floor(this.netscapeVersion);
	this.netscape = (this.netscapeVersion > 1 );
	
	this.mozillaVersion = this.mozillaVersionChecker();
	this.mozilla = ( !this.firefox && !this.opera && !this.ie && !this.netscape && this.mozillaVersion > 0 ); 
}

/*************************************************************
 関数名：AppDispPopUp()
 引数１：strLnkURL リンク先
 戻り値：なし
 用途　：ポップアップで画面を表示する
*************************************************************/
function AppPopupLnk_click(strLnkURL){
    window.open("/med/jp/sitetran.aspx?path=" + strLnkURL,"","location=yes, menubar=yes, toolbar=yes, status=yes, scrollbars=yes, resizable=yes");
}

function AppPopupLnk_mouseover(eleLnk, strLnkURL){
    document.body.style.cursor = "hand";
    window.status = strLnkURL;
    //eleLnk.onclick=function(){AppPopupLnk_click(strLnkURL);};
    eleLnk.onmouseout=function(){AppPopupLnk_mouseout();};
    
}
function AppPopupLnk_mouseout(){
    document.body.style.cursor = "default";
    window.status = "";
}

/* windowイベントハンドラ登録処理 -start- */

var App_AppHdlSt;
var App_AppHdlEd;
var App_ConHdlSt;
var App_ConHdlEd;
var App_C_STAPP = 'App_AppHdlSt';
var App_C_EDAPP = 'App_AppHdlEd';
var App_C_STCON = 'App_ConHdlSt';
var App_C_EDCON = 'App_ConHdlEd';

/*************************************************************
 関数名：AppHandlerWrite()
 引数１：Method名
 引数２：ハンドラ
 用途　：windowイベントハンドラ書き込み処理
*************************************************************/
function AppHandlerWrite(
	 strMethod	// Method名
	,strHandler	// ハンドラ
)
{
	document.write(
		  '\n<script type = "text/javascript"><' + '!--\n'
		+ 'window.' + strMethod + ' = function(){' + strHandler + '}\n'
		+ '//-->\n'
		+ '<' + '/script>'
	);

	return;
}


/*************************************************************
 関数名：AppHandlerGetHandler()
 引数１：ハンドラ
 引数２：開始マーク
 引数３：終了マーク
 戻り値：イベントハンドラテキスト
 用途　：イベントハンドラテキスト抽出処理
*************************************************************/
function AppHandlerGetHandler(
	 strHandler	//
	,strStMark	//
	,strEdMark	//
)
{
	var strHandlerText;
	var intSt;
	var intEd;

	strHandlerText = "";
	intSt = strHandler.indexOf( strStMark );
	intEd = strHandler.indexOf( strEdMark );
	if( (0 <= intSt) && (intSt < intEd) )
	{
		strHandlerText = strHandler.substring( intSt ,intEd ) + strEdMark + '=0;';
	}

	return strHandlerText;
}

/*************************************************************
 関数名：AppSetAppHandler()
 引数１：Method名　例)'onload'
 引数２：現在のハンドラ値　例)window.onload
 引数３：新しいハンドラfunctionコール文　例)'ConOnLoad();'
 引数４：呼び出し優先フラグ（ConハンドラとAppハンドラが設定されている場合に
         どちらを先に呼び出すかのフラグ0以外:Con優先  0:App優先）
 戻り値：なし
 用途　：アプリ用イベントハンドラ設定処理
*************************************************************/
function AppSetAppHandler(
	 strMethodName
	,strNowHandler
	,strNewHandler
	,intfConYusen 
)

{
	var strVal;

	strVal = App_C_STAPP + '=0;' + strNewHandler + App_C_EDAPP + '=0;';

	if( null != strNowHandler )
	{

		var strSrc = String( strNowHandler );
		var strConHandler;
		strConHandler = AppHandlerGetHandler( strSrc ,App_C_STCON ,App_C_EDCON );

		if( (null != strConHandler) && ('' != strConHandler) )
		{
			if( 0 != intfConYusen )
			{
				strVal = strConHandler + ';' + strVal;
			}
			else
			{
				strVal = strVal + ';' + strConHandler;
			}
		}
	}

	AppHandlerWrite( strMethodName ,strVal );

	return;
}

/*************************************************************
 関数名：AppSetConHandler()
 引数１：Method名　例)'onload'
 引数２：現在のハンドラ値　例)window.onload
 引数３：新しいハンドラfunctionコール文　例)'ConOnLoad();'
 引数４：呼び出し優先フラグ（ConハンドラとAppハンドラが設定されている場合に
         どちらを先に呼び出すかのフラグ0以外:Con優先  0:App優先）
 戻り値：なし
 用途　：コンテンツ用イベントハンドラ設定処理
*************************************************************/
function AppSetConHandler(
	 strMethodName
	,strNowHandler
	,strNewHandler
	,intfConYusen
)

{
	var strVal;

	strVal = App_C_STCON + '=0;' + strNewHandler + App_C_EDCON + '=0;'; 
	if( null != strNowHandler )
	{
		var strSrc = String(strNowHandler);
		var strAppHandler;
		strAppHandler = AppHandlerGetHandler( strSrc ,App_C_STAPP ,App_C_EDAPP );
		if( (null != strAppHandler) && ('' != strAppHandler) )
		{
			if( 0 != intfConYusen )
			{
				strVal = strVal + ';' + strAppHandler;
			}
			else
			{
				strVal = strAppHandler + ';' + strVal;
			}
		}
	}
	AppHandlerWrite( strMethodName ,strVal );
	return;
}

/* windowイベントハンドラ登録処理 -End- */
