
(function($) {
    var active = false;

    $.fn.circlelayout = function(params) {

//idea: create the divs, but don't position them. Keep them hidden. Then we figure out how many we have, and display those
//       in  a circle. Each div has a function associated with it for what happens when we click on it.
//  the center of the circle is reserved for "doing stuff".  

	var binds = params['bindings'];
	var mouseovers = params['mouseovers'];

	var center_x = params['center_x'] || 99;
	var center_y = params['center_y'] || 99;
	var x = center_x;
	var y = center_y;
	var c = 0;

	for(var id in binds) 
	    {
		c++;
	    }
	var r = params['radius'] || 500;
	r = (r*(1/(Math.tan(Math.PI/c)))/2);        
	
	var ang = (360/c);

	var i = 0; // bind count
	for(var id in binds) {
	    $('#'+id).css("position","absolute");
	    $('#'+id).css("left", x+Math.cos(((ang*i*Math.PI)/180))*r);
	    $('#'+id).css("top", y+Math.sin(((ang*i*Math.PI)/180))*r);
	    $('#'+id).css("z-index",20);
	    $('#'+id).mouseover(mouseovers[id]);
	    //	    $('#'+id).fadeIn("fast");

	    $('#'+id).click(binds[id]);
	    i++;
	}

	return this;
    };

})(jQuery);

