window.addEvent('domready', function() {
 var tips = new Tips('.tips');
 tips.addEvent('show', function(tip, el) { tip.fade('in'); });
 tips.addEvent('hide', function(tip, el) { tip.fade('out'); });

 $$('.box h2 a').each(function(item) {
  item.setStyle('cursor', 'pointer');
  var elToHide = item.getParent('h2').getNext('div');
  if (elToHide) {
   var mySlide = new Fx.Slide(elToHide);
   item.store('fx', mySlide);
   if (item.hasClass('hidden')) mySlide.hide();

   item.addEvent('click', function(e) {
    e.stop();
    var fx = this.retrieve('fx');
    fx.toggle();

    if (item.hasClass('hidden')){
     item.removeClass('hidden').addClass('visible');
    }
    else {
     item.removeClass('visible').addClass('hidden');
    }
   });
  }
 });

 if ($('section-menu')) {
  var accordion = new Accordion('a.menuitem', 'ul.submenu', {
   opacity: false,
   onActive: function(toggler, element){
    toggler.addClass('current');
    element.addClass('current');
   },
   onBackground: function(toggler, element){
    toggler.removeClass('current');
    element.removeClass('current');
   }
  }, $('section-menu'));
 }

 if ($('accordion')) {
  var accordion = new Accordion('h3.atStart', 'div.atStart', {
   opacity: false,
   onActive: function(toggler, element){
    toggler.setStyle('font-weight', 'bold');
    toggler.setStyle('background', '#fff');
   },
   
   onBackground: function(toggler, element){
    toggler.setStyle('font-weight', 'normal');
    toggler.setStyle('background', '#eee');
   }
  }, $('accordion'));
 }

});

var d=document;

function log_in() {
 if(d.lg.eml.value=='') alert('Please enter your email address in order to log in.');
 else if(d.lg.pwd.value=='') alert('Please enter your password in order to log in.');
 else {
  if(d.lg.ret.value == '') d.lg.ret.value=location.pathname+location.search;
  d.lg.action='https://'+location.hostname+'/log_in.html';
  d.lg.submit();
  return true;
 }
 return false;
}
