if (typeof Nicovideo == 'undefined') {
	Nicovideo = new Object();
}
if (typeof Nicovideo.Global == 'undefined') {
	Nicovideo.Global = {
		playerCount: 0,
		embedMode: "noflash"
	};
	(function () {
		if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] === "object" && navigator.mimeTypes && navigator.mimeTypes.length) {
			Nicovideo.Global.embedMode = "embed";
		} else if (typeof ActiveXObject !== "undefined") {
			try {
				var ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				if (ax) {
					Nicovideo.Global.embedMode = "object";
				}
			} catch (e) {}
		}
	})();
	}

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

Nicovideo.Video = function (video) {
	if (video) {
		for (var key in video) {
			this[key] = video[key];
		}
	}
};
Nicovideo.Video.prototype = {
	getPlayURL: function () {
		return Nicovideo.url + 'watch/' + encodeURIComponent(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 ? "..." : "");
	}
};

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 ? width : '485';
	this.height = height ? height : '385';
	if (window.innerWidth && this.width > window.innerWidth) {
		var scale = (window.innerWidth - 20) / this.width;		if (scale > 0) {
			this.width = this.width * scale;
			this.height = this.height * scale;
		}
	}
};
Nicovideo.MiniPlayer.prototype = {
	defaultAttributes: {},
	defaultParameters: {
		allowScriptAccess: 'always',
		allowFullScreen: 'true',
		bgcolor: '#000000',
		quality: 'high'
	},


	_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;
	},
	_escape: function (s) {
		return String(s).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
	},
	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.variables;

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

		var html;
		switch (Nicovideo.Global.embedMode) {
		case "embed":
			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 += ' />';
			break;
		case "object":
			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>';
			break;
		default:
			html =
				'<div style="'
						+ 'width:' + (this.width === "100%" ? this.width : this.width + "px")
						+ '; height:' + (this.height === "100%" ? this.height : this.height + "px")
						+ '; display:inline-block; background:#000; color:#FFF; margin:0; padding:0; overflow:hidden;">'
				+ '<a href="' + video.getPlayURL() + '" target="_blank" title="' + this._escape(video.title) + '"'
						+ ' style="position:relative; display:inline-block; width:100%; height:100%;">'
					+ '<img src="' + video.thumbnail + '" alt="" style="width:100%; height:100%; border:none;" />';
			if (!video.isDeleted && (this.width === "100%" || this.width >= 240) && (this.height === "100%" || this.height >= 120)) {
				html += '<span style="display:inline-block; position:absolute; left:0; top:0; width:100%; height:100%;'
							+ ' background-image: url(https://nicovideo.cdn.nimg.jp/web/img/thumb/nico/play.png); background-repeat: no-repeat; background-position: center center;"></span>';
			}
			html += '</a>'
				+ '</div>';
			break;
		}

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

Nicovideo.MiniPlayer.allocateId = function (player) {
	var id = 'external_nico_' + (Nicovideo.Global.playerCount++);
	return id;
};

if (document.all && !window.opera) {
	window.attachEvent("onbeforeunload", function () {
		window.attachEvent("onunload", function () {
			for (var i = 0, l = Nicovideo.Global.playerCount; i < l; i++) {
				var id = 'external_nico_' + i, el = document.all ? document.all[id] : document.getElementById(id);
				if (el && el.parentNode) {
					for (var key in el) {
						if (typeof el[key] == 'function')
							el[key] = null;
					}
					el.parentNode.removeChild(el);
				}
			}
		});
	});
}


(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/sm24999950" target="_blank">\u3054\u6ce8\u6587\u306f\u6a5f\u68b0\u5b66\u7fd2\u3067\u3059\u304b\uff1f</a></p>'
		);
		return;
	}

	var video = new Nicovideo.Video({
		v: 'sm24999950'
	,	id: 'sm24999950'
	,	title: '\u3054\u6ce8\u6587\u306f\u6a5f\u68b0\u5b66\u7fd2\u3067\u3059\u304b\uff1f'
	,	description: '\u3054\u3061\u3046\u3055OP\u306b\u51fa\u3066\u304f\u308b\u9854\u3092\u81ea\u52d5\u8a8d\u8b58\u3057\u3066\u30ad\u30e3\u30e9\u3054\u3068\u306b\u9055\u3046\u8272\u306e\u67a0\u3092\u3064\u3051\u3066\u3044\u307e\u3059\u3002\u6c34\u8272\u2192\u30c1\u30ce\u3001\u30d4\u30f3\u30af\u2192\u30b3\u30b3\u30a2\u3001\u7d2b\u2192\u30ea\u30bc\u3001\u7dd1\u2192\u5343\u591c\u3001\u9ec4\u8272\u2192\u30b7\u30e3\u30ed\u3001\u9ed2\u2192\u305d\u306e\u4ed6\u3067\u3059\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306a\u3069\u306e\u8a73\u7d30\u306f\u3053\u3061\u3089\u2192 http:\/\/kivantium.hateblo.jp\/entry\/2014\/11\/25\/230658\u30cb\u30b3\u30ca\u30ec\u306b\u89e3\u8aac\u30b9\u30e9\u30a4\u30c9\u3092\u7f6e\u304d\u307e\u3057\u305f\u2192http:\/\/niconare.nicovideo.jp\/watch\/kn94'
	,	thumbnail: 'http:\/\/tn.smilevideo.jp\/smile?i=24999950.L'
	,	postedAt: new Date('2014\/11\/27 01:00:20 +0900')
	,	length: 89
	,	viewCount: 14005
	,	mylistCount: 96
	,	commentCount: 93
	,	movieType: 'mp4'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
	'thumbWatch': '1'
	,'thumbPlayKey': '1531522618.0.1.aLzf5v7_3VBk0JGuPj95NLXOl7M.aHR0cDovL2tpdmFudGl1bS5oYXRlYmxvLmpwL2VudHJ5LzIwMTQvMTEvMjUvMjMwNjU4...0'
	,'playerTimestamp': '1530685744'
	,'player_version_xml': '1531387893'
	,'player_info_xml': '1512028043'
	,'translation_version_json': '1509423106'
	,'v': 'sm24999950'
	,'videoId': 'sm24999950'
	,'thumbTitle': '\u3054\u6ce8\u6587\u306f\u6a5f\u68b0\u5b66\u7fd2\u3067\u3059\u304b\uff1f'
	,'thumbDescription': '\u3054\u3061\u3046\u3055OP\u306b\u51fa\u3066\u304f\u308b\u9854\u3092\u81ea\u52d5\u8a8d\u8b58\u3057\u3066\u30ad\u30e3\u30e9\u3054\u3068\u306b\u9055\u3046\u8272\u306e\u67a0\u3092\u3064\u3051\u3066\u3044\u307e\u3059\u3002\u6c34\u8272\u2192\u30c1\u30ce\u3001\u30d4\u30f3\u30af\u2192\u30b3\u30b3\u30a2\u3001\u7d2b\u2192\u30ea\u30bc\u3001\u7dd1\u2192\u5343...'
	,'thumbTags': '\u30cb\u30b3\u30cb\u30b3\u6280\u8853\u90e8 \u3054\u6ce8\u6587\u306f\u3046\u3055\u304e\u3067\u3059\u304b\uff1f \u6a5f\u68b0\u5b66\u7fd2 \u304a\u308f\u304b\u308a\u3044\u305f\u3060\u3051\u305f\u3060\u308d\u3046\u304b \u304a\u304b\u308f\u308a\u3044\u305f\u3060\u3051\u308b\u3060\u308d\u3046\u304b Cpp=\u5fc3\u3074\u3087\u3093\u3074\u3087\u3093 \u7a93\u306b\uff01\u7a93\u306b\uff01'
	,'thumbImage': 'http:\/\/tn.smilevideo.jp\/smile?i=24999950.L'
	,'movie_type': 'mp4'
	,'wv_id': 'sm24999950'
	,'language': 'ja-jp'
	,'isWide': '1'
	,'noAdSense': '1'
	,'category': '\u30cb\u30b3\u30cb\u30b3\u6280\u8853\u90e8'
	,'categoryGroup': '\u79d1\u5b66\u30fb\u6280\u8853'
	,'leaf_switch': '2'
	,'accessFromHash': '1531436218:ac4ac8805417f10457a17c7c5abe9e15c285d1e55e75223e859e00e15fbcf8d6'
	}, '', '');
	player.write();
})();

