function writeFlash(requiredValues,paramValues,flashVarsValues) {
	// initialize variables
	var flashparams = "";
	var embedparams = "";
	var flashvarsparams = "";
	
	// construct output
	flashwrite = ('<OBJECT CLASSID="'+requiredValues["classid"]+'" CODEBASE="'+requiredValues["codebase"]+requiredValues["version"]+'" WIDTH="'+requiredValues["width"]+'" HEIGHT="'+requiredValues["height"]+'"><PARAM NAME="movie" VALUE="'+requiredValues["src"]+'">');
	// write params for the object tag, params for the embed tag
	for (var k in paramValues) {
		flashparams += '<PARAM NAME="'+k+'" VALUE="'+paramValues[k]+'">';	
		embedparams += k+'="'+paramValues[k]+'" ';
	}
	// write flashvars
	for (var m in flashVarsValues) {
		flashvarsparams += m+'='+flashVarsValues[m]+'&';
	}
	flashwrite += flashparams;
	// if there are flashvars, add this to the output; delete last character, which will always be an unncessary ampersand
	if (flashvarsparams != "") {
		flashwrite += '<PARAM NAME="flashvars" VALUE="'+flashvarsparams.substr(0,(flashvarsparams.length-1))+'">';
	}
	// write params for the embed tag
	flashwrite += ('<EMBED SRC="'+requiredValues["src"]+'" PLUGINSPAGE="'+requiredValues["pluginspage"]+'" TYPE="application/x-shockwave-flash" WIDTH="'+requiredValues["width"]+'" HEIGHT="'+requiredValues["height"]+'" '+embedparams);
	// if there are flashvars, add this to the output; delete last character, which will always be an unncessary ampersand
	if (flashvarsparams != "") {
		flashwrite += ' flashvars="'+flashvarsparams.substr(0,(flashvarsparams.length-1))+'"';
	}		
	// close tags
	flashwrite += '></EMBED></OBJECT>';
	// write output to HTML
	return(flashwrite);
}

function createFlash() {
	// initialize variables
	onError=null
	var requiredValues = new Array(); // required by flash
	var paramValues = new Array(); // optional settings for the flash movie
	var flashVarsValues = new Array(); // additional variables passed into the flash movie 
	
	
	// set defaults for required parameters
	requiredValues["classid"] = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	requiredValues["codebase"] = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=";
	requiredValues["version"] = "6,0,40,0"; // not a required param, but separated from codebase if change is needed
	requiredValues["pluginspage"] = "http://www.macromedia.com/go/getflashplayer";
	requiredValues["width"] = 42;
	requiredValues["height"] = 42;
	paramValues["quality"] = "high";
	
	// set up lists of required parameters and optional parameters; others passed in will go into the flashvars array
	var requiredList = new Array("classid","codebase","width","height","src","pluginspage","version");
	var paramList = new Array("id","name","swliveconnect","play","loop","menu","quality","scale","align","salign","wmode","bgcolor","base");

	// loop through each argument passed into function
	for(var i =0; i < arguments.length; i++ ) {
		var nameList = arguments[i].split("="); // split each argument into name/value pairs
		argName = (nameList.shift()); // assigns the name to the text before the first equal sign
		argValue = (nameList.join("=")); // assigns the value to the text after the first equal sign (accounts for multiple equal signs)
		// check to see if the argument name matches one of the required parameters
		for(j=0;j<requiredList.length;j++) {
			if (argName == requiredList[j]) {
				requiredValues[argName] = argValue; // assign a required parameter into an associative array
				argName = ""; // clear variable;
				break;
			}
		}
		// check to see if the argument name matches one of the optional parameters
		for(k=0;k<paramList.length;k++) {	
			if (argName == paramList[k]) {
				paramValues[argName] = argValue; // assign an optional parameter into an associative array
				argName = ""; // clear variable;
				break;
			}
		}
		// if neither condition above applies, pass argument into the flashvars array
		if (argName != "") {
			flashVarsValues[argName] = argValue;
		}
	}

	// construct output
	document.write(writeFlash(requiredValues,paramValues,flashVarsValues));
}