catid = '';
year = '';
blogid ='';
Event.observe(window, 'load', init, false);
function init() {
	scrollToAnchor();
	hiliteMenu();
	mouseOverImgs();
}
function scroll() {
	var myid = location.search;
	myid = 'e' + myid.replace(/^\?/,"");
	if (myid && $(myid)) {
		new Effect.ScrollTo(myid);
	}
}
function hiliteMenu() {
	var blogs = {
		2: 'about',
		3: 'uchikui',
		4: 'workshop',
		5: 'whoswho',
		6: 'yell',
		7: 'membership',
		8: 'words',
		9: 'links',
		10: 'contact',
		11: 'events',
		12: 'diary'
	};
	var cats = {
		1: 'future',
		2: 'future',
		5: 'past',
		6: 'past',
		8: 'a',
		9: 'ka',
		10: 'sa',
		11: 'ta',
		12: 'na',
		13: 'ha',
		14: 'ma',
		15: 'ya',
		16: 'ra',
		17: 'wa',
		18: 'future',
		19: 'past'
	};
	if (catid) {
		var elmid = cats[catid];
		if ($(elmid)) {
			if (catid > 7 && catid < 18) {
				$(elmid).src = '/whoswho/img/akasatana/' + cats[catid] + '_o.gif';
			} else {
				$(elmid).src = '/img/menu/' + cats[catid] + '_o.gif';
			}
			$(elmid).className = 'btn-current';
		}
	}
	if (year) {
		var elmid = year;
		if ($(elmid)) {
			$(elmid).src = '/img/menu/' + year + '_o.gif';
			$(elmid).className = 'btn-current';
		}
	}
	if (blogid) {
		var elmid = blogs[blogid];
		if ($(elmid)) {
			$(elmid).src = '/img/menu/' + blogs[blogid] + '_o.gif';
			$(elmid).className = 'btn-current';
		}
	}
}

function mouseOverImgs() {
  var btns = $A(document.getElementsByClassName('btn'));
  btns.each(function (node){
    node.outsrc = node.src;
    node.oversrc = node.src.replace('.gif', '_o.gif').replace('.jpg', '_o.jpg');
    var overimg = new Image();
    overimg.src = node.oversrc;
    node.onmouseover = function() { this.src = this.oversrc; };
    node.onmouseout = function() { this.src = this.outsrc; };
  });
}

function scrollToAnchor() {
  $$('a[href^=#]:not([href=#])').each(function(element) {
    element.observe('click', function(event) {
      var anc = this.hash.substr(1);
      if (anc.match(/^[0-9]+$/)) anc = 'e' + anc;
      new Effect.ScrollTo(anc);
      Event.stop(event);
    }.bindAsEventListener(element))
  })
}