// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//

document.observe('dom:loaded', function(){
    /*
    if($('tuesday-content')){
      $('tuesday-content').hide();
      $$('#tuesday span')[0].replace('<span>show</span>');
    }

    if($('wednesday-content')){
      $('wednesday-content').hide();
      $$('#wednesday span')[0].replace('<span>show</span>');
    }
    */

    $$('h2.day-drop-down').each(function(el){
      el.observe('click',function(){
        var thisId = this.id;
        if($(thisId + '-content').visible()){
          this.removeClassName('active');
          $(thisId + '-content').slideUp();
          $$('#' + thisId + ' span')[0].replace('<span>show</span>');
        } else {
          this.addClassName('active');
          $(thisId + '-content').slideDown();
          $$('#' + thisId + ' span')[0].replace('<span>hide</span>');
        }
      });
    });

    $$('#right div.feedback-form').each(function(){
      if(! $('edit-on')){
        $$('#right div.feedback-form')[0].hide();
          $('sign-up').observe('click', function(e){
            e.stop();
            if(Prototype.Browser.Gecko){
              Modalbox.show($$('#right div.feedback-form')[0], {title: "Sign up for the announcement list", width: 600});
            } else {
              document.location.href='/register';
            }
          });
      }
     });

    if($('language-toggle')){
      $('italian-content').toggle();
      $('language-toggle').observe('click', function(event){
          event.stop();
          var english = $('english-content');
          var italian = $('italian-content');
          if(english.visible()){
            $('flagicon').writeAttribute({src: '/english-lang-flag.gif'});
            english.slideUp();
            italian.slideDown();
          } else {
            $('flagicon').writeAttribute({src: '/italian-flag.gif'});
            english.slideDown();
            italian.slideUp();
          }
      });
    }

});
