
/* ===============================================
	navi
=============================================== */

/* ===============================================
	レイヤーの表示形式を変更
=============================================== */
function changeLayerDisplay(id,dis){
	if(document.all || document.getElementById){
		if(document.all){
			document.all(id).style.display = dis;
		} else if(document.getElementById){
			document.getElementById(id).style.display = dis;
		}
	}
}

/* ===============================================
	指定された ID領域に記述
=============================================== */
	function writeIdArea(id,writeData){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).innerHTML = writeData;
			} else if(document.getElementById){
				document.getElementById(id).innerHTML = writeData;
			}
		}
	}

/* ===============================================
	レイヤーのx座標設定
=============================================== */
	function setLayerPositionX(id,x){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).style.left = x + "px";
			} else if(document.getElementById){
				document.getElementById(id).style.left	= x + "px";
			}
		}
	}

/* ===============================================
	レイヤーの横幅取得
=============================================== */
	function getLayerSizeX(id){
		if(document.all || document.getElementById){
			if(document.all){
				return document.all(id).style.width;
			} else if(document.getElementById){
				return document.getElementById(id).style.width;
			}
		}
	}

/* ===============================================
  画像変更
=============================================== */
	function changeImage(fileName, imageName){
		document.images[imageName].src = fileName;
	}

	var imgWidth = new Array();

	var action = new Array;
			action['navi01'] = "true";
			action['navi02'] = "true";
			action['navi03'] = "true";
			action['navi04'] = "true";
			action['navi05'] = "true";
			action['navi06'] = "true";
			action['navi07'] = "true";
			action['navi08'] = "true";
	var movAction = new Array;
			movAction['navi01'] = "false";
			movAction['navi02'] = "false";
			movAction['navi03'] = "false";
			movAction['navi04'] = "false";
			movAction['navi05'] = "false";
			movAction['navi06'] = "false";
			movAction['navi07'] = "false";
			movAction['navi08'] = "false";
	var lock = "lockIdName";


	function startMoveNavi(id){
		if( (action[id] == "true") && (movAction[id] == "false") ){
			action[id] = "false";
			movAction[id] = "true";
			startMoveNavi_step00(id);
		}
	}

	var moveArea = 200;
	var moveFrequency = new Array();
			moveFrequency['normal'] = 40;
	var movePxcel = new Array();
	var moveLastPxcel = new Array();
	var moveMaxPxcel = new Array();
	var moveSec = 10;
	var timerID;
	var moveId = new Array;
	function startMoveNavi_step00(id){
		imgWidth[id] = getLayerSizeX(id);
		imgWidth[id] = parseInt(imgWidth[id]);
		moveMaxPxcel[id] = moveArea - imgWidth[id];
		moveFrequency[id] = moveFrequency['normal'];
		movePxcel[id] = parseInt( moveMaxPxcel[id] / moveFrequency[id] );
		if( movePxcel[id] == 0 ){
			movePxcel[id] = 1;
			moveFrequency[id] = moveMaxPxcel[id];
		}
		moveLastPxcel[id] = moveMaxPxcel[id] - ( movePxcel[id] * parseInt( moveFrequency[id] - 1 ) );
 
		moveId[id] = "1";
		startMoveNavi_step01(id);
	}
	function startMoveNavi_step01(id){
		var sec = 0;
		var i;
		for( i=1 ; i <= moveFrequency[id] ; i++ ){
			timerID = setTimeout(function(){startMoveNavi_step0101(id)},moveSec*i);
		}
		timerID = setTimeout(function(){startMoveNavi_step02(id)},moveSec*(moveFrequency[id]+2));
	}
	function startMoveNavi_step0101(id){
		var num = moveId[id];
		num = parseInt(num);
		var setPositionId = id;
		movePxcelCash = movePxcel[id]*num;
		var last = moveArea - imgWidth[id];
		if( num <= moveFrequency[id]-1 ){
			setLayerPositionX(setPositionId,movePxcelCash);
		} else {
			setLayerPositionX(setPositionId,last);
		}
		moveId[id] = num+1;
	}
	function startMoveNavi_step02(id){
		var fileName = "/home/zeroworld/img/navi/"+ id + "_on.gif";
		var imageName = id + "img";
		changeImage(fileName, imageName);
		movAction[id] = "false";
	}


	function endMoveNavi( id ){
		if( lock != id ){
			var waitSec = moveSec * parseInt(moveFrequency[id]);
			if( movAction[id] == "true" ){
//				timerID = setTimeout(function(){endMoveNavi(id)},moveSec*moveFrequency[id]*1);
				timerID = setTimeout(function(){endMoveNavi(id)},moveSec);
			}else if( action[id] == "false" ){
				var setPositionId = id;
				setLayerPositionX(setPositionId,'0');

				var fileName = "/home/zeroworld/img/navi/"+ id + ".gif";
				var imageName = id + "img";
				changeImage(fileName, imageName);

				timerID = setTimeout(function(){action[id] = "true"},moveSec*moveFrequency[id]);
			}
		}
	}





