// make by isobe 2007.12.27
// version 1.10

// 初期化
var result = new String;

///////////////////////////////////////////////////////////////////////////////////////////
// メイン
// _id : Flashを入れるボックスのid。ない場合はnull。
// _path : Flashの相対パス、または絶対パス。
// _width : Flashの幅。ピクセル値（数値のみ）。
// _height : Flashの高さ。ピクセル値（数値のみ）。
// _quality : Flashの再生画質(high|medium|low)。
// _bgcolor : Flashの背景色。
// _defultStatus : JavaScriptオフ対策などなど。(close|null|image_uri)
///////////////////////////////////////////////////////////////////////////////////////////
function flashWrite( _id, _path , _width , _height, _quality, _bgcolor, _defaultStatus )
{
	// JavaScriptで書き出すことになんの対策もしたくない場合
	if ( _defaultStatus == 'null' )
	{
		try
		{
			// Flashタグの作成にエラーがなかったら、書き出し
			makeFlashTags(_id, _path , _width , _height, _quality, _bgcolor, _defaultStatus);
		}
		catch(e)
		{
			// Flashタグの作成にエラーがあったら、最低限の書き出し
			result += '<embed src="'+ _path +'" quality="'+ _quality +'" width="'+ _width +'" height="'+ _height +'" bgcolor="'+ _bgcolor +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
			result += '</embed>';
			document.write(result);
		}
	}
	// ボックスを消して見せなくしている場合
	else if ( _id != null && _defaultStatus == 'close')
	{
		// ボックスを可視にして、大きさを整える
		document.getElementById(_id).style.display = 'block';
		document.getElementById(_id).style.width = _width +'px';
		document.getElementById(_id).style.height = _height +'px';
		
		try
		{
			// Flashタグの作成にエラーがなかったら、書き出し
			makeFlashTags(_id, _path , _width , _height, _quality, _bgcolor, _defaultStatus);
		}
		catch(e)
		{
			// Flashタグの作成にエラーがあったら、最低限の書き出し
			result += '<embed src="'+ _path +'" quality="'+ _quality +'" width="'+ _width +'" height="'+ _height +'" bgcolor="'+ _bgcolor +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
			result += '</embed>';
			document.write(result);
		}
	}
	// 代替え画像
	else
	{
		result += '<img src="'+ _defaultStatus +'" width="'+ _width +'" height="'+ _height +'" />';
		document.write(result);
	}
}

// フラッシュタグを生成
function makeFlashTags(_id, _path , _width , _height, _quality, _bgcolor, _defaultStatus)
{
	// classidと、codebaseが使えるブラウザ
	if ( _browser == 'ie7' || _browser == 'ie6' || _browser == 'ie' || _browser == 'safari' )
	{
		result += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" data="' + _coordinates + '" width="' + _width + '" height="' + _height + '" type="application/x-shockwave-flash">';
		result += '<param name="movie" value="' + _path + '" />';
		result += '<param name="quality" value="' + _quality + '" />';	
		result += '<param name="bgcolor" value="'+ _bgcolor +'">';
		result += '</object>';
	}
	// classidと、codebaseが使えないブラウザ
	else if ( _browser != 'opera' && _browser != 'unknown' )
	{
		result += '<object data="' + _path + '" width="' + _width + '" height="' + _height + '" type="application/x-shockwave-flash">';
		result += '<param name="movie" value="' + _path + '" />';
		result += '<param name="quality" value="' + _quality + '" />';		
		result += '<param name="bgcolor" value="'+ _bgcolor +'">';
		result += '</object>';
	}
	// embedタグしか使えないブラウザ
	else
	{
		result += '<embed src="'+ _path +'" quality="'+ _quality +'" width="'+ _width +'" height="'+ _height +'" bgcolor="'+ _bgcolor +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
		result += '</embed>';
	}
	
	document.write(result);
}