var currentAboutUsPic = 1;
var countAboutUsPic = 0;

var timer = setInterval( showDiv, 5000);

jQuery(document).ready(function() {
                  
      jQuery('#companyAboutUsPicCotainer div').each(function(index){
          $(this).attr('id', 'aboutUsPic_'+(index+1));
          countAboutUsPic++;
          
          jQuery('.companyAboutUsPicNav').append('<a id="aboutUsPicTab_'+(index+1)+'" class="companyAboutUsPicTab'+(index==0?' current':'')+'" href="#" tabIndex="'+(index+1)+'" rel="nofollow">'+(index+1)+'</a>');
      });
      
      jQuery(".companyAboutUsPicNav a").click(function () {
      
          var tabIndex = jQuery(this).attr('tabIndex');
          
          jQuery('.companyAboutUsPicNav a').removeClass('current');
          jQuery(this).addClass('current');
          jQuery('.companyAboutUsPicItem').hide();
          currentAboutUsPic = tabIndex;
          jQuery('#aboutUsPic_'+tabIndex).show();
          clearInterval(timer);
          timer = setInterval( showDiv, 2000);
          return false;
      });
                  
});




function showDiv() {

      jQuery('.companyAboutUsPicItem').hide();
      jQuery('.companyAboutUsPicNav a').removeClass('current');
      
      currentAboutUsPic == countAboutUsPic ? currentAboutUsPic = 1 : ++currentAboutUsPic;
      
      jQuery('#aboutUsPic_'+currentAboutUsPic).show();
      jQuery('#aboutUsPicTab_'+currentAboutUsPic).addClass('current');
      
      

      //setInterval();
     
}

