var param_dir;
var param_id;

//ウィンドウオープンDW関数
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

//ビューワFlashタグをHTMLに出力する関数
function writeFlashTag() {
	//パラメータ取得
	getParamString();
	//Flashタグ書き込み
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%">');
	document.write('<param name="movie" value="manga_viewer.swf?dir=' + param_dir + '&id=' + param_id + '">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="manga_viewer.swf?dir=' + param_dir + '&id=' + param_id + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed>');
	document.write('</object>');
}

//パラメータ取得
function getParamString() {
	var str	    = window.location.search.substring(1);
	param_dir   = getParam(str, "dir");	// 基準ディレクトリ
	param_id    = getParam(str, "id");	// マンガID
}

//ウィンドウ位置をセンタリング
function moveWindow() {
	xMgn = 4;	//X方向誤差修正値
	yMgn = 28;	//Y方向誤差修正値
	x = ( (screen.width  - 984) / 2 ) - xMgn;
	y = ( (screen.height - 704) / 2 ) - yMgn;
	window.moveTo(x,y);
}

// 指定したパラメータの値を抜き出す関数
function getParam( str, name )
{
	// 入力値チェック
	if( str.length<=0 || name.length<=0 )
	{											// 入力値不正の場合は、
		return("");								// 何も返さない。
	}

	name = name + "=";							// str.indexOf();の便宜上"="を付加する

	// str(文字列)から name(="prog="or"movieid="or"ch="...etc)を探す。
	var pos = str.indexOf( name, 0 );
	if( pos < 0 || (str.length)-(name.length) < pos )
	{											// 文字列中にnameがない場合は、
		return( "" );							// 何も返さない。
	}

	// 開始位置を退避
	var posSta = pos+(name.length);
	// 終了位置のデフォルトをセット
	var posEnd = posSta;

	// nameの後ろの&を探す
	pos = str.indexOf("&", pos+name.length );
	if( pos < 0 || (str.length) < pos )
	{											// 文字列中に"&"がない場合は、
		posEnd = (str.length);					// 最後の位置を設定する
	}
	else
	{											// 文字列中に"&"があった場合、
		posEnd = pos;							// "&"の位置を設定する
	}

	// 抜き出す
	return( str.substring( posSta, posEnd ) );
}