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/sm5335851" target="_blank">\u3010\u4ecf\u5177\u3067\u3011\u3066\u3063\u3066\u3063\u3066\u30fc\u3010\u6f14\u594f\u3057\u3066\u307f\u305f\u3011\u4fee\u6b63\u30fb\u8ffd\u52a0\u7248</a></p>'
		);
		return;
	}

	var video = Nicovideo.Video.create({
		v: 'sm5335851'
	,	id: 'sm5335851'
	,	title: '\u3010\u4ecf\u5177\u3067\u3011\u3066\u3063\u3066\u3063\u3066\u30fc\u3010\u6f14\u594f\u3057\u3066\u307f\u305f\u3011\u4fee\u6b63\u30fb\u8ffd\u52a0\u7248'
	,	description: '\u6cd5\u8981\u306e\u5f85\u3061\u6642\u9593\u306b\u4fee\u6b63\u2192\u97f3\u30ba\u30ec\u306f\u89e3\u6d88\u3057\u307e\u3057\u305f\u304c\u3001\u4e16\u9593\u306e\u30cb\u30fc\u30ba\u304b\u3089\u8457\u3057\u304f\u30ba\u30ec\u3066\u308b\u611f\u306f\u5426\u3081\u307e\u305b\u3093\u3002\u6728\u9b5a\u5927\u30fb\u9285\u947c\u30fb\u91d1\u78ec\uff08\u304d\u3093\u3051\u3044\uff09\u3092\u8ffd\u52a0\u3002\u524d\u4f5c\u2192sm5188914\u3000mylist\/9397467\u3000\u65b0\u4f5c9\/24\u2192\u65b0\u4f5c\u2192sm8322225 20\u4e07\u56de\u5fcc\u3001\u8996\u8074\u8005\u306a\u3089\u3073\u306bAA\u8077\u4eba\u3055\u3093\u306b\u6df1\u304f\u611f\u8b1d\uff01m(_ _)m\u3088\u3082\u3084\u672a\u3060\u306b\u4f38\u3073\u308b\u3068\u306f\u601d\u3063\u3066\u304a\u308a\u307e\u305b\u306a\u3093\u3060\uff01\u3061\u3087\u3063\u3068\u306e\u9593\u8131\u529b\u3057\u3066\u8cb0\u3048\u308c\u3070\u5e78\u3044\u3067\u3059\u30d7\u30ed\u3068\u3044\u3046\u304b\u3001\u80a9\u66f8\u304d\u306f\u73fe\u5bfa\u9662\u306e\u4e8c\u5341\u4e94\u4ee3\u4f4f\u8077\u30fb\u963f\u95cd\u68a8\u30fb\u5927\u50e7\u90fd\u3067\u3057\u3066\u4fee\u884c\u3057\u305f\u7d50\u679c\u304c\u3053\u308c\u3060\u3088\uff01\u3086\u3063\u304f\u308a\u6210\u4ecf\u3057\u640d\u306a\u3063\u305f\u306d\uff01\u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u2026\u6bce\u6642\u30fb\u30c7\u30a4\u30ea\u30fc\u3082\u6a5f\u80fd\u7f8eP\u3068\u540c\u6642\u671f\u3067\u2192nm5340491\u3001\u591a\u751f\u306e\u7e01\u3060\u306a\u3041\u3068\u3002\u6240\u611f\u30fb\u820e\u5229\u79ae\u6587\u89e3\u8aac\u30fb\u5fa1\u793c\u306a\u3069\u306f\u30b5\u30a4\u30c8\u306e\u65b9\u306b\u2192http:\/\/bouzumekuri.jugem.cc\/?eid=194'
	,	thumbnail: 'http:\/\/tn-skr4.smilevideo.jp\/smile?i=5335851'
	,	postedAt: new Date('2008\/11\/23 22:53:43 +0900')
	,	length: 94
	,	viewCount: 236976
	,	mylistCount: 5540
	,	commentCount: 7017
	,	movieType: 'flv'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
		thumbPlayKey: '1258965303.0.x70UmdtSV1TuAE7Z3IXdkWQsv-A.'
	,	wv_title: '\u3010\u4ecf\u5177\u3067\u3011\u3066\u3063\u3066\u3063\u3066\u30fc\u3010\u6f14\u594f\u3057\u3066\u307f\u305f\u3011\u4fee\u6b63\u30fb\u8ffd\u52a0\u7248'
	,	iee: '1'
	}, '', '');
	player.write();
})();

