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/sm8368171" target="_blank">\u3010\u304a\u3063\u3071\u3044\u8b70\u54e1\u3011 \u30df\u30f3\u30b9\u306e\u6182\u9b31 \u300c\u53cb\u611b\u3067\u3057\u3087\u3067\u3057\u3087\uff1f\u300d</a></p>'
		);
		return;
	}

	var video = Nicovideo.Video.create({
		v: 'sm8368171'
	,	id: 'sm8368171'
	,	title: '\u3010\u304a\u3063\u3071\u3044\u8b70\u54e1\u3011 \u30df\u30f3\u30b9\u306e\u6182\u9b31 \u300c\u53cb\u611b\u3067\u3057\u3087\u3067\u3057\u3087\uff1f\u300d'
	,	description: '\u304e\u308a\u304e\u308a\u30a2\u30a6\u30c8\u306a\u5185\u90e8\u544a\u767a\u30fb\u30fb\u30fb\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3064\u3065\u304d \u21d2 http:\/\/freejapan.tv\/?FAX\u25c6 FreeJapanTV http:\/\/www.nicovideo.jp\/user\/11520175\u3000mylist\/11401555\u3000co15938\u53cb\u611b \u6c11\u4e3b\u515a \u653f\u6a29\u4ea4\u4ee3 \u30de\u30cb\u30d5\u30a7\u30b9\u30c8 \u8a50\u6b3a \u571f\u5c4b\u305f\u304b\u3086\u304d \u571f\u5c4b\u656c\u4e4b \u6c11\u4e3b\u515a\u653f\u7b56\u96c6 INDEX 2009 WiLL \u592b\u5a66\u5225\u59d3 \u5a5a\u5916\u5b50 \u5f93\u8ecd\u6170\u5b89\u5a66\u554f\u984c \u97d3\u56fd \u671d\u9bae \u5916\u56fd\u4eba\u53c2\u653f\u6a29 \u96fb\u901a \u521d\u97f3\u30df\u30af \u6d45\u7530\u771f\u592e 1000\u4e07\u4eba\u79fb\u6c11\u53d7\u3051\u5165\u308c \u5ca1\u7530\u514b\u4e5f \u5927\u6ca2\u6607 \u5927\u6ca2\u306e\u307c\u308b \u897f\u677e\u5efa\u8a2d \u5c0f\u6ca2\u4e00\u90ce \u8f3f\u77f3\u6771 \u65e5\u6559\u7d44 \u5c0f\u6ca2\u92ed\u4ec1 \u56fd\u304c\u71c3\u3048\u308b \u30e4\u30f3\u30b0\u30b8\u30e3\u30f3\u30d7 \u5357\u4eac\u5927\u8650\u6bba \u634f\u9020 \u72ac\u4f0f\u79c0\u4e00 \u7530\u4e2d\u6b63\u660e \u6c34\u9593\u653f\u61b2 \u963f\u7f85\u5065\u4e00 \u677e\u5c3e\u4e00\u90ce \u5357\u4eac\u306e\u5b9f\u76f8 \u4e2d\u56fd \u30d7\u30ed\u30d1\u30ac\u30f3\u30c0 \u4e2d\u6d25\u5ddd\u535a\u90f7 \u6e21\u8fba\u6d69\u4e00\u90ce \u9577\u5cf6\u662d\u4e45 \u7267\u7fa9\u592b \u5c0f\u5ddd\u52dd\u4e5f \u30de\u30b9\u30b3\u30df \u30de\u30b9\u30b4\u30df \u6a2a\u5cf0\u3055\u304f\u3089\u30d1\u30d1 \u3076\u3063\u3066\u3076\u3063\u3066 \u59eb\u4e95\u7531\u7f8e\u5b50 \u30dd\u30eb\u30ce \u30c1\u30c3\u30c1\u30e7\u30ea\u30fc\u30ca \u30cf\u30eb\u30d2\u306e\u6182\u9b31 \u5b87\u5b99\u4eba \u65e5\u672c\u7d42\u4e86 UI'
	,	thumbnail: 'http:\/\/tn-skr4.smilevideo.jp\/smile?i=8368171'
	,	postedAt: new Date('2009\/09\/28 23:42:41 +0900')
	,	length: 983
	,	viewCount: 90941
	,	mylistCount: 5276
	,	commentCount: 14176
	,	movieType: 'mp4'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
		thumbPlayKey: '1258959395.0.f88rkXvd1_ydaKXjLNMHjB4j3Mo.'
	,	wv_title: '\u3010\u304a\u3063\u3071\u3044\u8b70\u54e1\u3011 \u30df\u30f3\u30b9\u306e\u6182\u9b31 \u300c\u53cb\u611b\u3067\u3057\u3087\u3067\u3057\u3087\uff1f\u300d'
	,	bgms: 'nm5575978,swf'
	,	has_owner_thread: '1'
	,	iee: '1'
	}, '320', '265');
	player.write();
})();

