// 適宜変更が必要
code="";

// <a href="#" onclick="openClip(this);return false;" onkeypress="openClip(this);return false;">Clip !!</a>
// <a href="#" onclick="similaritySearch(this);return false;" onkeypress="similaritySearch(this);return false;">Similarity Search By Bulkfeeds</a>
// のように利用する

function similaritySearch(e) {
	void(window.open("http://bulkfeeds.net/app/similar?url=" + escape(getPermaLink(e))));
}

function openClip(e) {
	void(window.open("http://clip.myblog.jp/shortcut/add_clip?title=&url="
		+ escape(getPermaLink(e)) + "&code=" + code,
		'AddClip',
		'scrollbars=no,width=430,height=320,left=100,top=100,status=yes,resizable=yes'));
}

// 指定要素以降で最初に見つかった"固定リンク"を得る
// ココログ専用
function getPermaLink(e) {
	while (e) {
		link = getPermaLinkInChildren(e);
		if (link) return link;
		while (e.nextSibling == null) {
			e = e.parentNode;
			if (!e) return null; // error
		}
		e = e.nextSibling;
	}
}
function getPermaLinkInChildren(e) {
	e = e.firstChild;
	while (e) {
		if (e.nodeValue == "固定リンク") return e.parentNode.getAttribute("href");
		link = getPermaLinkInChildren(e);
		if (link) return link;
		e = e.nextSibling;
	}
	return null;
}
