/**********************************************************************
project name : NUMO [ common.js ]

08.11.18
***********************************************************************/
/*==============================================
 Path
==============================================*/
var gCm_strServerFlg  = 'real';   // real -> 本サーバ , test -> テストサーバ, local -> ローカル環境
//var gCm_strServerFlg  = 'local';   // real -> 本サーバ , test -> テストサーバ, local -> ローカル環境
var gCm_strProtcolFlg = 'http';  // http -> 通常 , https -> SSL領域

var gCm_strRootPath = '';
var gCm_strImgPath  = '';

var gCm_strDomain   = '';

var gCm_strSetupRootPath        = ''; // http用ルートパス
var gCm_strSetupCommonPath      = ''; // http用Commonパス

var gCm_strSetupRootPath_ssl    = ''; // https用ルートパス
var gCm_strSetupCommonPath_ssl  = ''; // https用Commonパス

//ドライブ直下からのローカルフルパス（ローカル環境で実施する場合限定）
var gCm_strTopDir = "/NUMO/";

//---------------------------------------------
//本サーバ
//---------------------------------------------
if (gCm_strServerFlg == 'real') {  // 本サーバ
	// domain
  gCm_strDomain = 'www.numo.or.jp';
	
	// http
	gCm_strSetupRootPath        = 'http://' + gCm_strDomain;
	gCm_strSetupCommonPath      = gCm_strSetupRootPath + '/en/common';
	// https
	gCm_strSetupRootPath_ssl    = 'https://' + gCm_strDomain;
	gCm_strSetupCommonPath_ssl  = 'https://' + gCm_strDomain + '/en/common';
}

//---------------------------------------------
//テストサーバ
//---------------------------------------------
else if (gCm_strServerFlg == 'test') {  // テストサーバ
	// domain
  gCm_strDomain = 'numo.preview.i-studio.co.jp';
	
	// http
	gCm_strSetupRootPath        = 'http://' + gCm_strDomain;
	gCm_strSetupCommonPath      = gCm_strSetupRootPath + '/en/common';
	// https
	gCm_strSetupRootPath_ssl    = 'https://' + gCm_strDomain;
	gCm_strSetupCommonPath_ssl  = 'https://' + gCm_strDomain + '/en/common';
}

//---------------------------------------------
//ローカルサーバ
//---------------------------------------------
else if (gCm_strServerFlg == 'local') {  // ローカル環境
	// domain
  gCm_strDomain = gCm_getRelativePath(gCm_strTopDir);

	// http
	gCm_strSetupRootPath        = gCm_strDomain;
	gCm_strSetupCommonPath      = gCm_strSetupRootPath + '/en/common';
	// https
	gCm_strSetupRootPath_ssl    = gCm_strDomain;
	gCm_strSetupCommonPath_ssl  = gCm_strDomain + '/en/common';

//---------------------------------------------
//上記以外
//---------------------------------------------
} else {
	// それ以外
	alert('正しい [gCm_strServerFlg] を設定してください。');
}

/*==============================================
 Include
==============================================*/
document.writeln('<script type="text/javascript" src="' + gCm_strSetupRootPath + '/en/common/js/rollover.js"></script>');
document.writeln('<script type="text/javascript" src="' + gCm_strSetupRootPath + '/en/common/js/flashcheck.js"></script>');
document.writeln('<script type="text/javascript" src="' + gCm_strSetupRootPath + '/en/common/js/htmlparts.js"></script>');
document.writeln('<script type="text/javascript" src="' + gCm_strSetupRootPath + '/en/common/js/current.js"></script>');
document.writeln('<script type="text/javascript" src="' + gCm_strSetupRootPath + '/en/common/js/popup.js"></script>');

// JavaScript Document






/*==============================================
 getRelativePath
==============================================*/
function gCm_getPathLtoR(vstrTopDir){
  
  //トップディレクトリのローカルフルパス
  var strTopDir = vstrTopDir.toLowerCase();
  
  //ユーザーエージェント
  var strUA = navigator.userAgent.toLowerCase();

  //ローカルパス変換
  var strLocalPath = location.href;
  
  //-= debug =-
  //strLocalPath = "file:///localhost/Volumes/VOLLABEL/NUMO/about_numo/outline/gyoumu_houhousho/template.html";
  //strUA = "mac";
  //-= debug =-

  strLocalPath = strLocalPath.toLowerCase();                //全て小文字に変換
  strLocalPath = strLocalPath.replace(/\\/g,"/");           //\マークを全て[/]にかえる
  strLocalPath = strLocalPath.replace(/file:\/\/\//g,"");   //ファイルプロトコルを削除
  strLocalPath = strLocalPath.replace(/file:\/\//g,"");     //ファイルプロトコルを削除
  strLocalPath = strLocalPath.replace(/^.+?:/g,"");         //ドライブ名を削除する
  if (strUA.indexOf("mac") != -1 ){
    strLocalPath = strLocalPath.replace(/localhost\//,"");  //Localhost削除
    strLocalPath = strLocalPath.replace(/volumes\//,"");    //Volumes削除
    strLocalPath = strLocalPath.replace(/^.+?\//,"/");    //Volumes削除
  }
  strLocalPath = strLocalPath.replace(strTopDir,"");        //トップパスまでのディレクトリを削除

  return strLocalPath;
}

/*==============================================
 getRelativePath
==============================================*/
function gCm_getRelativePath(vstrTopDir){
  
  //ルートパスに変換
  strLocalPath = gCm_getPathLtoR(vstrTopDir);
  
  //相対パスに変換
  var intDirCnt = 0;
  if (strLocalPath.indexOf("/") > -1){
    astrTemp = strLocalPath.split("/");
    astrTemp.pop();
    intDirCnt = astrTemp.length;
  }
  strRelativPath = "";
  for (i=0; i<intDirCnt; i++){
    strRelativPath += "../";
  }
  strRelativPath = strRelativPath.replace(/\/$/, "");
  if (strRelativPath == ""){
    strRelativPath = ".";
  }

  return strRelativPath;
}