/*
 * プラグインダウンロードページURI格納配列設定
 */
var pluginspages = new Array();
pluginspages[0] = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"; // English
pluginspages[1] = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=Japanese"; // Japanese

var pluginVer = 0;

function pfAltAction(Obj)
{
	if( Obj.nonflashSW == 1 ){
		location.href = Obj.nonFlashSRC;
	}
	return Obj.nonFlashSRC;
}

function pfAltContent(Obj)
{
	if( Obj.nonflashSW == 1 ){
		return "";
	}
	return Obj.nonFlashSRC;
}

function pfFlashPlayerObject()
{
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
		return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	}
}

function embedSwf(Obj)
{
	if(!Obj.dir) Obj.dir = '';
	if(!Obj.id) Obj.id = 'putflash';
	if(!Obj.requiredVer) Obj.requiredVer = 8;
	if(!Obj.bgcolor) Obj.bgcolor = "#ffffff";
	if(!Obj.quality) Obj.quality = "high";
	if(!Obj.language) Obj.language = 0;
	if(!Obj.macie4exec && ( Obj.macie4exec != "0" )) Obj.macie4exec = 0;
	if(!Obj.moz_exec && ( Obj.moz_exec != "0" )) Obj.moz_exec = 1;
	if(!Obj.opera_exec && ( Obj.opera_exec != "0" )) Obj.opera_exec = 0;
	if(!Obj.nonflashSW && ( Obj.nonflashSW != "0" )) Obj.nonflashSW = 0;
	if(!Obj.nonFlashSRC) Obj.nonFlashSRC = "";
	if(!Obj.swLiveConnect) Obj.swLiveConnect = "false";
	if(!Obj.menu) Obj.menu = "true";
	if(!Obj.disableCodebase) Obj.disableCodebase = 0;

	var plugin = pfFlashPlayerObject();
	if(plugin){
		pluginVer = parseInt(plugin.description.substring( plugin.description.indexOf(".") != -1 ));
	}else{
		// for Win MSIE
		document.writeln('<script type="text/vbscript">');
		document.writeln('On Error Resume Next');
		document.writeln('Private swfEnableFlag');
		document.writeln('swfEnableFlag = false');
		document.writeln('swfEnableFlag = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + Obj.requiredVer + '"))');
		document.writeln('If swfEnableFlag Then');
		document.writeln('pluginVer = ' + Obj.requiredVer);
		document.writeln('End If');
		document.writeln('</script>');
	}

	document.open();

	if(Obj.hedSRC) document.write(Obj.hedSRC);
	if( pluginVer < Obj.requiredVer ){
		document.write(pfAltAction(Obj));
	}else{
		document.write(pfGetObjectElement(Obj));
	}

	if(Obj.fotSRC) document.write(Obj.fotSRC);
	document.close();
}

function pfGetObjectElement(Obj)
{
	if( window.opera && ( Obj.opera_exec != 1)){
		return pfAltAction(Obj);
	}

	if( !Obj.file || !Obj.width || !Obj.height || !Obj.id ){
		return "";
	}

	var result = "";
	result += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';

	if(!Obj.disableCodebase){
		result += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"';
	}

	result += ' id="' + Obj.id + '" width="' + Obj.width + '" height="' + Obj.height + '" name="' + Obj.id + '">';
	result += '<param name="movie" value="' + Obj.dir + Obj.file + '">';
	result += '<param name="quality" value="' + Obj.quality + '">';
	result += '<param name="bgcolor" value="' + Obj.bgcolor + '">';
	result += '<param name="menu" value="' + Obj.menu + '"' + '>';
	if(Obj.salign) result += '<param name="salign" value="' + Obj.salign + '"' + '>';
	if(Obj.scale) result += '<param name="scale" value="' + Obj.scale + '"' + '>';
	if(Obj.FlashVars) result += '<param name="FlashVars" value="' + Obj.FlashVars + '"' + '>';

	if((( navigator.appVersion.indexOf( 'Win', 0 ) != -1 ) && ( navigator.appName.indexOf( "Microsoft Internet Explorer", 0 ) != -1 )) && !window.opera ){
		result += pfAltContent(Obj);
	}else{
		result += pfGetEmbedElement(Obj);
	}

	result += '</object>';
	return result;
}

function pfGetEmbedElement(Obj)
{
	if( Obj.moz_exec != 1 && (navigator.userAgent.indexOf("Gecko/") != -1 )){
		return pfAltAction(Obj);
	}

	if( Obj.macie4exec != 1 && ( navigator.appVersion.indexOf( 'Mac', 0 ) != -1 )){
		if( navigator.appVersion.indexOf( 'MSIE 4.', 0 ) != -1 ) return pfAltAction(Obj);
		if( navigator.appVersion.indexOf( 'MSIE 3.', 0 ) != -1 ) return pfAltAction(Obj);
	}

	var useragent = navigator.userAgent;
	var reviseFlag = false;
	if(useragent.match(/Gecko\//)){
		var key = 'rv:';
		var sRv = useragent.substr( useragent.indexOf(key) + key.length, 4 );
		var fRv = parseFloat(sRv);
		reviseFlag = (( fRv > 1.4 ) && (( fRv < 1.7 ) || ( sRv == '1.7a' )));
	}

	var result = "";
	result += '<embed src="' + Obj.dir + Obj.file + '"';
	result += ' menu="' + Obj.menu + '"';
	result += ' quality="' + Obj.quality + '"';
	result += ' swLiveConnect="' + Obj.swLiveConnect + '"';
	result += ' bgcolor="' + Obj.bgcolor + '"';
	result += ' width="' + Obj.width + '"';
	result += ' height="' + Obj.height + '"';
	//result += ' height="100%"';
	//result += ' scale="' + Obj.scale + '"';
	if(Obj.scale && !reviseFlag) result += ' scale="' + Obj.scale + '"';
	if(Obj.salign) result += ' salign="' + Obj.salign + '"';
	if(Obj.scale && reviseFlag) result += ' scale="' + Obj.scale + '"';
	if(Obj.FlashVars) result += ' FlashVars="' + Obj.FlashVars + '"';
	result += ' type="application/x-shockwave-flash"';
	result += ' pluginspage="' + pluginspages[Obj.language] + '"';
	result += ' name="' + Obj.id + '"';
	result += '></embed>';

	return result;
}