var run_hot_jobs = true;
$(document).everyTime(4000, 'jobs1', function() {
  if(!run_hot_jobs)
    return ;
  cont = $('#hot_jobs .hot_jobs-left');
  cont2= $('#hot_jobs .hot_jobs-right');
  children = cont.children(); //cont1 children
  //remove first from first colunm
  cl = $(children[0]).clone();
  $(children[0]).fadeTo('slow', 0, function() {
  	$(this).slideUp('slow', function() {
      $(this).remove();
      cont.append(cl);
    });
  });
  //remove first from second colunm
  $(cont2.children()[0]).fadeTo('slow', 0, function() {
  	$(this).slideUp('slow', function() {
    	$(this).remove();
    });
  });
  ///Add last (9ight) child to second colunm
  o = children[10];
  $(document).oneTime(800,function() {cont2.append($(o).clone().css("display", "none").fadeIn('slow'))});
});
$(document).ready(function() {
  $('#hot_jobs').mouseover( function() {
    run_hot_jobs = false;
  });
  $('#hot_jobs').mouseout( function() {
    run_hot_jobs = true;
  });
  $(document).everyTime(8000, function() {
    if(testimonial_can_change) {
      switch_testimonial(1);
    }
  });
  $('#testimonials').mouseover(function() {
    testimonial_can_change = false;
  });
  $('#testimonials').mouseout(function() {
    testimonial_can_change = true;
  });
});
var testimonial_can_change = true;
var testimonial_position = 0;
var testimonial_changing = false;
function switch_testimonial(pos) {
  if(testimonial_changing == true) {
    return;
  }
  testimonial_changing = true;
  var children = $('#testimonials_list').children();
  if(children.length <= 1)
    return;
  old = testimonial_position;
  if(testimonial_position+pos < 0) testimonial_position = children.length;
  testimonial_position = testimonial_position+pos;
  if(testimonial_position >= children.length) testimonial_position = 0;
  $(children[old]).fadeOut('slow', function() {
    $(children[testimonial_position]).fadeIn('slow', function () {
      testimonial_changing = false;
    });
  });
}

