window.addEvent('domready', function() {
//    this.selects = $$('div#menu p');
//    $$('div#menu a').each(function(lnk, index) {
//	lnk.addEvent("click", function(e) {
//	    this.selects[index]
//      }, this);

    this.section = $('content');
    this.sections = $$('div#content div');
//    this.sliders = this.sections.map(function(div) {
//	return new Fx.Slide(div, { duration: 1000, mode: 'vertical' }).hide();
//      });
//    this.faders = $$('div#content div').map(function(div) {
//	return new Fx.Style(div, 'opacity', {duration: 1000 });
//      });
    this.selects = $$('div#menu p');
//    this.menutop = this.selects.map(function(p) {
//	return new Fx.Style(p, 'padding-top', { duration: 250 });
//      });
//    this.menubottom = this.selects.map(function(p) {
//	return new Fx.Style(p, 'padding-bottom', { duration: 250 });
//      });
    this.selectsEffects = this.selects.map(function(p) {
	return new Fx.Morph(p, { duration: 250, transition: Fx.Transitions.Sine.easeOut });
      });
    $$('div#menu a').each(function(lnk, i) {
	lnk.addEvent('click', function() {
//	    this.menutop[index].start(6);
//	    this.menubottom[index].start(6);
//	    this.sliders.each(function(slider, sliderIndex) {
//		if (sliderIndex != index) {
//		  this.selects[sliderIndex].removeClass('selected');
//		  this.sliders[sliderIndex].hide();
//		  this.menutop[sliderIndex].start(0);
//		  this.menubottom[sliderIndex].start(0);
//		}
//	      }, this);
	    this.selects.each(function(select, j) {
		if (i == j)
		  this.selects[j].addClass('selected');
		else {
		  this.selects[j].removeClass('selected');
		  this.selectsEffects[j].start({ 'padding-top': [0], 'padding-bottom': [0] });
		}
	      });
	    this.selectsEffects[i].start({ 'padding-top': [6], 'padding-bottom': [6] });
	    
	    var request = new Request({ method: 'get', url: '/data/section_' + i + '.xml',
		  onFailure: function(r) { alert("failed!"); },
		  onSuccess: function(responseText, responseXML) { $('content').set('html', responseText); } });
	    request.send();

//	    this.sliders.each(function(slider, sliderIndex) {
//		if (sliderIndex == index) {
//		  this.selects[sliderIndex].addClass('selected');
//		  this.sliders[sliderIndex].slideIn();
//		  this.faders[sliderIndex].start(1);
//		  //            setTimeout('dl.sliders['+sliderIndex+'].slideIn()', 1000);
//		}
//	      }, this);
	  }.bind(this));
      }, this);
    $$('div#menu a')[0].fireEvent("click");
  });
