var SlideList = new Class({
	initialize: function(menu, options) {
		this.setOptions(this.getOptions(), options);
		this.menu = $(menu), this.current = this.menu.getElement('li.current');
		this.menu.getElements('li').each(function(item){
			item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
			item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
			item.addEvent('mouseover', function(event){ this.clickItem(event, item); }.bind(this));
		}.bind(this));
		this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
		this.back.fx = this.back.effects(this.options);
		if(this.current) this.setCurrent(this.current);
	},
	setCurrent: function(el, effect){
		this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
		(effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
		this.current = el;
	},
	getOptions: function(){
		return { transition: Fx.Transitions.sineInOut, duration: 500, wait: false, onClick: Class.empty };
	},
	clickItem: function(event, item) {
		if(!this.current) this.setCurrent(item, true);
		this.current = item;
		this.options.onClick(new Event(event), item);
	},
	moveBg: function(to) {
		if(!this.current) return;
		this.back.fx.custom({ left: [this.back.offsetLeft, to.offsetLeft], width: [this.back.offsetWidth, to.offsetWidth]
		});
	}
});

// Suckerfish menu code
sfHover = function() {
	var sfEls = document.getElementById("homenav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() { this.className+=" sfhover"; }
		sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); }
	}
}

function ConfirmMsg(msg) { 
  document.returnValue = confirm(msg);
}

function showSection(num) { 
	$("section1").style.display = "none";
	$("section2").style.display = "none";
	$("section3").style.display = "none";
	$("section4").style.display = "none";
	$("section"+num).style.display = "block";
}

function enlargemap(picpath) {
	$('subdivisionmap').src = picpath;
	$('zoomlink').style.display = "none"; 
}

function mwsdomtabs(tabid) {
	if (!tabid) {
		if ($('domtab')) {
			// Show initial tab.
			tab_bodies = $$('div#domtab div.tab');
			tab_bodies[0].style.display = 'block';
			tabs = $$('ul.domtabs li');
			tabs[0].className = 'active';
		}
	} else {
		// Hide the tab bodies!
		tab_bodies = $$('div#domtab div.tab');
		for (var i=0; i<tab_bodies.length; i++) {
			tab_bodies[i].style.display = 'none';
		}
		// Now show just the one we want.
		$(tabid+"_tab_body").style.display = 'block';
		// Update the tab up top to reflect the change.
		tabs = $$('ul.domtabs li');
		for (var i=0; i<tabs.length; i++) {
			tabs[i].className = '';
		}
		$(tabid+"_tab").className = 'active';
	}
	return false;
}




SlideList.implement(new Options);
window.addEvent('domready', function() {
	new SlideList($E('ul', 'nav'), {transition: Fx.Transitions.backOut, duration: 700, onClick: function(ev, item) { ev.stop(); }});
	sfHover;
	mwsdomtabs();
});

