/*
 ****************************************************************************
 * File : prototype.effect.js
 * Copyright (C) 2005-2008 http://bizcaz.com/ All rights reserved.
 ****************************************************************************
*/
var tagclouds = {
	version: '1.0.4',
	weight: 1,        // フォント重み(大きい値にするとフォントが小さくなる)
	font_size_min: 12,// 基準となるフォント最小サイズ
	font_size_max: 41,// 基準となるフォント最大サイズ
	count_min: Math.log(1),	// 最小タグ数(自然対数仕様)
	count_max: Math.log(181),// 最大タグ数(自然対数仕様)

	init: function() {
		var tags       = new Array();
		var now        = (new Date()).getTime();
		var tagsNode   = document.getElementById('tags');
		var childNodes = tagsNode.childNodes;

		this.font_size_min /= this.weight;
		this.font_size_max /= this.weight;

		for (var i = 0;i < childNodes.length;i++) {
			var e = childNodes.item(i);

			if (e.nodeName.match(/li/i)) {
				var s = e.title.split(':');

				var d    = s[2].split('-');
				var diff = (now - (new Date(d[0], d[1] - 1, d[2])).getTime()) / 86400000;

				e.style.fontSize = this.calc_fontsize(s[1]) + 'px';

				if (diff < 15) {
					e.className = 'rank_1';/*      ～ 15日*/
				}
				else if (diff < 30) {
					e.className = 'rank_2';/*  15日～ 30日*/
				}
				else if (diff < 90) {
					e.className = 'rank_3';/*  30日～ 90日*/
				}
				else if (diff < 180) {
					e.className = 'rank_4';/*  90日～180日*/
				}
				else if (diff < 365) {
					e.className = 'rank_5';/* 180日～365日*/
				}
				else if (diff >= 365) {
					e.className = 'rank_6';/* 365日～     */
				}


				tags.push([e, s[1]]);
			}
		}

		tagsNode.style.display = 'block';
	},

	calc_fontsize: function (count) {
		count = Math.log(count);// 自然対数仕様
		return (this.font_size_max - this.font_size_min) * (count - this.count_min) / (this.count_max - this.count_min) + this.font_size_min;
	}
};

function updated_today() {
	var date = new Date();
	var yy   = date.getYear();      if (yy < 1900) { yy += 1900;     }
	var mm   = date.getMonth() + 1; if (mm <   10) { mm  = '0' + mm; }
	var dd   = date.getDate();      if (dd <   10) { dd  = '0' + dd; }

	var today    = yy+'/'+mm+'/'+dd;
	var updated  = '2008/03/04';

	if (updated == today) {

		var today_link = 'javascript:void(0);';

		var out = '<div id="updated_today"><a href="'+today_link+'" title="Updated Today:'+today+'">&nbsp;</a></div>';

		document.write(out);
		new Effect.Appear('updated_today', {from:0.1, to:1.0, duration:1.0})
	}
}

Event.observe(window, 'load', function() {
	$$('a[href^=#]:not([href=#])').each(function(element) {
		element.observe('click', function(event) {
			new Effect.ScrollTo(this.hash.substr(1));
			Event.stop(event);
		}.bindAsEventListener(element))
	})
});
Event.observe(window, 'load', function() {
	$$('#navibar').each(function(element) {
		var location    = encodeURI(document.location.href).replace(/#.*/,'');
		var descendants = element.descendants();

		descendants = descendants.map(function (descendant) {
			return $(descendant);
		});

		for (var i = 0, length = descendants.length;length > i;i++) {
			var elem = descendants[i];

			if (elem.tagName.match('A')) {
				if (location == elem.href) {
					Element.addClassName(elem, 'current');
					elem.href = 'javascript:void(0);';
					break;
				}
			}
		}
	})
});
/*
Event.observe(window, 'load', function() {
	tagclouds.init();
});
*/
