window.addEvent('domready', function() {
	
	
	var jsonRequest = new Request.JSON({url: '/clients.php',
		onRequest: function(){
		},	   
		onSuccess: function(clients){
			
			
			$('clients').set('html','');
			
			clients.each(function (o,i) {
				
				var sep = new Element('div',{'class': 'separator'});
				var clear = new Element('div',{'class': 'clear'});
				var item = new Element('a',{'href': o.link,'target':'_blank', 'id': 'client_'+ o.id ,'class': 'clients','styles':{'opacity':0}});
				var image = new Element('img',{'src': '/upload/clients/' + o.image ,'alt': o.name});
				
				item.grab(image,'bottom');
				
				item.addEvent('mouseenter', function(e) { e.stop(); this.getChildren('img').fade(1,0.2) });
				item.addEvent('mouseleave', function(e) { e.stop(); this.getChildren('img').fade(1)});
	       
		//(function(){
		
				
		
				if(i%6==0) $('clients').grab(clear, 'bottom');
				else $('clients').grab(sep, 'bottom');
				$('clients').grab(item,'bottom');
		
		item.fade(1);
		//}.delay(60 * i ));
			});
		}
	});
	jsonRequest.get();
});
