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=1417677079';

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(http://res.nimg.jp/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/sm22400980" target="_blank">\u5cf6\u98a8\uff06\u91d1\u525b\u306b\u30cf\u30c3\u30d4\u30fc\u30b7\u30f3\u30bb\u30b5\u30a4\u30b6\u6b4c\u308f\u305b\u3066\u307f\u305f\u3010\u4eba\u529bVOCALOID\uff06\u8266\u3053\u308c\u3011</a></p>'
		);
		return;
	}

	var video = new Nicovideo.Video({
		v: 'sm22400980'
	,	id: 'sm22400980'
	,	title: '\u5cf6\u98a8\uff06\u91d1\u525b\u306b\u30cf\u30c3\u30d4\u30fc\u30b7\u30f3\u30bb\u30b5\u30a4\u30b6\u6b4c\u308f\u305b\u3066\u307f\u305f\u3010\u4eba\u529bVOCALOID\uff06\u8266\u3053\u308c\u3011'
	,	description: '\u30b2\u30fc\u30e0\u306b\u30cf\u30de\u3063\u305f\u52e2\u3044\u3067\u4f5c\u3063\u3066\u307f\u305f\u3089\u3001\u9014\u4e2d\u3067\u6b7b\u306b\u305f\u304f\u306a\u308b\u7a0b\u306e\u8352\u884c\u3067\u3057\u305f\u3002\uff2d\uff2d\uff24\u306f\u307e\u3060\u521d\u5fc3\u8005\u306e\u305f\u3081\u5b9a\u70b9\u30ab\u30e1\u30e9\u3067\u3059\u3002\u6b4c\u58f0\u7d20\u6750\u306f\u4e2d\u306e\u4eba(\u4f50\u5009\u7dbe\u97f3\u3055\u3093\u30fb\u6771\u5c71\u5948\u592e\u3055\u3093)\u306e\u30b7\u30f3\u30b0\u30eb\uff23\uff24\u304b\u3089\u3002\u25a0\u4f7f\u7528\u697d\u66f2\u306fEasyPop\u3055\u3093\u4f5c\u306e\u300c\u30cf\u30c3\u30d4\u30fc\u30b7\u30f3\u30bb\u30b5\u30a4\u30b6(sm12825985)\u300d\u25a0\u2193\uff2d\uff2d\uff24\u3067\u304a\u501f\u308a\u3057\u305f\u3082\u306e\u2193 \u5168\u3066\u306e\u8077\u4eba\u69d8\u306b\u611f\u8b1d\u3044\u305f\u3057\u307e\u3059\u3002\u30fb\u5cf6\u98a8\uff06\u91d1\u525b\u30e2\u30c7\u30eb(sm22025972)\u3000\u30fb\u6226\u8266\u5927\u548c\u30e2\u30c7\u30eb(im2876301)\u30fb\u80cc\u666f(sm12676731)\u3000\u30fb\u30c0\u30f3\u30b9\u30e2\u30fc\u30b7\u30e7\u30f3(sm14003913)(sm14003959)\u25a0\u5236\u4f5c\u7269\uff08mylist\/25941980\uff09(14\/9\/12)\u65b0\u4f5c\u3067\u3059\u3002[sm24454016]\u9752.\u68ee\u55b0.\u7a2e -\u30a2\u30aa.\u30e2\u30ea\u30b0.\u30fc\u30eb-\u3010\u5409.\u5e7e.\u4e09\u3011'
	,	thumbnail: 'http:\/\/tn-skr1.smilevideo.jp\/smile?i=22400980.L'
	,	postedAt: new Date('2013\/12\/06 21:00:00 +0900')
	,	length: 235
	,	viewCount: 802109
	,	mylistCount: 37969
	,	commentCount: 5201
	,	movieType: 'mp4'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
	'thumbWatch': '1'
	,'thumbPlayKey': '1417956245.0.1.gtSs92ZMolEuKCQp4NVH50Cmv3A.aHR0cDovL2thbmtvcmVkb3VqaW4uYmxvZy5mYzIuY29tL2Jsb2ctZW50cnktNjMzLmh0bWw=..'
	,'playerTimestamp': '1417677103'
	,'player_version_xml': '1417677101'
	,'player_info_xml': '1417589370'
	,'translation_version_json': '1415685948'
	,'v': 'sm22400980'
	,'videoId': 'sm22400980'
	,'thumbTitle': '\u5cf6\u98a8\uff06\u91d1\u525b\u306b\u30cf\u30c3\u30d4\u30fc\u30b7\u30f3\u30bb\u30b5\u30a4\u30b6\u6b4c\u308f\u305b\u3066\u307f\u305f\u3010\u4eba\u529bVOCALOID\uff06\u8266\u3053\u308c\u3011'
	,'thumbDescription': '\u30b2\u30fc\u30e0\u306b\u30cf\u30de\u3063\u305f\u52e2\u3044\u3067\u4f5c\u3063\u3066\u307f\u305f\u3089\u3001\u9014\u4e2d\u3067\u6b7b\u306b\u305f\u304f\u306a\u308b\u7a0b\u306e\u8352\u884c\u3067\u3057\u305f\u3002\uff2d\uff2d\uff24\u306f\u307e\u3060\u521d\u5fc3\u8005\u306e\u305f\u3081\u5b9a\u70b9\u30ab\u30e1\u30e9\u3067\u3059\u3002\u6b4c\u58f0\u7d20\u6750\u306f...'
	,'thumbImage': 'http:\/\/tn-skr1.smilevideo.jp\/smile?i=22400980.L'
	,'movie_type': 'mp4'
	,'wv_id': 'sm22400980'
	,'language': 'ja-jp'
	,'iee': '1'
	,'isWide': '1'
	,'noAdSense': '1'
	,'category': '\u30b2\u30fc\u30e0'
	,'categoryGroup': '\u30a2\u30cb\u30e1\u30fb\u30b2\u30fc\u30e0\u30fb\u7d75'
	,'leaf_switch': '2'
	,'accessFromHash': '1417869845:e25ecadb3fd06a0f81da7eb1c7a04dd45ac4497220dae934a53f4503635b18a4'
	}, '320', '252');
	player.write();
})();

