var current = -1;
function rotate()
{
	jQuery('.feature-block').removeClass('active').addClass("non-active");
	jQuery('#block-'+current).removeClass('non-active').addClass('active');
	jQuery('.graphic-part img').attr('src', feat_images[current]);
}

function doFTimeout()
{
	var data = {
		action: 'home_featured_used'
	};
	
	if(current == 3)
	{
		current = -1;
	}
	
	//console.log('start rotate');
	
	jQuery("#rotator div").each(function() 
	{
		if(this.id)
		{
			//console.log('id:'+this.id);
			thiscurr = this.id.substr(6);
			
			if(thiscurr > current)
			{
				current = thiscurr;
				rotate();
				
				return false;
			}	
			else
			{
				//console.log(current + " - " + thiscurr);
			}
		}
	});
	
	/*
	jQuery.post(ajaxurl, data, function(response)
	{
		jQuery('#home_featured_used').html(response);
	});
	*/
	setTimeout(function()
	{
		doFTimeout();
		
	}, 5000);
}

jQuery(document).ready(function() 
{
	setTimeout(function()
	{
		doFTimeout();
		
	}, 1000);

	jQuery("#rotator div").click(function() 
	{
     	current = this.id.substr(6);
     	rotate();
	});
});

