/**
 * @author duncan@readitsideways.com
 */
var rotating = new Hash();

rotating.set('products', ['groceries.jpg', 'lotions.jpg']);
rotating.set('services', ['beauty.jpg', 'cleaning.jpg', 'hairstyling.jpg']);
rotating.set('products_count', 0);
rotating.set('services_count', 0);

function rotate_images(type){
    var r = rotating.get(type);
    var i = rotating.get(type+'_count');
	
	$(type + '_box').fade({duration:0.6});
	
    setTimeout(function(){
		$(type + '_box').style.background = 'URL("images/rotating/' + type + '/' + r[i] + '") center center  no-repeat';
		}, 600);
		
	setTimeout(function(){
		$(type + '_box').appear({duration:0.6});
		}, 650);
	
	i = ((i+1)==r.length) ? 0:i+1;
	rotating.set(type+'_count', i);
    
	setTimeout(function(){
		return rotate_images(type);
	}, 8000);
}


