/*
	write_swf.js

	convexStyle
	2006, All Rights Reserved.
	http://www.convexstyle.com
*/


/*
A list of variables


[Version](Numeric)
The published version of Flash Player
------------------------------------------------------------------------------
[URL](String)
the url of swf
------------------------------------------------------------------------------
[classID](String)
ActiveX classID
------------------------------------------------------------------------------
[codebase](String)
criteria URI for Classid attributes, Data attributes, and Archives attributes
------------------------------------------------------------------------------
[width](String)
the width of the swf
------------------------------------------------------------------------------
[height](String)
the height of the swf
------------------------------------------------------------------------------
[id](String)
the ID of the swf
------------------------------------------------------------------------------
[align](String)
the align style of the swf
"top","middle","bottom","left","right"
------------------------------------------------------------------------------
[allowScriptAccess](String)
whether or not swf class Javascript
"always", "sameDomain", "never"
------------------------------------------------------------------------------
[quailty](String)
Flash rendering quality
"high", "low"
------------------------------------------------------------------------------
[bgcolor](String)
the background color of a swf file
------------------------------------------------------------------------------
[type](String)
MineType
------------------------------------------------------------------------------
[pluginspage](String)
the page to move to if users don't have an appropriate version of flash player
------------------------------------------------------------------------------

*/


function getSwfElement(arr)
{

	swf_obj = new Object();


	// 必要な変数
	swf_obj['Version']           = arr['Version'];
	swf_obj['URL']               = arr['URL'];
	swf_obj['width']             = arr['width'];
	swf_obj['height']            = arr['height'];
	swf_obj['id']                = arr['id'];



	// 必ずしも必要ではない変数
	(arr['align'] == undefined) ? swf_obj['align'] = 'middle' : swf_obj['align'] = arr['align'];
	(arr['allowScriptAccess'] == undefined) ? swf_obj['allowScriptAccess'] = 'sameDomain' : swf_obj['allowScriptAccess'] = arr['allowScriptAccess'];
	(arr['quality'] == undefined) ? swf_obj['quality'] = 'high' : swf_obj['quality'] = arr['quality'];
	(arr['bgcolor'] == undefined) ? swf_obj['bgcolor'] = '#000000' : swf_obj['bgcolor'] = arr['bgcolor'];
/*
	swf_obj['align']             = arr['align'];
	swf_obj['allowScriptAccess'] = arr['allowScriptAccess'];
	swf_obj['quality']           = arr['quality'];
	swf_obj['bgcolor']           = arr['bgcolor'];
*/



	// 必要ではない変数
	swf_obj['classID']           = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	swf_obj['codebase']          = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + swf_obj['Version'] + ',0,0,0';
	swf_obj['type']              = 'application/x-shockwave-flash';
	swf_obj['pluginspage']       = 'http://www.macromedia.com/go/getflashplayer';



	// FlashVars
	if(arr['flashvars'] != undefined)
	{
		swf_obj['flashvars'] = new Array();

		for(var i = 0; i < arr['flashvars'].length; i ++)
		{
			swf_obj['flashvars'][i] = arr['flashvars'][i];
		}
	}

	return swf_obj;
}




function writeSwf(id)
{

	// initialize variables
	var swf = "";


	// to check whether or not flashvars exist
	if(swf_obj['flashvars'] != undefined)
	{
		var flashvars = "";

		for(var i = 0; i < swf_obj['flashvars'].length; i ++)
		{
			flashvars += "fv" + i + "=" + swf_obj['flashvars'][i] + "&";
		}
	}


	swf += '<object classid="' + swf_obj['classID'] + '" codebase="' + swf_obj['codebase'] + '" width="' + swf_obj['width'] + '" height="' + swf_obj['height'] + '" id="' + swf_obj['id'] + '" align="' + swf_obj['align'] + '">';
	swf += '<param name="allowScriptAccess" value="' + swf_obj['allowScriptAccess'] + '" />';
	swf += '<param name="movie" value="' + swf_obj['URL'] + '" />';
	swf += '<param name="quality" value="' + swf_obj['quality'] + '" />';
	swf += '<param name="bgcolor" value="' + swf_obj['bgcolor'] + '" />';
	if(swf_obj['flashvars'] != undefined)
	{
		swf += '<param name=FlashVars value="' + flashvars + '">';
		swf += '<embed FlashVars="' + flashvars + '" src="' + swf_obj['URL'] + '" quality="' + swf_obj['quality'] + '" bgcolor="' + swf_obj['bgcolor'] + '" width="' + swf_obj['width'] + '" height="' + swf_obj['height'] + '" name="' + swf_obj['id'] + '" align="' + swf_obj['align'] + '" allowScriptAccess="' + swf_obj['allowScriptAccess'] + '" type="' + swf_obj['type'] + '" pluginspage="' + swf_obj['pluginspage'] + '" />';
	}
	else
	{
		swf += '<embed src="' + swf_obj['URL'] + '" quality="' + swf_obj['quality'] + '" bgcolor="' + swf_obj['bgcolor'] + '" width="' + swf_obj['width'] + '" height="' + swf_obj['height'] + '" name="' + swf_obj['id'] + '" align="' + swf_obj['align'] + '" allowScriptAccess="' + swf_obj['allowScriptAccess'] + '" type="' + swf_obj['type'] + '" pluginspage="' + swf_obj['pluginspage'] + '" />';
	}
	swf += '</object>';


	document.getElementById(id).innerHTML = swf;

}
