function createObject() {
	var attributes = setAttributes(arguments);
	writeObject(attributes);
}

// Set Attributes and their values into an array
function setAttributes(attr) {
	// Define Variables
	var attributes = new Array();
	
	attributes['type'] = attr[0];
	attributes['src'] = attr[1];
	
	switch(attributes['type']) {
		case 'swf' :
		case 'flv' :
			attributes['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
			attributes['codebase'] = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
			attributes['pluginspage'] = 'http://www.macromedia.com/go/getflashplayer';
			attributes['type'] = 'application/x-shockwave-flash';
			break;
	}
	
	for( var i = 2; i < attr.length; i += 2 ) {
		var attrName = attr[i], attrVal = attr[i + 1];
		attributes[attrName] = attrVal;
	}
	
	return attributes;
}

// Write the Object and Embed tags w/ attributes
function writeObject(attributes) {
	var keys = new Array(), embedString, objectString;
	
	objectString = '<' + 'object classid="' + attributes['classid'] + '" codebase="' + attributes['codebase'] + '" width="' + attributes['width'] + '" height="' + attributes['height'] + '">' + "\n";
	
	for( var i in attributes ) {
		if( attributes[i] != null ) {
			keys.push(i);
		}
	}
	
	objectString += '<' + 'param name="movie" value="' + attributes['src'] + '" />' + "\n";
	
	for( var i = 7, key; key = keys[i]; i++ ) {
		objectString += '<' + 'param name="' + key + '" value="' + attributes[key] + '" />' + "\n";
	}
	
	embedString = '<' + 'embed src="' + attributes['src'] + '" ';
	for( var i = 2, key; key = keys[i]; i++ ) {
		if(key != 'codebase')
			embedString += key + '="' + attributes[key] + '" ';
	}
	embedString += ' />' + "\n";

	objectString += embedString;
	
	objectString += '</' + 'object' + '>';
	document.write(objectString);
}
