if (typeof Nicovideo == 'undefined') {
	Nicovideo = new Object();
}
if (typeof Nicovideo.Global == 'undefined') {
	Nicovideo.Global = {
		playerCount: 0
	};
}

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

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  || '485';
	this.height      = height || '385';
};
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;
	},
	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;
		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.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/sm9087798" target="_blank">\u3010OP\u3011\u5922\u306e\u6d6e\u6a4b\uff5e\u65b0\u91c8\u6e90\u6c0f\u7269\u8a9e\uff5e\u300c\u82e5\u7d2b\u30fb\u5915\u9854\u30fb\u672b\u6458\u82b1\u7de8\u300d</a></p>'
		);
		return;
	}

	var video = new Nicovideo.Video({
		v: 'sm9087798'
	,	id: 'sm9087798'
	,	title: '\u3010OP\u3011\u5922\u306e\u6d6e\u6a4b\uff5e\u65b0\u91c8\u6e90\u6c0f\u7269\u8a9e\uff5e\u300c\u82e5\u7d2b\u30fb\u5915\u9854\u30fb\u672b\u6458\u82b1\u7de8\u300d'
	,	description: '\u540c\u4eba\u30b5\u30fc\u30af\u30eb\u7121\u9650\u9003\u907f\u7d1a\u6570\u306e\u3001\u6e90\u6c0f\u7269\u8a9e\u306eAVG\u30b2\u30fc\u30e0\uff01Opening Movie\u300cSakura Storm\u300d\u4f5c\u8a5e:\u7dbe\u83d3 http:\/\/ryorca.net\/\u4f5c\u66f2:setzer http:\/\/www.mintjam.net\/mj\/\u6b4c:\u7dbe\u83d3\u30b3\u30df\u30b177\u2605\u767a\u58f212\/30 2\u65e5\u76ee \u6771Z37-a\u5922\u306e\u6d6e\u6a4b\uff5e\u65b0\u91c8\u6e90\u6c0f\u7269\u8a9e\uff5e\u300c\u82e5\u7d2b\u30fb\u5915\u9854\u30fb\u672b\u6458\u82b1\u7de8\u300d(18\u6b73\u4ee5\u4e0a)\u516c\u5f0f\u30b5\u30a4\u30c8http:\/\/genji.shinshaku.net\/index.html\u5236\u4f5c\u539f\u753b: \u7fe0\u71d5 \u30b0\u30e9\u30d5\u30a3\u30c3\u30af: \u96ea\u6c70\u90ce \u3068\u304a\u3084 toufuOP\/ED:\u9f8d\u82b1  BGM:szak\u30b7\u30ca\u30ea\u30aa:\u82e5\u7d2b=Nemuri \u5915\u9854=\u3055\u304f\u3063\u3061 \u672b\u6458\u82b1=\u3061\u3083\u3044\u306a\u30d7\u30ed\u30c7\u30e5\u30fc\u30b5\u30fc:\u84bc\u4e95\u4e9c\u7483\u590f\u51fa\u6f14\u58f0\u512a(\u656c\u79f0\u7565)\u30ea\u30e2\u30fc\u30cd\u5148\u751f\/yonji\/tamico.\/recog\/\u5a9b\u8cb4\/\u5c0f\u5bae\u771f\u592e\/\u85e4\u5802\u308c\u3093\u3052\u771f\u91ce\u7dbe\/\u6d45\u5009\u5c0f\u6625\/\u5742\u5d0e\u771f\u592e\/\u5927\u5c71\u30c1\u30ed\u30eb\/\u611b\u539f\u572d\u7e54\/\u304d\u3061\u3085\u306d\u54f2\u4e5f\/\u7dbe\u5ddd\u96ea\u5f25\/\u5f69\u5439\u3048\u3044\/\u9cf3\uff5e\u3042\u3052\u306f\uff5e\/\u8cb4\u5742\u7406\u7dd2\/\u7a7a\u6728\u3055\u304f\u3089'
	,	thumbnail: 'http:\/\/tn-skr3.smilevideo.jp\/smile?i=9087798'
	,	postedAt: new Date('2009\/12\/14 02:00:41 +0900')
	,	length: 89
	,	viewCount: 6529
	,	mylistCount: 94
	,	commentCount: 71
	,	movieType: 'mp4'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
	'thumbWatch': '1'
	,'thumbPlayKey': '1329039486.0.JPC3civTPwF7IiouOkA44V5o_Ls...'
	,'playerTimestamp': '1328754876'
	,'player_version_xml': '1328857541'
	,'player_info_xml': '1328854461'
	,'v': 'sm9087798'
	,'videoId': 'sm9087798'
	,'thumbTitle': '\u3010OP\u3011\u5922\u306e\u6d6e\u6a4b\uff5e\u65b0\u91c8\u6e90\u6c0f\u7269\u8a9e\uff5e\u300c\u82e5\u7d2b\u30fb\u5915\u9854\u30fb\u672b\u6458\u82b1\u7de8\u300d'
	,'thumbDescription': '\u540c\u4eba\u30b5\u30fc\u30af\u30eb\u7121\u9650\u9003\u907f\u7d1a\u6570\u306e\u3001\u6e90\u6c0f\u7269\u8a9e\u306eAVG\u30b2\u30fc\u30e0\uff01Opening Movie\u300cSakura Storm\u300d\u4f5c\u8a5e:\u7dbe\u83d3 h...'
	,'thumbImage': 'http:\/\/tn-skr3.smilevideo.jp\/smile?i=9087798'
	,'movie_type': 'mp4'
	,'wv_id': 'sm9087798'
	,'iee': '1'
	,'category': '\u30b2\u30fc\u30e0'
	,'categoryGroup': '\u30a2\u30cb\u30e1\u30fb\u30b2\u30fc\u30e0\u30fb\u7d75'
	,'leaf_switch': '2'
	}, '', '');
	player.write();
})();


