/*==============================================================================
	iBlog のエントリページへのリンクを Technorati で調べる。
	Coyright (C) 2006 OKAMURA Yuji, All rights reserved.
==============================================================================*/
function EntryPageURL4BlogPage(categoryUUID, entryUUID) {
	var	url = String(window.location);

	url = url.replace(/(?:index\.html)?(?:\?.*)?(?:#.*)?$/, '');

	return url + categoryUUID + '/' + entryUUID + '/index.html';
}

function EntryPageURL4CategoryPage(entryUUID) {
	var	url = String(window.location);

	url = url.replace(/(?:index\.html)?(?:\?.*)?(?:#.*)?$/, '');

	return url + entryUUID + '/index.html';
}

function EntryPageURL4EntryPage() {
	var	url = String(window.location);

	url = url.replace(/(?:\?.*)?(?:#.*)?$/, '');
	url = url.replace(/\/$/, '/index.html');

	return url;
}

function EntryPageURL4DayPage(archiveLink) {
	var	url = String(window.location);

	url = url.replace(/\d+\/\d+\/\d+\/index\.html(?:\?.*)?(?:#.*)?$/, '');
	archiveLink = archiveLink.replace(/^\.\.\/\.\.\/\.\.\//, '');

	return url + archiveLink;
}

function TechnoratiUrl(targetURL) {
	if (targetURL) {
		return 'http://www.technorati.com/search/'
			+ encodeURIComponent(targetURL);
	}
	else {
		return undefined;
	}
}

function TechnoratiLinkHTML(targetURL) {
	var	href = TechnoratiUrl(targetURL);

	if (href) {
		return '<a href="'+href+'" title="Technorati Search: '+targetURL+'"><img src="http://technorati.com/tools/mozsearch/technorati.png" width="16" height="16" border="0" alt="Technorati による '+targetURL+' へのリンク一覧" /></a>';
	}
	else {
		return '';
	}
}

function WriteTechnoratiLink(targetURL) {
	document.write(TechnoratiLinkHTML(targetURL));
}
