/* -------------------------------------------------------------------------- */
/** 
 *    @fileoverview
 *       embeds lion blogparts.
 *
 *    @version rev001.2009-03-26
 */
/* -------------------------------------------------------------------------- */

(function() {
	function BATag(tagName, attrs) {
		this.tagName    = tagName;
		this.attributes = attrs || {};
		this.childNodes = [];
	}
	BATag.prototype = {
		setAttr : function(attrName, value) {
			this.attributes[attrName] = value;
		},
		append : function(arg) {
			this.childNodes.push(arg);
		},
		toString : function(debug) {
			var tagOpen    = (debug) ? '&lt;' : '<';
			var tagClose   = (debug) ? '&gt;' : '>';
			var tag        = tagOpen + this.tagName;
			var content    = (this.childNodes.length) ? '' : null;
			for (var i = 0, n = this.childNodes.length; i < n; i++) {
				content += this.childNodes[i].toString(debug);
			}
			for (var attr in this.attributes) {
				tag += ' ' + attr + '="' + this.attributes[attr] + '"';
			}
			tag += (content != null) ?
			       	tagClose + content + tagOpen + '/' + this.tagName + tagClose :
			       	' /' + tagClose;
			return tag;
		}
	};
	var env             = {};
	    env.ua          = {};
	    env.ua.isGecko  = /Gecko\//    .test(navigator.userAgent);
	    env.ua.isSafari = /AppleWebKit/.test(navigator.userAgent);
	    env.ua.isOpera  = Boolean(window.opera);
	    env.ua.isIE     = Boolean(document.all && !env.ua.isGecko && !env.ua.isSafari && !env.ua.isOpera);
	var setting = {
		"attrs" : {
			"data"              : "http://www.leclubpeugeot.jp/blogparts/lion/lion.swf",
			"type"              : "application/x-shockwave-flash",
			"id"                : "jp_leclubpeugeot_blogparts_lion",
			"name"              : "jp_leclubpeugeot_blogparts_lion",
			"width"             : "160",
			"height"            : "339"
		},
		"params" : {
			"align"             : "middle",
			"salign"            : "",
			"scale"             : "showall",
			"bgcolor"           : "#ffffff",
			"quality"           : "high",
			"wmode"             : "window",
			"menu"              : "true",
			"play"              : "true",
			"loop"              : "true",
			"devicefont"        : "false",
			"allowFullScreen"   : "false",
			"allowScriptAccess" : "sameDomain"
		}
	};
	if (env.ua.isIE) {
		setting.params.movie = setting.attrs.data;
		delete setting.attrs.data;
	}
	var flash = new BATag('object', setting.attrs);
	for (var prop in setting.params) {
		flash.append(new BATag('param', { 'name' : prop, 'value' : setting.params[prop] }));
	}
	document.write(flash);
})();
