/*
sample usage (enclose the following in script tags):

var oMovie = new FlashMovie();
oMovie.Src = "my_swf.swf";
oMovie.Name = "mySwfId";
oMovie.Width = 750;
oMovie.Height = 530;
oMovie.AddParameter('favoriteIceCream', 'chocolate'); //this is obviously optional- adds both a parameter tag and embed attribute
oMovie.Render();

alternately, you can use arguments in the constructor:
var oMovie = new FlashMovie("my_swf.swf", "mySwfId", 750, 530);
oMovie.Render();

for debugging:
alert(oMovie.GetTag());

to include non-flash alternate content, use the <noscript> tag

*/

function FlashMovie(sSrc, sName, nWidth, nHeight) {
	this.Src = sSrc ? sSrc : null;
	this.Width = nWidth ? nWidth : null;
	this.Height = nHeight ? nHeight : null;
	this.Name = sName ? sName : "";
	this.Loop = false;
	this.Quality = "high";
	this.BgColor = "#FFFFFF";
	this.Menu = false;
	this.Align = "";
	this.Wmode = "";
	
	this.m_arrParamNames = new Array();
	this.m_arrParamValues = new Array();
	this.AddParameter = FlashMovieAddParameter;
	
	this.GetTag = function() { return FlashMovieGetTag(this); };
	this.Render = function() { document.write(FlashMovieGetTag(this)); }
}

function FlashMovieAddParameter(sName, sValue) {
	this.m_arrParamNames[this.m_arrParamNames.length] = sName;
	this.m_arrParamValues[this.m_arrParamValues.length] = sValue;
}

function FlashMovieGetTag(oFlash) {
	var sTag = '';
	
	if (!oFlash.Src) {
		alert('missing flash src attribute');
	}

	sTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \n';
	sTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" \n';
	sTag += 'id="' + oFlash.Name + '" \n';
	
 	if (oFlash.Width) {
		sTag += 'width="' + oFlash.Width + '" \n';
	}
 	if (oFlash.Height) {
		sTag += 'height="' + oFlash.Height + '" \n';
	}
 	if (oFlash.Align) {
		sTag += 'align="' + oFlash.Align + '" \n';
	}
	sTag += '> \n';
	
	//write parameter tags
	sTag += '<param name=movie value="' + oFlash.Src + '"> \n';
	sTag += '<param name=menu value="' + oFlash.Menu + '"> \n';
	sTag += '<param name=quality value="' + oFlash.Quality + '"> \n';
	sTag += '<param name=bgcolor value="' + oFlash.BgColor + '"> \n';
	sTag += '<param name=loop value="' + oFlash.Loop + '"> \n';
	sTag += '<param name=wmode value="' + oFlash.Wmode + '"> \n';
	
	//write any additional parameter tags
	for (var i=0; i<oFlash.m_arrParamNames.length; i++) {
		sTag += '<param name=' + oFlash.m_arrParamNames[i] + ' value="' + oFlash.m_arrParamValues[i] + '"> \n';
	}
	
	//write embed tag
	sTag += '<embed src="' + oFlash.Src + '" ';
	sTag += 'type="application/x-shockwave-flash" ';
	sTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	sTag += 'loop="' + oFlash.Loop + '" ';
	sTag += 'menu="' + oFlash.Menu + '" ';
	sTag += 'quality="' + oFlash.Quality + '" ';
	sTag += 'bgcolor="' + oFlash.BgColor + '" ';
	if (oFlash.Wmode) {
		sTag += 'wmode="' + oFlash.Wmode + '" ';
	}

 	if (oFlash.Width) {
		sTag += 'width="' + oFlash.Width + '" ';
	}
 	if (oFlash.Height) {
		sTag += 'height="' + oFlash.Height + '" ';
	}
 	if (oFlash.Align) {
		sTag += 'align="' + oFlash.Align + '" ';
	}
	
	//write any additional embed attributes
	for (i=0; i<oFlash.m_arrParamNames.length; i++) {
		sTag += oFlash.m_arrParamNames[i] + '="' + oFlash.m_arrParamValues[i] + '" ';
	}
	sTag += '>\n';
	sTag += '</embed>\n';
	sTag += '</object>\n';
	
	return sTag;
}
