var r_index = 1;
$(document).ready(function(){
	$('html').oneTime(2000, function(){
		$('.iv-rotator').fadeIn(4000);
	});
	r_play($('.iv-rotator .select li:eq(0)'));
	

	$('html').everyTime(10000, function() {       
    	//rand_d = Math.floor(4*Math.random());
    	r_play($('.iv-rotator .select li:eq('+r_index+')'));
        if(r_index == 3)
        {
            r_index = 0;
        }else
        {
            r_index++;
        }
        
	});


	$('.iv-rotator .select li').mouseenter(function(){
		r_play($(this));
	});
	$('.iv-rotator .select li').click(function(){
		var index = $('.select li').index($(this));
		var elem_l = $('.screen li:eq('+index+')');
		document.location.href = elem_l.find('a:first').attr('href');
	});
	
});

function r_play(elem)
{
	var index = $('.select li').index(elem);
	var elem_l = $('.screen li:eq('+index+')');
    $(elem_l).stop(true, true);
	$('.screen li .text').hide();
	$('.screen li').hide();
	$(elem_l).fadeIn('slow');
	showTextBlock($('.screen li:eq('+index+') div'));
  r_index = index;
  if(r_index == 3)
    r_index = 0;
  else
    r_index++;
}
function showTextBlock(elem)
{
	
	$(elem).slideDown('slow');
}


