function activex_generate_object(object_attributes, params, embedded_attributes)
{
	var object_invoke_string = '';
	object_invoke_string += '<object ';
	for (var i in object_attributes) { object_invoke_string += i +'="'+ object_attributes[i] +'" '; }
	object_invoke_string += '>';
	for (var i in params) { object_invoke_string += '<param name="'+ i +'" value="'+ params[i] +'" /> '; }
	object_invoke_string += '<embed ';
	for (var i in embedded_attributes) { object_invoke_string += i +'="'+ embedded_attributes[i] +'" '; }
	object_invoke_string += ' ></embed></object>';
	document.write(object_invoke_string);
}

function activex_execute_flash()
{
	var attributes_collection = activex_get_attributes_collection(arguments, "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
	activex_generate_object(attributes_collection.object_attributes, attributes_collection.params, attributes_collection.embedded_attributes);
}

function activex_execute_shockwave()
{
	var attributes_collection = activex_get_attributes_collection(arguments, "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null);
	activex_generate_object(attributes_collection.object_attributes, attributes_collection.params, attributes_collection.embedded_attributes);
}

function activex_get_attributes_collection(arguments_array, source_parameter_name, classid, mime_type)
{
	var attributes_collection = new Object();
	attributes_collection.embedded_attributes = new Object();
	attributes_collection.params = new Object();
	attributes_collection.object_attributes = new Object();
	var param_is_present = new Boolean(false);
	var default_params = new Array("bgcolor", "align", "scale", "quality", "allowScriptAccess", "codebase", "pluginspage");
	var args = new Array(arguments_array.length);
	for (var i = 0; i < args.length; i++) { args[i] = arguments_array[i]; }

	for (var j = 0; j < default_params.length; j += 2)
	{
		param_is_present = false;
		for (var i = 0; i < args.length; i += 2)
		{
			if (args[i] == default_params[j]) { param_is_present = true; }
		}
		if (!param_is_present) // add default value corresponding to the missing parameter
		{
			switch (default_params[j].toLowerCase())
			{
				case "bgcolor":
					args.push("wmode");
					args.push("transparent");
					break;
				case "align":
					args.push("align");
					args.push("middle");
					break;
				case "scale":
					args.push("scale");
					args.push("noscale");
					break;
				case "quality":
					args.push("quality");
					args.push("high");
					break;
				case "allowscriptaccess":
					args.push("allowScriptAccess");
					args.push("sameDomain");
					break;
				case "codebase":
					args.push("codebase");
					args.push("https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0");
					break;
				case "pluginspage":
					args.push("pluginspage");
					args.push("https://www.macromedia.com/go/getflashplayer");
					break;
			}
		}
	}

	for (var i = 0; i < args.length; i += 2)
	{
		var currArg = args[i].toLowerCase();
		switch (currArg)
		{
			case "classid":
				break;
			case "pluginspage":
				attributes_collection.embedded_attributes[args[i]] = args[i + 1];
				break;
			case "src":
			case "movie":
				attributes_collection.embedded_attributes["src"] = args[i + 1];
				attributes_collection.params[source_parameter_name] = args[i + 1];
				break;
			case "onafterupdate":
			case "onbeforeupdate":
			case "onblur":
			case "oncellchange":
			case "onclick":
			case "ondblclick":
			case "ondrag":
			case "ondragend":
			case "ondragenter":
			case "ondragleave":
			case "ondragover":
			case "ondrop":
			case "onfinish":
			case "onfocus":
			case "onhelp":
			case "onmousedown":
			case "onmouseup":
			case "onmouseover":
			case "onmousemove":
			case "onmouseout":
			case "onkeypress":
			case "onkeydown":
			case "onkeyup":
			case "onload":
			case "onlosecapture":
			case "onpropertychange":
			case "onreadystatechange":
			case "onrowsdelete":
			case "onrowenter":
			case "onrowexit":
			case "onrowsinserted":
			case "onstart":
			case "onscroll":
			case "onbeforeeditfocus":
			case "onactivate":
			case "onbeforedeactivate":
			case "ondeactivate":
			case "type":
			case "codebase":
				attributes_collection.object_attributes[args[i]] = args[i + 1];
				break;
			case "width":
			case "height":
			case "align":
			case "vspace":
			case "hspace":
			case "class":
			case "title":
			case "accesskey":
			case "name":
			case "id":
			case "tabindex":
				attributes_collection.embedded_attributes[args[i]] = attributes_collection.object_attributes[args[i]] = args[i + 1];
				break;
			default:
				attributes_collection.embedded_attributes[args[i]] = attributes_collection.params[args[i]] = args[i + 1];
		}
	}
	attributes_collection.object_attributes["classid"] = classid;
	if (mime_type) { attributes_collection.embedded_attributes["type"] = mime_type; }
	return attributes_collection;
}
