//==========================================================
//	html サブウィンドウを中央に開く
//==========================================================
function PopWnd(mypage, myname, w, h, scroll)
{
	var win_x = ( screen.availWidth - w) / 2;
	var win_y = ( screen.availHeight - h) / 2;
	win_detail = 'left=' + win_x
	             + ',top=' + win_y
	             + ',width=' + 10
	             + ',height=' + 10
	             + ',menubar=no'		// メニューバー
	             + ',toolbar=no'		// ツールバー
	             + ',location=no'		// アドレスバー
	             + ',status=no'		// ステータスバー
	             + ',scrollbars=' + scroll	// スクロールバー(yes,no,auto)
	             + ',resizable=yes';	// サイズ変更
	win = window.open( mypage, myname, win_detail);
	win.moveTo( win_x, win_y);
	win.resizeTo( w, h);
	if ( parseInt( navigator.appVersion) >= 4) { win.window.focus(); }
}

//==========================================================
//	image サブウィンドウを中央に開く
//==========================================================
function ImgPopWnd(myimage, mytitle, myname, w, h, imgW, imgH, scroll)
{
	if ( w <= 0) { w = screen.availWidth + w }
	if ( h <= 0) { h = screen.availHeight + h }
	var win_x = ( screen.availWidth - w) / 2;
	var win_y = ( screen.availHeight - h) / 2;

	win_detail = 'left=' + win_x
	             + ',top=' + win_y
	             + ',width=' + 10
	             + ',height=' + 10
	             + ',menubar=no'		// メニューバー
	             + ',toolbar=no'		// ツールバー
	             + ',location=no'		// アドレスバー
	             + ',menubar=no'		// メニューバー
	             + ',status=no'		// ステータスバー
	             + ',scrollbars=' + scroll	// スクロールバー(yes,no,auto)
	             + ',resizable=yes';	// サイズ変更
	win = window.open( myimage, myname, win_detail);
	win.moveTo( win_x, win_y);
	win.resizeTo( w, h);
	win.document.open();
	win.document.writeln( '<html>');
	win.document.writeln( '<head>');
	win.document.writeln( '<title>' + mytitle + '</title>');
	win.document.writeln( '<meta http-equiv="imagetoolbar" content="no">');
	win.document.writeln( '</head>');
	win.document.writeln( '<body oncontextmenu="return false">');
	win.document.writeln( '<div align="center">');
	win.document.writeln( '<a href="javascript:window.close();">');
	win.document.writeln( '<img src="' + myimage + '" border="0" width="' + imgW + '" height="' + imgH + '" alt="">');
	win.document.writeln( '<p>');
	win.document.writeln( '<img src="http://www.webamuse.co.jp/img/close01.gif" border="0" width="95" height="20" alt="閉じる">');
	win.document.writeln( '</a>');
	win.document.writeln( '</div>');
	win.document.writeln( '</body>');
	win.document.writeln( '</html>');
	win.document.close();
	if ( parseInt( navigator.appVersion) >= 4) { win.window.focus(); }
}

//==========================================================
//	image サブウィンドウを中央に開く（黒バック）
//==========================================================
function ImgPopWndBk(myimage, mytitle, myname, w, h, imgW, imgH, scroll)
{
	if ( w <= 0) { w = screen.availWidth + w }
	if ( h <= 0) { h = screen.availHeight + h }
	var win_x = ( screen.availWidth - w) / 2;
	var win_y = ( screen.availHeight - h) / 2;

	win_detail = 'left=' + win_x
	             + ',top=' + win_y
	             + ',width=' + 10
	             + ',height=' + 10
	             + ',menubar=no'		// メニューバー
	             + ',toolbar=no'		// ツールバー
	             + ',location=no'		// アドレスバー
	             + ',menubar=no'		// メニューバー
	             + ',status=no'		// ステータスバー
	             + ',scrollbars=' + scroll	// スクロールバー(yes,no,auto)
	             + ',resizable=yes';	// サイズ変更
	win = window.open( myimage, myname, win_detail);
	win.moveTo( win_x, win_y);
	win.resizeTo( w, h);
	win.document.open();
	win.document.writeln( '<html>');
	win.document.writeln( '<head>');
	win.document.writeln( '<title>' + mytitle + '</title>');
	win.document.writeln( '<meta http-equiv="imagetoolbar" content="no">');
	win.document.writeln( '</head>');
	win.document.writeln( '<body bgcolor="000000" color="FFFFFF" oncontextmenu="return false">');
	win.document.writeln( '<div align="center">');
	win.document.writeln( '<a href="javascript:window.close();">');
	win.document.writeln( '<img src="' + myimage + '" border="0" width="' + imgW + '" height="' + imgH + '" alt="">');
	win.document.writeln( '<p>');
	win.document.writeln( '<img src="http://www.webamuse.co.jp/img/close02.gif" border="0" width="95" height="20" alt="閉じる">');
	win.document.writeln( '</a>');
	win.document.writeln( '</div>');
	win.document.writeln( '</body>');
	win.document.writeln( '</html>');
	win.document.close();
	if ( parseInt( navigator.appVersion) >= 4) { win.window.focus(); }
}

//==========================================================
//	image 表示拡大
//==========================================================
function ImgZoomWnd(myimage, mytitle, myname, w, h, WidS, HeiS, WidL, HeiL)
{
	if ( w <= 0) { w = screen.availWidth + w }
	if ( h <= 0) { h = screen.availHeight + h }
	var win_x = ( screen.availWidth - w) / 2;
	var win_y = ( screen.availHeight - h) / 2;

	win_detail = 'left=' + win_x
	             + ',top=' + win_y
	             + ',width=' + 10
	             + ',height=' + 10
	             + ',menubar=no'		// メニューバー
	             + ',toolbar=no'		// ツールバー
	             + ',location=no'		// アドレスバー
	             + ',menubar=no'		// メニューバー
	             + ',status=no'		// ステータスバー
	             + ',scrollbars=yes'	// スクロールバー(yes,no,auto)
	             + ',resizable=yes';	// サイズ変更
	win = window.open( myimage, myname, win_detail);
	win.moveTo( win_x, win_y);
	win.resizeTo( w, h);
	win.document.open();
	win.document.writeln( '<html>');
	win.document.writeln( '<head>');
	win.document.writeln( '<title>' + mytitle + '</title>');
	win.document.writeln( '<meta http-equiv="imagetoolbar" content="no">');
	win.document.writeln( '<script language="JavaScript">');
	win.document.writeln( '<!--');
	win.document.writeln( 'function PhotoZoom(WidS, HeiS, WidL, HeiL)');
	win.document.writeln( '{');
	win.document.writeln( 'if (Photo.name == "S")');
	win.document.writeln( '{');
	win.document.writeln( 'Photo.name="L"');
	win.document.writeln( 'Photo.width = WidL;');
	win.document.writeln( 'Photo.height = HeiL;');
	win.document.writeln( '}');
	win.document.writeln( 'else');
	win.document.writeln( '{');
	win.document.writeln( 'Photo.name="S"');
	win.document.writeln( 'Photo.width = WidS;');
	win.document.writeln( 'Photo.height = HeiS;');
	win.document.writeln( '}');
	win.document.writeln( '}');
	win.document.writeln( '-->');
	win.document.writeln( '</script>');
	win.document.writeln( '</head>');
	win.document.writeln( '<body oncontextmenu="return false" style="margin: 5px;">');
	win.document.writeln( '<div align="center">');
	win.document.writeln( '<a href="javascript:PhotoZoom(' + WidS + ',' + HeiS + ',' + WidL + ',' + HeiL + ');">');
	win.document.writeln( '<img src=' + myimage + ' id="Photo" name="S" border="0" align="top" width=' + WidS + ' height=' + HeiS + ' alt="">');
	win.document.writeln( '</a>');
	win.document.writeln( '<p style="margin: 1px"></p>');
	win.document.writeln( '<a href="javascript:PhotoZoom(' + WidS + ',' + HeiS + ',' + WidL + ',' + HeiL + ');">');
	win.document.writeln( '<img src="http://www.webamuse.co.jp/img/zoom.gif" border="0" width="42" height="10" alt="拡大／縮小">');
	win.document.writeln( '</a>');
	win.document.writeln( '<p style="margin: 5px"></p>');
	win.document.writeln( '<a href="javascript:window.close();">');
	win.document.writeln( '<img src="http://www.webamuse.co.jp/img/close01.gif" border="0" width="95" height="20" alt="閉じる">');
	win.document.writeln( '</a>');
	win.document.writeln( '</div>');
	win.document.writeln( '</body>');
	win.document.writeln( '</html>');
	win.document.close();
	if ( parseInt( navigator.appVersion) >= 4) { win.window.focus(); }
}

//==========================================================
//	画像ダウンロード用ウィンドウを中央に開く
//==========================================================
function ImgDlWnd(myimage, mytitle, myname, w, h)
{
	var win_w = screen.availWidth;
	var win_h = screen.availHeight;
	var win_x = 0;
	var win_y = 0;

	win_detail = 'left=' + win_x
	             + ',top=' + win_y
	             + ',width=' + 10
	             + ',height=' + 10
	             + ',scrollbars=yes'	// スクロールバー(yes,no,auto)
	             + ',resizable=yes';	// サイズ変更
	win = window.open( myimage, myname, win_detail);
	win.moveTo( win_x, win_y);
	win.resizeTo( win_w, win_h);
	win.document.open();
	win.document.writeln( '<html>');
	win.document.writeln( '<head>');
	win.document.writeln( '<title>' + mytitle + '</title>');
	win.document.writeln( '</head>');
	win.document.writeln( '<body style="margin: 1px;">');
	win.document.writeln( '<img src="' + myimage + '" border="0" width="' + w + '" height="' + h + '" alt="">');
	win.document.writeln( '</body>');
	win.document.writeln( '</html>');
	win.document.close();
	if ( parseInt( navigator.appVersion) >= 4) { win.window.focus(); }
}

//==========================================================
//	FLASH swfファイルの表示（背景黒）
//==========================================================
function WriteFlash(myswf, myname, prmcmd, w, h)
{
	document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + w + '" HEIGHT="' + h + '" id="' + myname + '" ALIGN="">');
	if ( '' == prmcmd)
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '">');
	}
	else
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '?' + prmcmd + '">');
	}
	document.writeln('<PARAM NAME=quality VALUE=high>');
	document.writeln('<PARAM NAME=bgcolor VALUE=#000000>');
	document.writeln('<EMBED src="'  + myswf + '" quality=high bgcolor=#000000  WIDTH="' + w + '" HEIGHT="' + h + '" NAME="' + myname + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
	document.writeln('</OBJECT>');
}

//==========================================================
//	FLASH swfファイルの表示（背景指定）
//==========================================================
function WriteFlash2(myswf, myname, prmcmd, w, h, bgcolor)
{
	document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + w + '" HEIGHT="' + h + '" id="' + myname + '" ALIGN="">');
	if ( '' == prmcmd)
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '">');
	}
	else
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '?' + prmcmd + '">');
	}
	document.writeln('<PARAM NAME=quality VALUE=high>');
	document.writeln('<PARAM NAME=bgcolor VALUE=' + bgcolor + '>');
	document.writeln('<EMBED src="'  + myswf + '" quality="high" bgcolor="#000000" WIDTH="' + w + '" HEIGHT="' + h + '" NAME="' + myname + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
	document.writeln('</OBJECT>');
}

//==========================================================
//	FLASH swfファイルの表示（背景指定＆透過指定）
//==========================================================
function ViewFlash(myswf, myname, prmcmd, w, h, bgcolor, IsTransparent)
{
	document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + w + '" HEIGHT="' + h + '" id="' + myname + '" ALIGN="">');
	if ( '' == prmcmd)
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '">');
	}
	else
	{
		document.writeln('<PARAM NAME=movie VALUE="' + myswf + '?' + prmcmd + '">');
	}
	document.writeln('<PARAM NAME=quality VALUE=high>');
	document.writeln('<PARAM NAME=bgcolor VALUE=' + bgcolor + '>');
	if ( true == IsTransparent)
	{
		document.writeln('<PARAM NAME=wmode VALUE=transparent>');
	}
	document.writeln('<EMBED src="'  + myswf + '" quality="high" bgcolor="#000000" WIDTH="' + w + '" HEIGHT="' + h + '" NAME="' + myname + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
	document.writeln('</OBJECT>');
}

//==========================================================
//	画像ファイルの表示
//==========================================================
function ImageLock(myImg, w, h, myLock)
{
	if ( '' == myLock) myLock = 'http://www.webamuse.co.jp/img/none.gif';

	var sImg = 'src="' + myImg + '" border="0" width="' + w + '" height="' + h + '" alt=""';
	var sOpt = ' onMouseDown="this.src=\'' + myLock +'\'" onMouseUp="this.src=\'' + myImg + '\'" onMouseOut="this.src=\'' + myImg + '\'"';
	document.writeln( '<img ' + sImg + sOpt + '>');
}

//==========================================================
//	プルダウンメニュー
//==========================================================
function pullDown(Target, IsView)
{
	if( true == IsView)
		Target.style.visibility = "visible";
	else
		Target.style.visibility = "hidden";
}


//==========================================================
//	スクロール
//==========================================================
function scroller(px, direction, unif, prev)
{
	// どのぐらいスクロールしているか
	if ( document.all)
	{
		var Y = document.body.scrollTop;
		var X = document.body.scrollLeft;
	}
	else
	{
		var Y = window.pageYOffset;
		var X = window.pageXOffset;
	}
	var s = 0;
	switch ( direction)
	{
		case 'vertical':
			s = Y;
			break;
		case 'horizontal':
			s = X;
			break;
		case 'multiple':
			s = X;
			break;
	}
	var sR = unif;
	if ( sR == 'no')
	{
		sR = 0;
		var f = px - Math.abs( s - px);		// 現在の移動量
		sR = Math.ceil( ( px - f) / 5);
		if ( sR < 1) sR = 1;
	}
	else
	{
		sR = parseInt( unif);
	}
	if ( ( px - s) > 0)
	{
		// 現在座標より正方向にスクロールするとき
		s += sR;
		if ( s > px) s = px;
	}
	else if (px == s)
	{
		// 現在座標と目的座標が同じになったとき
		return;
	}
	else if ( ( px - s) < 0)
	{
		// 現在座標より逆方向にスクロールするとき
		s -= sR;
		if ( s < px) s = px;
	}
	if ( prev == s) return;
	var sY = Y;
	var sX = X;
	switch ( direction)
	{
		case 'vertical':
			sY = s;
			break;
		case 'horizontal':
			sX = s;
			break;
		case 'multiple':
			sX = s;
			sY = s;
			break;
	}
	window.scrollTo( sX, sY);
	setTimeout( 'scroller(' + px + ', "' + direction + '","' + unif + '",' + s + ');', 5);
}
