if (typeof Nicovideo == 'undefined') {
	Nicovideo = new Object();
}

Nicovideo.version = '1.4.0';
Nicovideo.url = 'http://www.nicovideo.jp/';
Nicovideo.playerUrl = 'http://ext.nicovideo.jp/swf/player/thumbwatch.swf?ts=1257969235';

if (typeof Nicovideo.Video == 'undefined') {
	Nicovideo.Video = function (video) {
		if (video) {
			for (var key in video) {
				this[key] = video[key];
			}
		}
	};
	Nicovideo.Video.create = function (video) {
		if (typeof this.__cache == "undefined") this.__cache = {};
		var v = this.__cache[video.v];
		if (!v) v = this.__cache[video.v] = new this(video);
		return v;
	};
	Nicovideo.Video.prototype = {
		getPlayURL: function () {
			return Nicovideo.url + 'watch/' + this.v;
		},
		getShortTitle: function () {
			return this.title.substring(0, 60) + 
				(this.title.length > 60 ? "..." : "");
		},
		getShortDescription: function () {
			return this.description.substring(0, 60) + 
				(this.description.length > 60 ? "..." : "");
		}
	};
}
if (typeof Nicovideo.MiniPlayer == 'undefined') {
	Nicovideo.MiniPlayer = function (video, vars, width, height) {
		this.id          = Nicovideo.MiniPlayer.allocateId(this);
		this.video       = video;
		this.attributes  = {};
		this.parameters  = {};
		this.variables   = vars || {};
		this.width       = width  || '485';
		this.height      = height || '385';
	};
	Nicovideo.MiniPlayer.prototype = {
		defaultAttributes: {},
		defaultParameters: {
			allowScriptAccess: 'always',
			bgcolor: '#000000',
			quality: 'high'
		},
		defaultVariables: {
			thumbWatch: 1,
			playerTimestamp: '1258606760',
			player_version_xml: '1258608916'
		},


		_merge: function () {
			var o = {};
			for (var i = 0, len = arguments.length; i < len; i++) {
				var arg = arguments[i];
				if (typeof arg != "object") continue;
				for (var key in arg) {
					o[key] = arg[key];
				}
			}
			return o;
		},
		getHTML: function () {
			var id = this.id,
				video = this.video,
				attrs = this._merge(this.defaultAttributes, this.attributes),
				params = this._merge(this.defaultParameters, this.parameters),
				vars = this._merge(
					this.defaultVariables,
					{
						v: video.v,
						thumbTitle: video.getShortTitle(),
						thumbDescription: video.getShortDescription(),
						thumbImage: video.thumbnail,
						thumbWidth: this.width,
						thumbHeight: this.height,
						mylist_counter: video.mylistCount.toString()
							.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,"),
						movie_type: video.movieType,
						wv_id: video.id
					},
					this.variables
				);

			var flashvars = [];
			for (var key in vars) {
				flashvars.push(key + '=' + encodeURIComponent(vars[key]));
			}
			params.flashvars = flashvars.join("&");

			var html;
			if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
				html =
					'<embed type="application/x-shockwave-flash"'
					+ ' id="' + id + '"'
					+ ' name="' + id + '"'
					+ ' src="' + Nicovideo.playerUrl + '"'
					+ ' width="' + this.width  + '"'
					+ ' height="' + this.height + '"'
					;
				for (var key in params) {
					html += ' ' + key + '="' + params[key] + '"';
				}
				for (var key in attrs) {
					html += ' ' + key + '="' + attrs[key] + '"';
				}
				html += ' />';
			} else {
				html =
					'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
					+ ' id="' + id + '"'
					+ ' name="' + id + '"'
					+ ' width="' + this.width + '"'
					+ ' height="' + this.height + '"'
					;
				for (var key in attrs) {
					html += ' ' + key + '="' + attrs[key] + '"';
				}
		 		html += '>';
				html += '<param name="movie" value="' + Nicovideo.playerUrl + '" />';
				for (var key in params) {
					html += '<param name="' + key + '" value="' + params[key] + '" />';
				}
				html += '</object>';
			}

			return html;
		},
		write: function (id) {
			if (id === undefined) {
				document.write(this.getHTML());
			} else if (typeof id == "string") {
				var el = document.getElementById(id);
				if (el) el.innerHTML = this.getHTML();
			} else if (id) {
				id.innerHTML = this.getHTML();
			}
		}
	};

	Nicovideo.MiniPlayer.players = {};
	Nicovideo.MiniPlayer.playerCount = 0;
	Nicovideo.MiniPlayer.allocateId = function (player) {
		var id = 'external_nico_' + (this.playerCount++);
		this.players[id] = player;
		return id;
	};


}

(function () {
	var b = true;
	try {
		var w = window.parent, self = window.self;
		while (w && w != self) {
			if (w.location.host != self.location.host) {
				b = false;
				break;
			}
			if (w === w.parent) break;
			w = w.parent;
		}
	} catch (e) {
		b = false;
	}

	if (!b) {
		Nicovideo = undefined;
		document.write(
			'<p><a href="http://www.nicovideo.jp/watch/sm4544516" target="_blank">\u3010\u5144\u8cb4\u8a95\u751f\u796d\u3011\u5144\u8cb4\u306e\u60c5\u71b1\u5927\u9678\u3010Live Better\u3011</a></p>'
		);
		return;
	}

	var video = Nicovideo.Video.create({
		v: 'sm4544516'
	,	id: 'sm4544516'
	,	title: '\u3010\u5144\u8cb4\u8a95\u751f\u796d\u3011\u5144\u8cb4\u306e\u60c5\u71b1\u5927\u9678\u3010Live Better\u3011'
	,	description: '\u3053\u308c\u307e\u3067\u306e\u9053\u306e\u308a\u2192mylist\/7538296 \u2606\u2606\u51fa\u5178\u2606\u2606\u25cf\u30107\/14\u653e\u9001\u3011 \u5642\u306e\u3042\u306e\u4eba\u304c\u9042\u306b \u300c\u60c5\u71b1\u5927\u9678\u300d \u51fa\u6f14\uff01\uff01\u3010\u4e88\u544aCM\u3011sm3551427 \u25cf\u3010\u671f\u9593\u9650\u5b9a\u3011NUDA\u306e\u65b0CM\u304c\u767a\u8868\u3055\u308c\u305f\u3088\u3046\u3067\u3059\u30107\/14\u767a\u58f2\u3011sm3725595\u3000\u25cf\u3010MAD\u3011 \u5144\u8cb4\u306e\u30bd\u30d5\u30c8\u30d0\u30f3\u30afCM\u3000sm3613906TV\u65b0\u65e5\u66ae\u91cc\u306b\u4f55\u304b\u3054\u8981\u671b\u7b49\u3042\u308b\u65b9\u306f\u3053\u3061\u3089\u3078\u2192tvshinnippori\u2606mail.goo.ne.jp \u2606\u306f@9\/28\u8ffd\u8a18:\u30a4\u30f3\u30bf\u30d3\u30e5\u30fc\u53d7\u3051\u307e\u3057\u305f\u2192sm476510112\/16\u8ffd\u8a18\u306a\u3093\u304b\u96d1\u8a8c\u306b\u8f09\u3063\u305f\u3089\u3057\u3044http:\/\/win100.jp\/movie2008\/ 1\/3\u8ffd\u8a18\uff1a\u305d\u308c\u3068\u30d6\u30ed\u30b0\u4f5c\u308a\u307e\u3057\u305f\u3000http:\/\/jyonetu.blog63.fc2.com\/2\/14\u8ffd\u8a18\uff1a\u3042\u306a\u305f\u306e\u4eca\u65e5\u306e\u904b\u52e2\u306f\u3069\u3046\u3067\u3059\u304b\uff1f\u65b0\u4f5c\u3067\uff5e\u3059\u2192sm6143692'
	,	thumbnail: 'http:\/\/tn-skr1.smilevideo.jp\/smile?i=4544516'
	,	postedAt: new Date('2008\/09\/07 03:09:42 +0900')
	,	length: 715
	,	viewCount: 323751
	,	mylistCount: 9518
	,	commentCount: 32177
	,	movieType: 'mp4'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
		thumbPlayKey: '1258962320.0.0OaKZloldQ3J0jPomWKgfyz8jDg.'
	,	wv_title: '\u3010\u5144\u8cb4\u8a95\u751f\u796d\u3011\u5144\u8cb4\u306e\u60c5\u71b1\u5927\u9678\u3010Live Better\u3011'
	,	has_owner_thread: '1'
	,	iee: '1'
	}, '485', '386');
	player.write();
})();

