(function( $ ){

  $.fn.circlemenu = function(centerX, centerY, radius, startAngle, endAngle) {
  	centerX = parseFloat(centerX);
  	centerY = parseFloat(centerY);
  	radius = parseFloat(radius);
  	startAngle = parseFloat(startAngle);
  	endAngle = parseFloat(endAngle);
 	var AngleDistance;
 	var selector = '#'+this.attr('id')+' > li';
 	var ChildrenCount = this.children(selector).size();
 	var x, y;
 	if( ChildrenCount < 2 ) {
 		AngleDistance = 0;
 		if( ChildrenCount < 1 ) {
 			return;
 		}
 	}
 	else {
 		AngleDistance = (startAngle - endAngle) / (ChildrenCount-1);
 	}
 	$(this).css('list-style', 'none');
  	this.children(selector).each(function(index) {
  		x = centerX + radius * Math.cos((startAngle - AngleDistance * index) * Math.PI / 180 );
  		y = centerY + (-1) * radius * Math.sin((startAngle - AngleDistance * index) * Math.PI / 180 );
 		$(this).css('position', 'absolute');
 		$(this).css('left', x+'px');
 		$(this).css('top', y+'px');
  	});

  }
})( jQuery );
