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/sm1556758" target="_blank">\u91ce\u7403\u3000\u30a4\u30c1\u30ed\u30fc \u8d70\u653b\u5b88\u30b9\u30fc\u30d1\u30fc\u30d7\u30ec\u30fc\u7279\u96c6 \uff3b\u524d\u671f\u7de8\uff3d</a></p>'
		);
		return;
	}

	var video = Nicovideo.Video.create({
		v: 'sm1556758'
	,	id: 'sm1556758'
	,	title: '\u91ce\u7403\u3000\u30a4\u30c1\u30ed\u30fc \u8d70\u653b\u5b88\u30b9\u30fc\u30d1\u30fc\u30d7\u30ec\u30fc\u7279\u96c6 \uff3b\u524d\u671f\u7de8\uff3d'
	,	description: '\u5f8c\u671f\u7de8\u21d2 sm1565208\u30022003\u5e742007\u5e74\u306e\u5168\u7403\u56e3\u76e3\u7763\u306b\u3088\u308b\u9078\u8003\u3067\u300c\u6700\u9ad8\u306e\u6253\u8005\u300d\u300c\u6700\u9ad8\u306e\u30d0\u30f3\u30bf\u30fc\u300d\u300c\u6700\u9ad8\u306e\u8d70\u8005\u300d\u300c\u6700\u3082\u30a8\u30ad\u30b5\u30a4\u30c6\u30a3\u30f3\u30b0\u306a\u9078\u624b\u300d\u300c\u6700\u3082\u5f37\u80a9\u306a\u5916\u91ce\u624b\u300d\u300c\u6700\u3082\u5b88\u5099\u304c\u512a\u308c\u305f\u5916\u91ce\u624b\u300d\u306e\uff16\u90e8\u9580\u3067\u5171\u306b1\u4f4d\u306b\u9078\u3070\u308c\u305f\u30a4\u30c1\u30ed\u30fc\u9078\u624b\u306e\u8d70\u653b\u5b88\u30d5\u30a1\u30a4\u30f3\u30d7\u30ec\u30fc\u96c6\u3002\u30002006\u5e74\u30e1\u30b8\u30e3\u30fc\u30ea\u30fc\u30ac\u30fc415\u4eba\u306b\u3088\u308b\u6295\u7968\u3067\u3082\u3001\u300c\u6700\u3082\u80a9\u304c\u5f37\u3044\u5916\u91ce\u624b\u300d\u306b\u30a4\u30c1\u30ed\u30fc\u9078\u624b\u304c\u300148\uff05\u3068\u5927\u534a\u306e\u652f\u6301\u3092\u53d7\u3051\u3001\u300c\u5f37\u80a9\u30ca\u30f3\u30d0\u30fc\u30ef\u30f3\u300d\u306e\u79f0\u53f7\u3092\u624b\u306b\u5165\u308c\u3066\u3044\u308b\u30022008\u5e74\u516c\u5f0f\u30b9\u30ab\u30a6\u30c8\u8a55\u4fa1\u3067\u3082\u300c\u6253\u6483\u7dcf\u5408\u300d\u300c\u30d0\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u300d\u300c\u5916\u91ce\u5b88\u5099\u300d\u300c\u80a9\u300d\u300c\u8d70\u8005\u300d\u306e\uff15\u9805\u76ee\u30671\u4f4d\u3092\u7372\u5f97\u3057\u3001\u4ed63\u9805\u76ee\u30672\u4f4d\u306e\u652f\u6301\u3092\u5f97\u305f\u3002\u30b4\u30fc\u30eb\u30c9\u30b0\u30e9\u30d6\u8cde\u3082\u65e5\u7c73\uff11\uff14\u5e74\u9023\u7d9a\u3067\u7d99\u7d9a\u4e2d\uff08\u65e5\u672c\u306f\u8a18\u8005\u6295\u7968\u3001\u30a2\u30e1\u30ea\u30ab\u306f\u76e3\u7763\u30b3\u30fc\u30c1\u6295\u7968\uff09\u3002\u30a4\u30c1\u30ed\u30fc\u597d\u30d7\u30ec\u30fc\u96c6\uff1amylist\/15699076\u3001MLB\u6295\u7a3f\u4e00\u89a7\uff1amylist\/2365420'
	,	thumbnail: 'http:\/\/tn-skr3.smilevideo.jp\/smile?i=1556758'
	,	postedAt: new Date('2007\/11\/18 03:24:17 +0900')
	,	length: 509
	,	viewCount: 313059
	,	mylistCount: 3378
	,	commentCount: 13403
	,	movieType: 'flv'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
		thumbPlayKey: '1258961998.0.H2XKvUTbk9YNdFcQhIdTnAFEhfU.'
	,	wv_title: '\u91ce\u7403\u3000\u30a4\u30c1\u30ed\u30fc \u8d70\u653b\u5b88\u30b9\u30fc\u30d1\u30fc\u30d7\u30ec\u30fc\u7279\u96c6 \uff3b\u524d\u671f\u7de8\uff3d'
	,	iee: '1'
	}, '485', '386');
	player.write();
})();

