var openHeight = 507;
var closedHeight = 193;
var startImageFlow = false;

function showHeadCont(banner, callFunc) {
  var banner2;

  if(banner == 'dark') banner2 = 'light';
  else banner2 = 'dark';

  Effect.BlindUp('main_cont', { duration: 1.0 });

  if($('head_bg_'+banner).visible() == false) {
 /*
    new Effect.Parallel([
      new Effect.Fade('head_bg_'+banner2, { sync: true }),
      new Effect.Appear('head_bg_'+banner, { sync: true }),
    ],{
      duration: 0.5,
      delay: 0.5,
      queue: 'end'
    });
  */
    new Effect.Appear('head_bg_'+banner, { duration:0.3, queue:'end' });
    new Effect.Fade('head_bg_'+banner2, { duration:0.3, queue:'end' });
  }

  new Effect.Parallel([
    new Effect.Morph('banner', { sync: true, style:'height:'+openHeight+'px;' }),
    new Effect.Morph('banner_abs', { sync: true, style:'height:'+openHeight+'px;' }),
    new Effect.Morph('head_bg_'+banner, { sync: true, style:'height:'+openHeight+'px;' })
  ],{
    duration: 1.5,
    delay: 0.2,
    queue: 'end'
  });

  new Effect.Appear('head_cont', { queue: 'end', afterFinish:function() { startImageFlow=true; if(callFunc!='') {setTimeout(callFunc+'()', 10);} } });

}


function showMainCont(callFunc) {
  var banner;

  if($('myImageFlow') != null) {
    $('myImageFlow').hide();
  }

  new Effect.Fade('head_cont', { queue:'end' });

  if($('head_bg_light').visible())
    banner = 'light';
  else
    banner = 'dark';

  new Effect.Parallel([
    new Effect.Morph('banner_head', { sync: true, style:'height:'+closedHeight+'px;' }),
    new Effect.Morph('banner_abs_head', { sync: true, style:'height:'+closedHeight+'px;' }),
    new Effect.Morph('head_bg_'+banner, { sync: true, style:'height:'+closedHeight+'px;' })
  ],{
    duration: 1.5,
    delay: 0.2,
    queue:'end',
    afterFinish: function() { $('head_cont').innerHTML = ''; }
  });

  if($('head_bg_dark').visible() == false) {
    new Effect.Appear('head_bg_dark', { duration:0.3, queue:'end' });
    new Effect.Fade('head_bg_light', { duration:0.3, queue:'end' });
  }

  new Effect.BlindDown('main_cont', { queue: 'end', afterFinish:function() { startImageFlow=true; if(callFunc!='') {setTimeout(callFunc+'()', 10);} if($('myImageFlow') != null) { $('myImageFlow').show(); } } });

}

function toggleMainCont(callFunc) {

  if($('myImageFlow') != null) { $('myImageFlow').hide(); }
  new Effect.BlindUp('main_cont', { duration: 1.0 });
  new Effect.BlindDown('main_cont2', { duration:1.0, delay:0.5, queue: 'end', afterFinish:function() { startImageFlow=true; if(callFunc!='') {setTimeout(callFunc+'()', 10);} if($('myImageFlow') != null) { $('myImageFlow').show(); } } });
}

function toggleHeadCont(banner2, callFunc) {

  if($('head_bg_light').visible())
    banner = 'light';
  else
    banner = 'dark';

  if($('myImageFlow') != null) {
    $('myImageFlow').hide();
  }

  new Effect.Fade('head_cont', { duration:1.0, queue:'end' });

  new Effect.Parallel([
    new Effect.Morph('banner_head', { sync: true, style:'height:'+closedHeight+'px;' }),
    new Effect.Morph('banner_abs_head', { sync: true, style:'height:'+closedHeight+'px;' }),
    new Effect.Morph('head_bg_'+banner, { sync: true, style:'height:'+closedHeight+'px;' })
  ],{
    duration: 1.3,
    delay: 1.0,
    afterFinish: function() { $('head_cont').update($('main').innerHTML); $('main').innerHTML=''; },
    queue: 'end'
  });

  if(banner != banner2) {
    new Effect.Appear('head_bg_'+banner2, { duration:0.3, queue:'end' });
    new Effect.Fade('head_bg_'+banner, { duration:0.3, queue:'end' });
  }

  new Effect.Parallel([
    new Effect.Morph('banner_head', { sync: true, style:'height:'+openHeight+'px;' }),
    new Effect.Morph('banner_abs_head', { sync: true, style:'height:'+openHeight+'px;' }),
    new Effect.Morph('head_bg_'+banner2, { sync: true, style:'height:'+openHeight+'px;' })
  ],{
    duration: 1.3,
    delay: 0.5,
    afterFinish: function() { startImageFlow=true; new Effect.Appear('head_cont', { queue: 'end' }); if(callFunc!='') {setTimeout(callFunc+'()', 10);} if($('myImageFlow') != null) { $('myImageFlow').show(); } },
    queue: 'end'
  });

}
