var speed = 2000; //speed of the fade (milliseconds)
var interval = 5000; //duration between slides (milliseconds) 
var cl = '';
var newpost = '';
$(function(){
  //setup clone
  $('div.tabs > div').hide();
  size = $('div.tabs > div').size();
  $('div.tabs > div div.feat_post').hide();
  cl = $('div.tabs > div#tab1').clone();
  cl.attr('id','clone').show().find('div.feat_post').show();
  $('div.tabs').prepend(cl);
  //
  $('div.tabs ul.tabNavigation a').click(function(){
    clearInterval(setint);
    speed = 1;
    do_slide(this.hash);
    return false;
  });
  var setint = setInterval("do_slide();",interval + speed);
});

var arr = ['#tab1','#tab2','#tab3','#tab4','#tab5','#tab6','#tab7','#tab8','#tab9','#tab10'];
var z = 0;               

function do_slide(_hash){
  if(z+1 < size){z++;}else{z=0;}
  if(!_hash){_hash = arr[z];}
  var newim = $('div.tabs div'+_hash+' div.feature_slide > img').clone();
  newpost = $('div.tabs div'+_hash+' div.feat_post').clone();
  cl.find('div.feature_slide > img').after(newim).css('position','absolute');
  cl.find('div.feat_post').fadeOut(speed/2,function(){
    cl.find('div.feat_post').replaceWith(newpost).hide().find('*').hide();
    cl.find('div.feat_post').fadeIn(speed/2);
  });
  cl.find('div.feature_slide > img:first').fadeOut(speed,function(){$(this).remove();});
}
