
Effect.Circle = Class.create();
Object.extend(Object.extend(Effect.Circle.prototype,Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		this.start(arguments[1] || {});
	},
	
	setup: function() {
		
		this.images = this.element.childElements();
		counters = this.images.length
		radiant = 360/counters;
		this.r = (((this.element.getDimensions().width > this.element.getDimensions().height) ? this.element.getDimensions().height : this.element.getDimensions().width) / 2);
		this.radiants = new Array(counters);

		for(x=1;x<=counters;x++){
			this.radiants[x] = Math.round(360 - (radiant * x)); 
		}
		
		/* calcolo delle dimensione dei quadrati */
		this.size = Math.round(((Math.sin(radiant * Math.PI/180)*this.r)/5) * 4)-1;
		this.hsize = Math.round(this.size/2);

		
	},
	
	update: function(position) {
		x = 1;
		rs = this.radiants;
		ra = this.r;
		hs = this.hsize;
		s = this.size;
		
		this.images.each(function(img,index){
			img.setStyle({
				top: Math.round((Math.sin(rs[x] * Math.PI/180)* ra) + ra - this.hs)  + 'px',
				left: Math.round((Math.cos(rs[x] * Math.PI/180)* ra) + ra - this.hs) + 'px',
				width:  s + 'px',
				height: s + 'px'
			});
			rs[x] = rs[x] + 0.1;
			if (rs[x] == 360){
				rs[x] = 1;
			}
			x = x+1;
		});
	}
	
});
	
