//=================================
// Initialize Bandits()
var bdtFlg=false;

function Bandits( tagName , bdtWdt , bdtHgt ){
	//=================================
	//　Bandits()
	//　Ver2.1 / 2006.09.06
	//　tagName=タグ配列名
	//　bdtWdt=レイヤー横幅
	//　bdtHgt=レイヤー高さ
	//=================================
	//ウインドウサイズ、オフセット取得
	bkX=(window.ActiveXObject) ? document.body.scrollLeft : window.pageXOffset;
	bkY=(window.ActiveXObject) ? document.body.scrollTop : window.pageYOffset;
	bkWidth=(window.ActiveXObject) ? document.body.clientWidth : window.innerWidth;
	bkHeight=(window.ActiveXObject) ? document.body.clientHeight : window.innerHeight;

	//バックグラウンド
	setOverlay("overlay","#000000",bkX,bkY,bkWidth,bkHeight,50,"");
	moveOpacity("overlay",0,70,70);
	//レイヤー座標
	bdtLft=Math.round((bkWidth-bdtWdt)/2+bkX);
	bdtTop=Math.round((bkHeight-bdtHgt)/2+bkY);
	//HTML生成
	var tag=inrtag[tagName];
	setOverlay("bandits","#FFFFFF",bdtLft,bdtTop,bdtWdt,bdtHgt,52,tag);
	moveOpacity("bandits",0,100,10);
	tag='　';
	setOverlay("banditsShadow","#000000",bdtLft+3,bdtTop+3,bdtWdt,bdtHgt,51,tag);
	moveOpacity("banditsShadow",0,20,10);
	bdtFlg=true;
}

function clearBandits(){
	//=================================
	//　clearBandits()
	//　Ver1.0 / 2006.08.19
	//=================================
	document.getElementById("overlay").style.visibility="hidden";
	document.getElementById("bandits").style.visibility="hidden";
	document.getElementById("banditsShadow").style.visibility="hidden";
}

function offsetBandits(){
	//=================================
	//　offsetBandits()
	//　Ver1.2 / 2006.09.06
	//=================================
	if(bdtFlg){
		bkWidth=(window.ActiveXObject) ? document.body.clientWidth : window.innerWidth;
		bkHeight=(window.ActiveXObject) ? document.body.clientHeight : window.innerHeight;
		bkX=(window.ActiveXObject) ? document.body.scrollLeft : window.pageXOffset;
		bkY=(window.ActiveXObject) ? document.body.scrollTop : window.pageYOffset;
		//bandits オブジェクト縦・横取得
		bw=eval((document.getElementById('bandits').style.width).replace('px',''));
		bh=eval((document.getElementById('bandits').style.height).replace('px',''));
		//新座標計算
		bdtLft=Math.round((bkWidth-bw)/2);
		bdtTop=Math.round((bkHeight-bh)/2);
		//位置変更
		moveToOverlay('bandits',bdtLft,bdtTop);
		moveToOverlay('banditsShadow',bdtLft+3,bdtTop+3);
		//バックグラウンド面積変更
		document.getElementById('overlay').style.width=bkWidth;
		document.getElementById('overlay').style.height=bkHeight;
	}
}

function setOverlay( ovlyID , ovlyColor , x , y , wdt , hgt , zidx , tag ){
	//=================================
	//　setOverlay()
	//　Ver 1.0 / 2006.07.14
	//　ovlyID=オブジェクトID
	//　ovlyColor =背景色(16進数)
	//　x=横座標　y=縦座標　wdt=横幅　hgt=縦幅
	//　tag=オブジェクトにストリームするHTML
	//=================================
	var Ovly=document.getElementById(ovlyID);
	Ovly.style.visibility="hidden";
	Ovly.style.position="absolute";

	if(ovlyColor=="PNG") {
		Ovly.style.backgroundColor="transparent";
		Ovly.innerHTML=pngLoader(wdt,hgt,tag);
	//PNGではない場合
	}else{
		Ovly.style.backgroundColor=ovlyColor;
		if(tag != "")Ovly.innerHTML=tag;
	}
	Ovly.style.left=x;
	Ovly.style.top=y;
	Ovly.style.width=wdt;
	Ovly.style.height=hgt;
	Ovly.style.zIndex=zidx;
	Ovly.style.visibility="visible";
}

//以下 Win IE 用 (暫定プログラム)===========
function pngLoader( wdt , hgt , pngURL ){
	//=================================
	//　pngLoader()
	//　Ver1.0 / 2006.07.14
	//　wdt=PNG横幅
	//　hgt=PNG縦幅
	//　pngURL=PNGのURL
	//=================================
	//Win IEの場合AlphaImageLoaderを使用
	if(window.ActiveXObject){
		var AlpLdr='<DIV STYLE="width:'+wdt+'px;height:'+hgt+'px;';
		AlpLdr=AlpLdr+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+pngURL+'\',sizingMethod=\'scale\');"></DIV>';
		//それ以外はIMGで処理
	}else{
		AlpLdr='<IMG SRC="'+pngURL+'" WIDTH="'+wdt+'" HEIGHT="'+hgt+'" VSPACE="0" HSPACE="0" BORDER="0">';
	}
	return AlpLdr;
}
//=================================

function moveOpacity( ovlyID , dftOp , lmtOp , opV ){
	//=================================
	//　moveOpacity()
	//　Ver1.0 / 2006.07.14
	//　ovlyID=オブジェクトID
	//　dftOp=開始不透明度(0〜100)
	//　lmtOp=終了不透明度(0〜100)
	//　※ dftOp > lmtOpでも可
	//=================================
	tmrFlag=false
	var vinc=(dftOp<lmtOp) ? opV : -1*opV;
	dftOp=dftOp+vinc;
	//指定オブジェクトの不透明度設定
	var Ovly=document.getElementById(ovlyID);
	Ovly.style.opacity=dftOp/100;
	Ovly.style.mozOpacity=dftOp/100;
	Ovly.style.filter="alpha(opacity="+dftOp+")";
	//タイマー設定
	var timerID=setTimeout("moveOpacity('"+ovlyID+"',"+dftOp+","+lmtOp+","+opV+")", 10);
	if( (dftOp>=lmtOp && vinc==opV) || (dftOp<=lmtOp && vinc==-1*opV) ){
		clearTimeout(timerID);
		if(lmtOp==0)Ovly.style.visibility="hidden";
	}
}

function moveToOverlay( ovlyID , mX , mY){
	//=================================
	//　moveToOverlay()
	//　Ver1.0 / 2006.08.29
	//　ovlyID=オブジェクトID
	//　mX=X座標　mY=Y座標
	//=================================
	document.getElementById(ovlyID).style.left=mX;
	document.getElementById(ovlyID).style.top=mY;
}

function getPageCenter(pW){
	//=================================
	//　getPageCenter()
	//　Ver1.0 / 2006.09.22
	//　pW=ページレイアウト幅
	//=================================
	bkWidth=(window.ActiveXObject) ? document.body.clientWidth : window.innerWidth;
	return Math.ceil((bkWidth-pW)/2);
}

//=================================
// Initialize glideOverlay()
var wx=new Array(),wy=new Array(),ex=new Array(),ey=new Array()
var spd=new Array(),step=new Array(),stepX=new Array(),stepY=new Array()
var mvFlg=new Array(),slideID=new Array()

function glideOverlay( ovlyID , strX , strY , endX , endY , speed , stpx ){
	//=================================
	//　glideOverlay()
	//　Ver1.0 / 2006.08.22
	//　ovlyID=オブジェクトID
	//　strX , strY=開始位置　endX , endY=終了位置
	//　speed=速度　stpx=ステップ
	//=================================
	if(!mvFlg[ovlyID]){
		//移動初期化
		var ofX=(endX-strX);	//距離X
		var ofY=(endY-strY);	//距離Y
		//ステップ
		step[ovlyID]=Math.max(Math.abs(ofX),Math.abs(ofY))/stpx;	
		stepX[ovlyID]=ofX/step[ovlyID];	//移動量（距離X／ステップ）
		stepY[ovlyID]=ofY/step[ovlyID];	//移動量（距離Y／ステップ）
		wx[ovlyID]=strX;	//移動中X
		wy[ovlyID]=strY;	//移動中Y
		ex[ovlyID]=endX;	//到着X
		ey[ovlyID]=endY;	//到着Y
		spd[ovlyID]=speed;	//スピード
		mvFlg[ovlyID]=true;	//移動=true
	}
	if( mvFlg[ovlyID] && wx[ovlyID]<=ex[ovlyID] && wy[ovlyID]<=ey[ovlyID] ){
		wx[ovlyID]+=stepX[ovlyID];
		wy[ovlyID]+=stepY[ovlyID];
		slideID[ovlyID]=setTimeout("glideOverlay('"+ovlyID+"')",spd[ovlyID]);
	}else{
		//停止
		clearTimeout(slideID[ovlyID]);
		mvFlg[ovlyID]=false;
	}
	document.getElementById(ovlyID).style.left=wx[ovlyID];
	document.getElementById(ovlyID).style.top=wy[ovlyID];
}

//=================================
// Initialize wipeClipOverlay()
var wipeFlag=false;
var t,r,b,l
var wiptID=setTimeout('',1);

function wipeClipOverlay( ovlyID , stT , stR , stB , stL , endT , endR , endB , endL , step ){
	//=================================
	//　wipeClipOverlay()
	//　Ver1.0 / 2006.08.23
	//　ovlyID=オブジェクトID
	//　stT , stR  , stB , stL =開始位置
	//　endT , endR , endB , endL=終了位置
	//　※↑トップ、ライト、ボトム、レフト
	//　step=ステップ
	//=================================
	if(!wipeFlag){
		t=stT;r=stR;b=stB;l=stL;
		stepT=(Math.max(t,endT)-Math.min(t,endT))/step;	//step計算
		stepR=(Math.max(r,endR)-Math.min(r,endR))/step;
		stepB=(Math.max(b,endB)-Math.min(b,endB))/step;
		stepL=(Math.max(l,endL)-Math.min(l,endL))/step;
		clipvalue  = t+','+r+','+b+','+l+',';
		clipvalue += endT+','+endR+','+endB+','+endL+','+step;
		wipeFlag=true;
	}
	if(t>endT)t-=stepT;
	if(r<endR)r+=stepR;
	if(b<endB)b+=stepB;
	if(l>endL)l-=stepL;
	if(!(t>endT)&&!(r<endR)&&!(b<endB)&&!(l>endL)){	clearTimeout(wiptID);
	}else{ wiptID=setTimeout('wipeClipOverlay("'+ovlyID+'",'+clipvalue+')',10);}
	document.getElementById(ovlyID).style.clip="rect("+t+","+r+","+b+","+l+")";
}