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/1249716285" target="_blank">\u3010\u7537\u3060\u3089\u3051\u5408\u5531\u3011\u3000\u300emagnet\u300f\u3000\u30109\u7d4418\u4eba\u3011\uff0bmp3</a></p>'
		);
		return;
	}

	var video = Nicovideo.Video.create({
		v: '1249716285'
	,	id: 'nm7871970'
	,	title: '\u3010\u7537\u3060\u3089\u3051\u5408\u5531\u3011\u3000\u300emagnet\u300f\u3000\u30109\u7d4418\u4eba\u3011\uff0bmp3'
	,	description: '\u30de\u30a4\u30ea\u30b9\uff11\u4e07\u30fb\u30fb\u30fb\u3060\u3068\u30fb\u30fb\u30fb\uff1f\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff08*\uff9f\u0434\uff9f*\uff09\u30bd\u30ed\u591a\u3081\u306e\u30ea\u30ec\u30fc\u5f62\u5f0f\u30b5\u30d3\u3060\u3051\u5408\u5531\u3063\u307d\u3044\u4f55\u304b\u3002\uff22\uff2c\u8981\u7d20\u3092\u542b\u307f\u307e\u3059\u3002\u80cc\u5f8c\u306b\u304a\u6c17\u3092\u3064\u3051\u3066\u3054\u8996\u8074\u304f\u3060\u3055\u3044(o\u00b4_\u3000_)o))\u25bc\u4eba\u9078\u306f\u8a66\u884c\u932f\u8aa4\u306e\u7d50\u679c\u3067\u3059(\u00b4\u30fb\u2200\u30fb`)\u672c\u5bb6\u69d8\uff08\u6d41\u661fP\u69d8\uff09\u3000\u2192\u3000sm6909505\u6b4c\u3044\u624b\u69d8\u3000\u2192\u3000mylist\/13138976\u300c\u304f\u308a\u3080\u305e\u3093\u00d7\u85ac\u4eba\u300d\u300cclear\u00d7\u86c7\u8db3\u300d\u300c\u3071\u306b\u3087\u00d7\uff15\u30b3\u30de\u30b9\u30d9\u30ea\u300d\u300c\u3051\u3063\u305f\u308d\u00d7\u30d9\u30a7\u30a7\u30a7\u30a7\u30b8\u30e5\u300d\u300cASK\u00d7\u3075\u3041\u306d\u308b\u300d\u300c\u540d\u7121\u3057\u00d7\u540d\u7121\u3057\u300d\u300ctane\u00d7ZERO\u300d\u300c\u30ec\u30df\u30e5\u30fc\u00d7\u307f\u30fc\u3061\u3083\u3093\u300d\u300c\u30b3\u30b2\u72ac\u00d7\u3080\u3063\u3061\u300d\u30de\u30a4\u30ea\u30b9\u30c8\u3000\u2192\u3000mylist\/8891391mp3\u2193\uff08\u5fae\u4fee\u6b63\u7248\uff0b\u53f0\u8a5e\u7121\u3057\u7248\u306e\uff12\u672c\u7acb\u3066\u306b\u306a\u308a\u307e\u3057\u305f\uff09http:\/\/www1.axfc.net\/uploader\/N\/so\/80629.zip&key=mag02'
	,	thumbnail: 'http:\/\/tn-skr3.smilevideo.jp\/smile?i=7871970'
	,	postedAt: new Date('2009\/08\/08 06:05:44 +0900')
	,	length: 241
	,	viewCount: 168221
	,	mylistCount: 13603
	,	commentCount: 376
	,	movieType: 'swf'
	,	isDeleted: false	,	isMymemory: false	});
	var player = new Nicovideo.MiniPlayer(video, {
		thumbPlayKey: '1258959854.0.Bp3pK1XZnDj_brQQlqgFI1TZFms.'
	,	wv_title: '\u3010\u7537\u3060\u3089\u3051\u5408\u5531\u3011\u3000\u300emagnet\u300f\u3000\u30109\u7d4418\u4eba\u3011\uff0bmp3'
	}, '420', '340');
	player.write();
})();

