var LocalNav = Class.create();
LocalNav.prototype = {
	current: null,
	list: new Array(),
	
	initialize: function () {
		this.current = 1;
		
		var allNodes = document.getElementsByClassName('localnav');		
		
		for(var i = 0; i < allNodes.length; i++) if (allNodes[i].nodeType == 1) var container = allNodes[i];
		
		var nodes = container.childElements();
		var count = 0;
		
		for (var j = 0; j < nodes.length; j++) {
			count++;
			this.list[count] = nodes[j];
			nodes[j].down('a').onclick = function () { localnav.toggle(this.target); return false; };
		}
		
		var allNodes = document.getElementsByClassName('info-box');	
			for(var i = 0; i < allNodes.length; i++) if (allNodes[i].nodeType == 1) var container = allNodes[i];

		Element.setStyle(container, {height: Element.getHeight('info-box1')+'px'});

	},
	
	toggle: function (num) {
		if (num!=this.current) {
			this.list[this.current].removeClassName('current');
			this.list[num].addClassName('current');
			
			var allNodes = document.getElementsByClassName('info-box');	
				for(var i = 0; i < allNodes.length; i++) if (allNodes[i].nodeType == 1) var container = allNodes[i];

			new Effect.Morph(container,{style: {height: Element.getHeight('info-box'+num)+'px'}, duration: 0.5});
			
			Element.setOpacity('info-box'+num, 0);
      		Element.setStyle('info-box'+num, {top: '-120px'});
			Element.setStyle('info-box'+num, {display: 'block'});
			new Effect.Parallel([new Effect.DropOut('info-box'+this.current), new Effect.Move('info-box'+num, {x: 0, y: 0, mode: 'absolute'}), new Effect.Opacity('info-box'+num, {sync: true, to: 1.0, from: 0.0})], { duration: 0.5 });
			this.current = num;
		}
	}
}

var localnav;
var thisvar = 0;

function initPage() {
	localnav = new LocalNav();
}

Event.observe(window, 'load', initPage, false);