/** |READ ME| **************************************************************************************

"財団法人 対日貿易投資交流促進協会"

JavaScript File
/common/js/library.js

各種制御用JS

Ver.200805

----------------------------------------------------------------------------------------------------

このファイルはロールオーバー制御のJSについて記述されています。

01.グローバル変数定義

02.ロールオーバー制御

03.プルダウン制御
This script and many more are available free online at The JavaScript Source!!
http://javascript.internet.com
Created by: Konstantin Jagello | http://javascript-array.com/

04.表示入替

05.ウィンドウリサイズ対応

************************************************************************************** |READ ME| **/





/** |01.グローバル変数定義| ************************************************************** START **/


var d = document;


/** |01.グローバル変数定義| **************************************************************** END **/





/** |02.ロールオーバー制御| ************************************************************** START **/


function mAct(chPos,bAct){

	if(chPos.firstChild.getAttribute("src")){

		//画像パスの取得
		var chPath = chPos.firstChild.src;

		//画像の切替
		chPos.firstChild.src = (bAct)?chPath.replace("_off","_on"):chPath.replace("_on","_off");

	}

}


/** |02.ロールオーバー制御| **************************************************************** END **/





/** |03.プルダウン制御| ****************************************************************** START **/


var TimeOut = 100;
var currentLayer = null;
var currentitem = null;
var currentLayerNum = 0;
var noClose = 0;
var closeTimer = null;

function mopen(n) {

	var l = d.getElementById("PullDown");

	if(l){
		mcancelclosetime();
		l.style.display='block';
		if(currentLayer && (currentLayerNum != n))currentLayer.style.display='none';
		currentLayer = l;
		currentLayerNum = n;

	} else if(currentLayer) {
		currentLayer.style.display='none';
		currentLayerNum = 0;
		currentitem = null;
		currentLayer = null;
	}

}

function mclosetime() {

	closeTimer = window.setTimeout(mclose, TimeOut);

}

function mcancelclosetime() {

	if(closeTimer) {
		window.clearTimeout(closeTimer);
		closeTimer = null;
	}

}

function mclose() {

	if(currentLayer && noClose!=1) {
		currentLayer.style.display='none';
		currentLayerNum = 0;
		currentLayer = null;
		currentitem = null;
	} else {
		noClose = 0;
	}

	currentLayer = null;
	currentitem = null;

}

d.onclick = mclose;


/** |03.プルダウン制御| ******************************************************************** END **/





/** |04.表示入替| ************************************************************************ START **/


var closing = false;

function closingBlk(chPos,chTgt){

	// 指定ブロックの表示切替
	d.getElementById(chTgt).style.display = (closing)?"none":"block";

	//開閉フラグの保存
	closing = (closing)?false:true;

	//各種情報の取得
	var chPath = chPos.firstChild.src;

	//各種情報の切替
	chPos.firstChild.src = (closing)?chPath.replace("_on","_off"):chPath.replace("_off","_on");
	chPos.firstChild.width = (closing)?166:154;
	chPos.firstChild.alt = (closing)?"小口輸入の流れを閉じる":"小口輸入の流れを見る";
	chPos.title = (closing)?"小口輸入の流れを閉じる":"小口輸入の流れを見る";

	//リンクが動作をさせないためにfalseを返す
	return false;

}


/** |04.表示入替| ************************************************************************** END **/





/** |05.ウィンドウリサイズ対応| ********************************************************** START **/


//クラス取得関数
function getElementsByClass(searchClass) {

	if (document.all) {

		var classElements = new Array();
		var allElements = document.all;

		for (i = 0, j = 0; i < allElements.length; i++) {
			if (allElements[i].className == searchClass) {
				classElements[j] = allElements[i];
				j++;
			}
		}

	} else if (document.getElementsByTagName) {

		var classElements = new Array();
		var allElements = document.getElementsByTagName("*");

		for (i = 0, j = 0; i < allElements.length; i++) {
			if (allElements[i].className == searchClass) {
				classElements[j] = allElements[i];
				j++;
			}
		}

	} else {

		return;

	}

	return classElements;

}


//指定Classの書換
function showFlash() {

	//ドキュメントの横幅
	dW = document.body.clientWidth;
	
	//クラスを取得
	var e = getElementsByClass('frame copy');
	
	// ドキュメントの横幅が 830px 以下であれば
	if (dW <= 830) {
		e[0].style.width = '830px';
	} else {
		e[0].style.width = '100%';
	}

}


/** |05.ウィンドウリサイズ対応| ************************************************************ END **/
