window.addEvent('domready', function(){
  
  var pics = $('jubiBox').getElements('img');
  
  pics[0].set('opacity','0');
  
  pics[0].set('id','jubpic1');
  pics[1].set('id','jubpic2');
  
  var mytween = new Fx.Tween(pics[0], {duration: 1200, transition: Fx.Transitions.Sine.easeInOut});
  var mytween2 = new Fx.Tween(pics[1], {duration: 1200, transition: Fx.Transitions.Sine.easeInOut});
  
  
  var myMorph = new Fx.Morph('jubpic1', {
    duration: 1200,
    transition: Fx.Transitions.Sine.easeInOut
  }); 
   
  var myMorph2 = new Fx.Morph('jubpic2', {
    duration: 1200,
    transition: Fx.Transitions.Sine.easeInOut
  });  
  
  var Site = { counter: 0 };
  var addCount = function(){ 
    this.counter++; 
    if(pics[0].get('opacity') == '0'){
      //mytween.start('opacity','1');
      myMorph.start({
        'opacity': 1,
      });
      myMorph2.start({
        'opacity': 0,
      });
    } else {
      //mytween.start('opacity','0');
      myMorph.start({
        'opacity': 0,
      });
      myMorph2.start({
        'opacity': 1,
      });
    }
    if(pics[1].get('opacity') == '0'){
      //mytween2.start('opacity','1');
      myMorph2.start({
        'opacity': 1,
      });
      myMorph.start({
        'opacity': 0,
      });
    } else {
      //mytween2.start('opacity','0');
      myMorph2.start({
        'opacity': 0,
      });
      myMorph.start({
        'opacity': 1,
      });
    }
  };
  addCount.periodical(4000, Site);
  
  
  var top = $('layout_head1').getElements('img');
  
  top[0].set('opacity','0');
  
  var mytween3 = new Fx.Tween(top[0], {duration: 1200, transition: Fx.Transitions.Sine.easeInOut});
  var mytween4 = new Fx.Tween(top[1], {duration: 1200, transition: Fx.Transitions.Sine.easeInOut});
   
  var Site2 = { counter: 0 };
  var addCount2 = function(){ 
    this.counter++; 
     if(pics[0].get('opacity') == '0'){
       mytween3.start('opacity','1');
     } else {
       mytween3.start('opacity','0');
     }
     if(pics[1].get('opacity') == '0'){
       mytween4.start('opacity','1');
     } else {
       mytween4.start('opacity','0');
     }
  };
  addCount2.periodical(4000, Site);
 
});


