var Geyder = {
	initialize: function() {
	  $('container').makeClipping().setStyle({
	    width:'840px', 
	    height:'500px'
	  });
	  var acc = new accordion('accordion', {
	    resizeSpeed: 8,
	    defaultSize: {
	      height: 380
	    }
	  });
	  acc.activate($$('div#accordion .accordion_toggle')[0]);
	  new Control.Tabs('tab_group_biowaerme');
	  new Control.Tabs('tab_group_heiztechnik');
	},
	unloadCurrentContent: function() {
	  if(this.currentContent != null) {
	    this.currentContent.unload();
	  }
	},
	currentContent: null
}

var Menu = {
  isVisible: false,
  load: function() {
    $('menu').morph('left:0', {duration:1.2, delay:0.9});
  }
}

var Startseite = {
  isVisible: false,
  galleryPlayed: false,
  load: function() {
    if(this.isVisible) {
      return;
    } 
    else {
      if(Geyder.currentContent != 'Startseite') Geyder.unloadCurrentContent();
      $('startseite-link').addClassName('active');
      if(!this.galleryPlayed) {  
        new Effect.Appear($('startseite1'), {duration:1.2, delay:0.4});
  	    new Effect.Appear($('startseite2'), {duration:1.2, delay:1.9});
  	    new Effect.Appear($('startseite3'), {duration:1.2, delay:3.4,
    	    afterFinish: function() {
    	      $('startseite-text').morph('bottom:0px', {duration:1.5, delay:0.5});
      		  if(!Menu.isVisible) { 
      		     Menu.load();
      		  }
      		  $('startseite1', 'startseite2').invoke('hide'); 
    	    }
    	  });
  	    this.galleryPlayed = true;
  	  }
  	  else {
  	    new Effect.Appear($('startseite3'), {duration:0.8, delay:0.4,
  	      afterFinish: function() { $('startseite-text').morph('bottom:0px', {duration:1.0, delay:0.5}); }
  	    });
  	  }
  	  Geyder.currentContent = this;
  	  this.isVisible = true;
  	}
  },
  unload: function() {
    $('startseite-text').morph('bottom:-207px', {duration:1.0, delay:0.5});
    new Effect.Fade($('startseite3'), {duration:0.8, delay:1.0});
    $('startseite-link').removeClassName('active');
    this.isVisible = false;
  }
}

var Leistungen = {
  isVisible: false,
  load: function() {
    if (this.isVisible) {
      return
    }
    else {
      if (Geyder.currentContent != 'Leistungen') Geyder.unloadCurrentContent();
      $('leistungen-link').addClassName('active');
      new Effect.Appear($('leistungen'), {duration:1.2, delay:0.4});
      Geyder.currentContent = this;
      this.isVisible = true;
    }
  },
  unload: function() {
    new Effect.Fade($('leistungen'), {duration:0.8, delay:0.8});
    $('leistungen-link').removeClassName('active');
    this.isVisible = false;
  }
}

var Kontakt = {
  isVisible: false,
  load: function() {
    if(this.isVisible) {
      return
    }
    else {
      if(Geyder.currentContent != 'Kontakt') Geyder.unloadCurrentContent();
      $('kontakt-link').addClassName('active');
      new Effect.Appear($('kontakt'), {duration:1.2, delay:0.4});
      $('kontakt-text').morph('bottom:0px', {duration:0.8, delay:1.8});
      Geyder.currentContent = this;
      this.isVisible = true;
    }
  },
  unload: function() {
    $('kontakt-text').morph('bottom:-149px', {duration:0.8, delay:0.4});
    new Effect.Fade('kontakt', {duration:0.8, delay:0.8});
    $('kontakt-link').removeClassName('active');
    this.isVisible = false;
  }
}

var WirUeberUns = {
  isVisible: false,
  load: function() {
    if(this.isVisible) {
      return
    }
    else {
      if(Geyder.currentContent != 'WirUeberUns') Geyder.unloadCurrentContent();
      $('wirueberuns_1').appear();
      $('wirueberuns-link').addClassName('active');
      Geyder.currentContent = this;
      this.isVisible = true;
      this.currentPage = 1;
    }
  },
  showMore: function() {
    $('wirueberuns_1').fade();
    $('wirueberuns_2').appear();
    this.currentPage = 2;
  },
  unload: function() {
    $('wirueberuns_'+this.currentPage).fade();
    $('wirueberuns-link').removeClassName('active');
    this.isVisible = false;
    
  }
}



Event.observe(window, 'load', function() {
  Geyder.initialize();
	if(!Startseite.isVisible) {
    Startseite.load();
	}
});
