document.onload=stt();

// Defining the global arguments

// Determing Browser Type and Version with JavaScript
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// http://www.mozilla.org/docs/web-developer/sniffer/browser_type_oo.html

function Is (){

	var agt=navigator.userAgent.toLowerCase();

	// Browser
	this.major=parseInt(navigator.appVersion);

	this.nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	this.nav4up = (this.nav && (this.major >= 4));

	this.gecko = (agt.indexOf('gecko') != -1);

	this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	this.ie3 = (this.ie && (this.major < 4));
	this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	this.ie4up = (this.ie && (this.major >= 4));
	this.ie5up = (this.ie && !this.ie3 && !this.ie4);
	this.ie5_5up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5);
	this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
	this.ie6up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);

	this.opera = (agt.indexOf("opera") != -1);

	// OS
	this.win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
	this.mac = (agt.indexOf("mac")!=-1);

	this.linux = (agt.indexOf("inux")!=-1);
}

var is;
is=new Is();

// END of Determing Browser Type and Version with JavaScript


// Only for Internet Explorer 5 or upper on Windows
function tpstt(){
	if(is.ie5up && is.win){
		document.getElementById("mvlay").style.visibility="visible";
	}
}

function stt(){

	skyz110=new Image();
	skyz110.src="images/z110.gif";

	skyz120=new Image();
	skyz120.src="images/z120.gif";

	skyz130=new Image();
	skyz130.src="images/z130.gif";

	skyz140=new Image();
	skyz140.src="images/z140.gif";

	skyz150=new Image();
	skyz150.src="images/z150.gif";

	skyz160=new Image();
	skyz160.src="images/z160.gif";

	skyz170=new Image();
	skyz170.src="images/z170.gif";

	sq005=new Image();
	sq005.src="images/q005.gif";

	sq006=new Image();
	sq006.src="images/q006.gif";

	sq007=new Image();
	sq007.src="images/q007.gif";

	sq111=new Image();
	sq111.src="images/q111.gif";

	sq112=new Image();
	sq112.src="images/q112.gif";

	sq113=new Image();
	sq113.src="images/q113.gif";

	sq114=new Image();
	sq114.src="images/q114.gif";

}

function outputLAYER(layName,html){
	if(document.getElementById){
		document.getElementById(layName).innerHTML=html;
		return 1;
	}else if(document.all){
		document.all(layName).innerHTML;
		return 1;
	}else{
		return 0;
	}
}

function moveLAYER(idName,x,y){
	if(document.getElementById){
		var ie = getIEVersion();
		if(ie >= 9){
			document.getElementById(idName).style.pixelLeft=x;
			document.getElementById(idName).style.pixelTop=y;
		}else{
			document.getElementById(idName).style.left=x;
			document.getElementById(idName).style.top=y;
		}
	}else if(document.all){
		document.all(idName).style.pixelLeft=x;
		document.all(idName).style.pixelTop=y;
	}
}

function getIEVersion() {
	var ie = (function(){
		var undef, v = 3, div = document.createElement('div');  
		while (
			div.innerHTML = '<!--[if gt IE '+(++v)+']><I></I><![endif]-->',
			div.getElementsByTagName('i')[0]
		);
		return v> 4 ? v : undef;
	}());
	return ie;
}

var wx=new Array(),wy=new Array(),count=new Array();
var ex=new Array(),ey=new Array(),spd=new Array();
var step=new Array(),stepX=new Array(),stepY=new Array();
var mvFlag=new Array(),slideID=new Array();
var ookisaCX=new Array(), ookisaCY=new Array(), ookisaDX=new Array(), ookisaDY=new Array();

function slideLAYERs(layName,startX,startY,endX,endY,speed,stpx,ookisaAX,ookisaAY,ookisaBX,ookisaBY){

	if(is.ie5up && is.win){

		if(!mvFlag[layName]){
			if(document.layers){
				clearTimeout(slideID[layName]);
			}

			count[layName]=0;
			var ofX=(endX-startX);
			var ofY=(endY-startY);
			step[layName]=stpx;
				stepX[layName]=ofX/stpx;
			stepY[layName]=ofY/stpx;
			wx[layName]=startX;
			wy[layName]=startY;
			ex[layName]=endX;
			ey[layName]=endY;
			ookisaDX[layName]=ookisaAX;
			ookisaDY[layName]=ookisaAY;
			ookisaCX[layName]=(((ookisaBX-ookisaAX)-(ookisaBX-ookisaAX)%stpx))/stpx;
			ookisaCY[layName]=(((ookisaBY-ookisaAY)-(ookisaBY-ookisaAY)%stpx))/stpx;

			spd[layName]=speed;
			mvFlag[layName]=true;
		}

		if(mvFlag[layName]&&(count[layName]<=step[layName]-1)){
			count[layName]++;
			wx[layName]+=stepX[layName];
			wy[layName]+=stepY[layName];
			ookisaDX[layName]+=ookisaCX[layName];
			ookisaDY[layName]+=ookisaCY[layName];

			if(document.getElementById){
					document.getElementById(layName).style.width=ookisaDX[layName]+"px";
					document.getElementById(layName).style.height=ookisaDY[layName]+"px";
					document.getElementById(layName).style.left=wx[layName];
					document.getElementById(layName).style.top=wy[layName];
			}

			slideID[layName]=setTimeout('slideLAYERs("'+layName+'")',spd[layName]);

		}else{
			wx[layName]=ex[layName];
			wy[layName]=ey[layName];
			clearTimeout(slideID[layName]);
			mvFlag[layName]=false;
		}
	}
}

function topchgICON(icode){
	document.s110.src="images/x110.gif";
	document.s120.src="images/x120.gif";
	document.s130.src="images/x130.gif";
	document.s140.src="images/x140.gif";
	document.s150.src="images/x150.gif";
	document.s160.src="images/x160.gif";
	document.s170.src="images/x170.gif";
	document.s180.src="images/x180.gif";

	switch (icode){
		case 110:
		document.s110.src="images/z110.gif";
		break;

		case 120:
		document.s120.src="images/z120.gif";
		break;

		case 130:
		document.s130.src="images/z130.gif";
		break;

		case 140:
		document.s140.src="images/z140.gif";
		break;

		case 150:
		document.s150.src="images/z150.gif";
		break;

		case 160:
		document.s160.src="images/z160.gif";
		break;

		case 170:
		document.s170.src="images/z170.gif";
		break;

		case 180:
		document.s180.src="images/z180.gif";
		break;

	}

}

function dtllay(contcode){

	if(is.ie5up && is.win){

		if(contcode==0){
			document.getElementById("cntdtl").style.visibility="hidden";
			return 0;
		}

		if(contcode==110){
			var html="<img src='images/q005.gif' alt='' />";
			html+="<a href='forVisitor.html'><img src='images/q114.gif' alt='forVisitor' /></a>";
			html+="<br />";
			html+="<img src='images/q006.gif' alt='' />";
			html+="<a href='access.html'><img src='images/q111.gif' alt='Access' /></a>";
			html+="<br />";
			html+="<img src='images/q006.gif' alt='' />";
			html+="<a href='menu.html'><img src='images/q112.gif' alt='Menu' /></a>";
			html+="<br />";
			html+="<img src='images/q007.gif' alt='' />";
			html+="<a href='gallery.html'><img src='images/q113.gif' alt='Gallery' /></a>";

			var x=203;
			var y=302;
		}

		if(contcode==120){
			var html="<img src='images/q005.gif' alt='' />";
			html+="<a href='p-boys.html'><img src='images/q121.gif' alt='p-boys' /></a>";
			html+="<br />";
			html+="<img src='images/q007.gif' alt='' />";
			html+="<a href='welcome.html'><img src='images/q122.gif' alt='Welcome' /></a>";

			var x=203;
			var y=330;
		}

		moveLAYER("cntdtl",x,y);
		outputLAYER("cntdtl",html);
		document.getElementById("cntdtl").style.visibility="visible";

		return 0;
	}
	return 0;
}

var pop_win=null;

function popupwindow(){
    pop_win=window.open("","news","width=591,height=416,scrollbars=no,resizable=yes,status=no");
    pop_win.window.document.open();
    pop_win.window.document.write(
     '<html>'
    +'<head><title>８周年！！</title></head>'
    +'<body style="margin:0;padding:0;border:0;">'
    +'<img src="images/pop_8th.jpg" />'
    +'</body>'
    +'</html>'
    );
    pop_win.window.document.close();
    pop_win.focus();
}

function randomPopup(){
    // 画像の配列を定義
    img = new Array();
    img[0] = "images/pop_6th_01.jpg";
    img[1] = "images/pop_6th_02.jpg";
    // 表示する画像をランダムに決定
    n = Math.floor(Math.random()*img.length);
    var src = img[n];
    // すでにウインドウが開いているなら、いったん閉じる
    if(pop_win != null && !pop_win.closed) pop_win.close();
    var pop_width = 376;   // 6周年記念画像に合わせている
    var pop_height = 532;  // 6周年記念画像に合わせている
    // ウィンドウを開く
    pop_win = window.open(
                      "",
                      "news",
                      "width="+pop_width+",height="+pop_height+",scrollbars=no,resizable=yes,status=no"
                  );
    // 空ウィンドウに画像を出力するためのHTML
    pop_win.window.document.open();
    pop_win.window.document.write(
     '<html>'
    +'<head><title>６周年！！</title></head>'
    +'<body style="margin:0;padding:0;border:0;">'
    +'<img src="'+src+'" />'
    +'</body>'
    +'</html>'
    );
    pop_win.window.document.close();
    pop_win.focus();
}

function openImageSizedWindow(){
    // 画像の配列を定義
    img = new Array();
    img[0] = "images/pop_6th_01.jpg";
    img[1] = "images/pop_6th_02.jpg";
    // 表示する画像をランダムに決定
    n = Math.floor(Math.random()*img.length);
    var src = img[n];
    // 画像をロードしてサイズを取得
    var i = new Image(); i.src = src;
    // すでにウインドウが開いているなら、いったん閉じる
    if(pop_win != null && !pop_win.closed) pop_win.close();
    // 画像のサイズに合った空ウィンドウを開く
    pop_win = window.open(
                      "",
                      "news",
                      "width="+i.width+",height="+i.height+",scrollbars=no,resizable=yes,status=no"
                  );
    pop_win.resizeTo(i.width, i.height);
    // 空ウィンドウに画像を出力するためのHTML
    pop_win.window.document.open();
    pop_win.window.document.write(
     '<html>'
    +'<head><title>６周年！！</title></head>'
    +'<body style="margin:0;padding:0;border:0;">'
    +'<img src="'+i.src+'" width="100%" alt="" />'
    +'</body>'
    +'</html>'
    );
    pop_win.window.document.close();
    pop_win.focus();
}

