var Site = {

  start: function() {
    mySmoothScroll = new SmoothScroll({links: '.orgs a'});
    
    h1 = $$('.orgs')[0].getStyle('height');
    h2 = $$('.orgs')[1].getStyle('height');
    if (h1.toInt() > h2.toInt()) $$('.orgs')[1].setStyle('height', h1);
    else $$('.orgs')[0].setStyle('height', h2);
    
    // dragable
    var myMove1 = new Drag($('about'));
    // var myMove2 = new Drag($('help'));
    
    // questions
    $$('.box').fade('hide');
    $$('#questions a').addEvent('click', function(event){
      event.stop();
      id = Site.getHash(this.href);
      if ($$('.visible')[0] && !$(id).hasClass('visible')) {
        Site.dramaticExit($$('.visible')[0]);
        $(id).setStyle('left', 55);
        $(id).setStyle('top', 185);
        Site.dramaticReveal($(id));
      }
      else if(!$(id).hasClass('visible')) {
        $(id).setStyle('left', 55);
        $(id).setStyle('top', 185);
        Site.dramaticReveal($(id));
      }
    });
    
    // close answers
    $$('.box .close').addEvent('click', function(){
      Site.dramaticExit(this.getParent('div'));
    });
    
    // questions
    $$('.orgs a').addEvent('click', function(e){
      id = Site.getHash(this.href);
      var Highlighter = new Fx.Tween($(id));
      Highlighter.start('background-color','#fff840');
      (function(){Highlighter.start('background-color','#ffffff')}).delay(1200);
    });
    
  },
  
  getHash: function(url) {
    return url.split('#')[1];
  },
  
  dramaticReveal: function(element) {
    var tada = new Fx.Morph(element, {duration: '500', transition: Fx.Transitions.Sine.easeOut});
    tada.start({
        'left': element.getStyle('left').toInt()+10, 
        'top': element.getStyle('top').toInt()+5, 
        });
    element.fade('in');
    element.addClass('visible');
  },
  
  dramaticExit: function(element) {
    var tada = new Fx.Morph(element, {duration: '500', transition: Fx.Transitions.Sine.easeOut});
    tada.start({
        'left': element.getStyle('left').toInt()+10, 
        'top': element.getStyle('top').toInt()+5, 
        });
    element.fade('out');
    element.removeClass('visible');
  }
  

}

window.addEvent('domready', Site.start);