var tabs = 3,
    cswitch = false,
    acttab = 0,
    timer,
    turndelay = 10000;

function initTabs(){
  turnTab();
  timer = setInterval("turnTab()", turndelay);
}

function turnTab(){
  if(cswitch==false){
    acttab = 1 * acttab + 1;
    if(acttab>tabs){acttab=1;}
  }else{
    cswitch=false;
  }
  $('.switch').removeClass('sw-active');
  $('.switch[rel='+acttab+']').addClass('sw-active');
  $('.dtext').fadeOut(250);
  $('.cyclebox img.ci').fadeOut(500);
  $('.cyclebox img.ci'+acttab).fadeIn(350, function(){
    $('.dtext').html( $('p.ct'+acttab).html() );
    $('.dtext').fadeIn(150);
  });
}

$(function(){
  $('a').click(function(){ $(this).blur(); });
  $('.cyclebox img:gt(0)').hide();
  $('.switch').click(function(){
    if( !$(this).hasClass('sw-active') ){
      acttab = $(this).attr('rel');
      cswitch = true;
      turnTab();
    }
    return false;
  });
  
  $('.cyclebox').hover(function(){
    clearInterval(timer);
  },function(){
    timer = setInterval("turnTab()", turndelay);
  });
  
  initTabs();
  
});
























