function animate(){
var rotators=$$('.rotate');
if (rotators.length>=1){
                  var switchers=new Array(rotators.length);
                  rotators.each(function(el, i){
                  var images = el.getElements('img');
                  switchers[i]=new Switcher(images, false,i);
               });      
               }
}

function autor(){
var wraps=$$('.divider_wrapper');
      wraps.each(function(el, j){
           el.addEvents({
               'mouseover'  : function(){
                  var hovers=el.getElements('.hover_effect');
                  hovers.each(function(elm, j){
                  elm.set('morph',{
                      link:'cancel',
                      duration:200,
                      onComplete: function() {
                          elm.removeClass('aut_small');
                          elm.addClass('author');
                            var iwrap=elm.getElements('.hidden');
                            iwrap.set('morph',{link:'ignore',duration:300,transition: Fx.Transitions.linear});
                            iwrap.setStyle('height',0);
                            iwrap.removeClass('hidden');
                            iwrap.morph({'height':135});
                        }
                        
                       });
                   elm.morph({
                   'height': 200
                   });
                  });
               
                },
               'mouseleave' : function(){
                  var hovers=el.getElements('.hover_effect');
                  hovers.each(function(elm, j){
                  elm.set('morph',{
                      link:'cancel',
                      duration:200,
                      onComplete: function() {
                              elm.addClass('aut_small');
                              elm.removeClass('author');
                              elm.getElements('.img_wrap').addClass('hidden');
                            }
                     });
                  elm.morph({
                  'height': 34
                  
                  });
                      
                  });
                }
            });
        });
}

                  


var Switcher = new Class({
        initialize: function(images,controls,order){
        this.duration=5000;
        this.interval=2500;
        this.latency=(order*this.duration)/4;
        this.bs=images;
        this.anim=null;
        this.animating=false;
        this.icons=controls;
        this.actual=new Array(this.bs.length);
        this.actualb=0;
        this.bs.setStyle('opacity', 0);
        this.fill_actual();
        this.bs[0].setStyle('opacity', 1); 
        this.setAnim(this);
        this.change(this.actualb,this);
        this.start_anim.delay(this.latency,null,this);        
        
   },
    fill_actual: function(){
    l=this.actual.length;
    for(var i=0;i<l;i++){
      this.actual[i]=0;  
      }
  
    },
    start_anim: function(self){
    //if(!self.animating){
    self.animating=true;
    self.anim=(function(){
    self.actualb++;
    self.actualb=self.actualb % self.bs.length;
    self.change(self.actualb,self);
    }).periodical(self.duration);
    //}
    },
    
    setAnim: function(self){ //set initail events and morphing properties
 //    alert('stared');
    this.bs.each(function(el, i) {
            el.setStyles({position : 'absolute' , left: 0 , top:0});
            el.set('morph', {link : 'cancel', duration: self.interval});
            el.addEvents({
              'mouseenter': function() {
                  $clear(self.anim);
                  self.animating=false;
                  },
              'mouseleave' : function() {
                  if(this.icons) {self.icons[i].removeClass('active');}
                  if (!self.animating){
                  self.start_anim(self);
                  }
                }
             });
            
         });
     
     if (this.icons){    
     this.icons.each(function(el, i) {    
          el.addEvents({
              'mouseenter': function() {
                  self.icons[i].addClass('active');
                  //self.change(i,self);
              },
              'click': function() {

                  $clear(self.anim);
                  self.animating=false;
                  self.change(i,self);
                  self.actualb=i;
              },

              'mouseleave' : function() {
                  self.icons[i].removeClass('active');
                  if (!self.animating){
                  self.start_anim(self);
                  }
              }   
          });
     
      });
      }
      },
      change: function(i,self){
        ar=self.actual;
          if (ar[i]!=1){ //if buuble isnt active;
          ar.each(function(item, i) {
                if (item==1){
                self.bs[i].morph({'opacity' : 0});
                }
                item=0;
              });
          self.fill_actual();     
          ar[i]=1;
          self.bs[i].morph({'opacity' : 1});
          }
      }
            
});
window.addEvent('domready', function(){animate();dropdown();autor()});
// JavaScript Document

function dropdown(){
if (($$('#cv_content')).length>0){
var myMenu= new Fx.Slide('cv_content');
var butt=$('toggle');//.getElement('span');
myMenu.hide();
butt.setStyle('cursor', 'pointer');
butt.addEvent('click', function(e){
myMenu.toggle().chain(function(){
if (myMenu.open){butt.getParent('h2').addClass('active');}
else {butt.getParent('h2').removeClass('active');}
});
});
}
}

