$.fn.ellipse = function(options){
	options = $.extend({
		slides: 'a', /* slides */
		r: 20,	/* radius */
		kx: 1,   	/* ellipse koef. if k==0 then circle */
		ky: 1 
	}, options);
	var self = this;
	self.options = options;
	var slides = self.find(self.options.slides);
	self.center = {
		x: self.width()/2,
		y: self.height()/2
	} 
	var phi = 2*Math.PI/(slides.length);
	var gamma = Math.acos(Math.cos(phi/2));
	
	slides.each(function(i, item){
		var r = self.options.r;
		var kx = self.options.kx;
		var ky = self.options.ky;
		var dx = kx*2*r*Math.sin(i*phi/2)*Math.cos(i*gamma);
		var dy = ky*2*r*Math.sin(i*phi/2)*Math.sin(i*gamma);
		var x = self.center.x;
		var y = self.center.y;
		var item = $(item);
		var w = item.width();
		var h = item.height();
		var W = self.width();
		var H = self.height();
		item.css({
			left: Math.round((x+dx-w/2)),
			top: Math.round((y+dy-r*(ky)-h/2)),
			position: 'absolute'
		});
	});
	$('#preloader').css({
		zIndex: 100
	});
	$('#icons').css({
		zIndex: 100
	});
}

$(window).load(function(){
	$('#icons').ellipse({
		slides: 'div',
		r: 220,
		kx: 1.2,
		ky: 0.9
	});
});
