var panels = {
	_moving: false
	, init: function() {
		panels._moving = false;
	}, toggle: function(p) {
		if (!panels._moving) {
			panels._moving = true;
			if (p.hasClassName('open')) {
				panels._close(p);
			} else {
				// warning - there will be a very brief (miliseconds) period of time where _moving is false and we are actually moving (finishing the open)
				if (p.up('.shuffler').down('.open')) {
					panels._close(p.up('.shuffler').down('.open'));
				}
				panels._open(p);
			}
		}
	}, _close: function(p) {
		p.removeClassName('open');
		p.down('.panel-content').visualEffect('blind_up',{duration:.5, afterFinish:function() { panels._moving = false; }});	
	}, _open: function(p) {
		p.addClassName('open');
		p.down('.panel-content').visualEffect('blind_down',{duration:.5, afterFinish:function() { panels._moving = false; }});
	}
};

var home = {
	_delay: 5
	, _fade: .5
	, init: function() {
		home._set_z_index();
		window.setInterval(home._switch, (home._delay * 1000));
	}, _switch: function() {
		$('home-animation').down('img').visualEffect('fade', { duration: home._fade, afterFinish: function() {
			img = $('home-animation').down('img');
			$('home-animation').insert({bottom: $('home-animation').down('img')});
			home._set_z_index();
			img.show();
		} });
	}, _set_z_index: function() {
		var images = $$('#home-animation img');
		
		images.each(function(s, index) {
			s.setStyle('z-index:' + (images.length - index) +';');
		});		
	}
};
