function nasnosThumbnailerClick(id, src) {
	var target;
	if (document.target) {
		target = document.all[id];
	} else {
		target = document.getElementById(id);
	}
	if (target) {
		target.src = src;
	}
}

function nasnosThumbnailer() {
	var frame;
	if (document.all) {
		frame = document.all['contents_main'];
	} else {
		frame = document.getElementById('contents_main');
	}

	var regex = new RegExp('<thumbnail [^>]+>[^<]+<\/thumbnail>', 'igm');
	if (!frame.innerHTML.match(regex)) {
		return;
	}

	frame.innerHTML = frame.innerHTML.replace(
			regex
			,function (whole) {
				if (whole.match(/ mce_tsrc=\"(.*?)\"/im)) {
					var src=RegExp.$1;
					if (whole.match(/ for=\"(.*?)\"/im)) {
						var forid = RegExp.$1;
						if (whole.match(/<thumbnail .*?>(.*?)<\/thumbnail>/im)) {
							var image = '<a href="javascript: nasnosThumbnailerClick(\''+forid+'\', \''+RegExp.$1+'\')"><img src="'+src+'" /></a>';
							return image;
						}
					}
				}
			}
		);
	return;
}

function nasnosGoogleMap() {
	var frame;
	if (document.all) {
		frame = document.all['contents_main'];
	} else {
		frame = document.getElementById('contents_main');
	}

	if (!frame.innerHTML.match(/<googlemap .*?>/igm)) {
		return;
	}

	frame.innerHTML = frame.innerHTML.replace(
			/<googlemap .*?>/igm,
			function (whole) {
			var iframe = '<div style="text-align: center"><iframe ';
			if (whole.match(/width=\"(.*?)\"/igm)) {
			iframe += 'width="'+RegExp.$1+'" ';
			}
			if (whole.match(/height=\"(.*?)\"/igm)) {
			iframe += 'height="'+RegExp.$1+'" ';
			}

			iframe += 'frameborder="0" scrolling="no" marginheight="0" marginwidth="0" ';

			if (whole.match(/mce_tsrc=\"(.*?)\"/igm)) {
			iframe += 'src="'+RegExp.$1+'"';
			}

			iframe += '></iframe>';
			if (whole.match(/mce_thref=\"(.*?)\"/igm)) {
			iframe += '<br /><br /><a href="'+RegExp.$1+'" target="__blank">【大きな地図で見る】</a>';
			}

			return iframe + '</div>';;
			}
	);
}

function nasnosSwf() {
	var frame;
	if (document.all) {
		frame = document.all['contents'];
	} else {
		frame = document.getElementById('contents');
	}

	var regex = new RegExp('<swf .*?></swf>', 'igm');

	if (!frame.innerHTML.match(regex)) {
		return;
	}

	frame.innerHTML = frame.innerHTML.replace(
			/<swf .*?>(<\/swf>)?/igm,
			function (whole) {
				var src = '';
				if (whole.match(/mce_src=\"(.*?)\"/igm)) {
					src = RegExp.$1;
				} else {
					return '';
				}
				var width = 0;
				if (whole.match(/width=\"(.*?)\"/igm)) {
					width = RegExp.$1;
				}
				var height = 0;
				if (whole.match(/height=\"(.*?)\"/igm)) {
					height = RegExp.$1;
				}

				var swf = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'">';
				swf += "\n";
				swf += '<param name="movie" value="'+src+'" />';
				swf += "\n";
				swf += '<!--[if !IE]>-->';
				swf += "\n";
				swf += '<object type="application/x-shockwave-flash" data="'+src+'" width="'+width+'" height="'+height+'">';
				swf += "\n";
				swf += '<!--<![endif]-->';
				swf += "\n";
				swf += '<p>Alternative content</p>';
				swf += "\n";
				swf += '<!--[if !IE]>-->';
				swf += "\n";
				swf += '</object>';
				swf += "\n";
				swf += '<!--<![endif]-->';
				swf += "\n";
				swf += '</object>';
				swf += "\n";

			return swf;
			}
	);
}

