/**********************************************************************
Tokio Marine & Nichido Fire Insurance Co., Ltd. : js [ common.js ]

06.07.28
***********************************************************************
a variable : gCmxxx
a function : style_xxx / global_xxx / active_xxx / flash_xxx
**********************************************************************/


/*------------------------------------------------------
 Path
------------------------------------------------------*/
var gCmFlg = 1;    // 0 -> real , 1 -> test , 2 -> template
var gCmRootPath = '';

if( gCmFlg == 0 )     { gCmRootPath = '/'; }
else if( gCmFlg == 1 ){ gCmRootPath = '/'; }
else                  { gCmRootPath = '../'; }

var gCmImgPath = gCmRootPath + 'common/img/';
var gCmEnImgPath = gCmRootPath + 'common/en/img/';

/*------------------------------------------------------
 Font Size
------------------------------------------------------*/
var gCmCookieName = 'MARINE_TEXT_SIZE';
var gCmCookieData = style_getCookie();

if( gCmCookieData == '' ){ gCmCookieData = 'M'; }


/*------------------------------------------------------
 Style
------------------------------------------------------*/
with( document ){
	write('<link rel="stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/contents.css" media="all">');
	write('<link rel="stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/base.css" media="all">');
	write('<link rel="stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/print.css" media="print">');
	write('<link rel="stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/txsize_' + gCmCookieData + '.css" media="all">');
	write('<link rel="alternate stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/txsize_M.css" title="M" media="all">');
	write('<link rel="alternate stylesheet" type="text/css" href="' + gCmRootPath + 'common/en/css/txsize_L.css" title="L" media="all">');
}

/*------------------------------------------------------
 Other Variable
------------------------------------------------------*/
var gGnActiveImg = '';

/*------------------------------------------------------
 Image Preload
------------------------------------------------------*/
global_load(
	gCmEnImgPath + 'gn_btn01_on.gif',
	gCmEnImgPath + 'gn_btn02_on.gif',
	gCmEnImgPath + 'gn_btn03_on.gif',
	gCmEnImgPath + 'gn_btn04_on.gif',
	gCmEnImgPath + 'gn_btn05_on.gif',
	gCmEnImgPath + 'gn_btn06_on.gif'
);

/*======================================================
 open_popup()
======================================================*/
function open_popup(mUrl,mName,mWid,mHgt){
	var mOpt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + mWid + ",height=" + mHgt;
	var mWin = window.open(mUrl,mName,mOpt);
	mWin.focus();
}


/*======================================================
 style_getCookie()
======================================================*/
function style_getCookie(){
	var mCk = '';
	var mCk_ary  = document.cookie.split(';');
	var mKey = gCmCookieName + '=';
	var mStr = '';
	var mRet = '';

	for( var i = 0; i < mCk_ary.length; i ++ ){
		if( mCk_ary[i].indexOf(mKey) >= 0 ){
			mCk = mCk_ary[i].replace(/ /i,'');
		}
	}
	if( mCk.indexOf(mKey) >= 0 ){
		mStr = mCk.indexOf(mKey) + mKey.length;
		mRet = mCk.substr(mStr,1);
	}
	return mRet;
}

/*======================================================
 style_setCookie()
======================================================*/
function style_setCookie(wk){
	var mCkData = gCmCookieName + '=' + wk + ';';
	var mCkDoc  = 'domain=' + document.domain + ';';
	var mCkPath = 'path=/;';

	var mDates  = 30;   // Days at expiration date
	var mSetDay = new Date();
	mSetDay.setTime(mSetDay.getTime() + (mDates*1000*60*60*24));
	var mCkTerm = 'expires=' + mSetDay.toGMTString() + ';';

	document.cookie = mCkData + mCkDoc + mCkPath + mCkTerm;
	//alert(document.cookie);
}

/*======================================================
 style_change()
======================================================*/
function style_change(mArg){
	var mStTag = document.getElementsByTagName('link');
	var mStStart = 4;
	var mStLeng  = 6;

	for( var i = mStStart; i < mStLeng; i ++ ){

		mStTag[i].disabled = true;

		if( mStTag[i].getAttribute('title') == mArg ){
			mStTag[i].disabled = false;
		}
	}
	style_setCookie(mArg); // cookie
	style_actImage(mArg);  // image
}

/*======================================================
 style_actImage()
======================================================*/
function style_actImage(mArg){
	var mName_M = 'tx_btn_m';
	var mName_L = 'tx_btn_l';
	var mImg_M  = document.images[mName_M];
	var mImg_L  = document.images[mName_L];

	if( mArg == 'M' ){
		mImg_M.src = gCmEnImgPath + mName_M + '_on.gif';
		mImg_L.src = gCmEnImgPath + mName_L + '.gif';
	}
	else if( mArg == 'L' ){
		mImg_M.src = gCmEnImgPath + mName_M + '.gif';
		mImg_L.src = gCmEnImgPath + mName_L + '_on.gif';
	}
}

/*======================================================
 global_load()
======================================================*/
function global_load(){
	var mAry = new Array();
	for( var i = 0; i < global_load.arguments.length; i ++ ){
		mAry[i] = new Image();
		mAry[i].src = global_load.arguments[i];
		//document.write("<img src='" + mAry[i].src + "'><br>");
	}
}

/*======================================================
 global_over()
======================================================*/
function global_over(mName){
	if( mName == '' || mName == null ){ return; }
	var mImg = document.images[mName];
	if( mImg && gGnActiveImg != mName ){
		mImg.src = gCmEnImgPath + mName + '_on.gif';
	}
}

/*======================================================
 global_out()
======================================================*/
function global_out(mName){
	if( mName == '' || mName == null ){ return; }
	var mImg = document.images[mName];
	if( mImg && gGnActiveImg != mName ){
		mImg.src = gCmEnImgPath + mName + '.gif';
	}
}

/*======================================================
 active_header()
======================================================*/
function active_header(mName){
	if( mName == '' || mName == null ){ return; }
	var mObj = document.getElementById(mName);
	if( mObj ){
		mObj.style.backgroundImage = 'url(' + gCmImgPath + 'hd_icon_on.gif)';
		mObj.style.backgroundColor = '#1673C1';
		mObj.style.color = '#FFFFFF';
	}
}

/*======================================================
 active_global()
======================================================*/
function active_global(mName){
	if( mName == '' || mName == null ){ return; }
	var mImg = document.images[mName];
	if( mImg ){
		mImg.src = gCmEnImgPath + mName + '_on.gif';
	}
	gGnActiveImg = mName;
}

/*======================================================
 active_ftglobal()
======================================================*/
function active_ftglobal(mName){
	if( mName == '' || mName == null ){ return; }
	var mObj = document.getElementById(mName);
	if( mObj ){
		mObj.style.color = '#A0B2B8';
	}
}

/*======================================================
 open_pop()
======================================================*/
function open_pop(mUrl,mName,mWid,mHgt){
	var mOpt = "toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=" + mWid + ",height=" + mHgt;
	var mWin = window.open(mUrl,mName,mOpt);
	mWin.focus();
}

/*********************************************************************/

