/*  ContentFlowAddOn_roundabout, version 2.0 
 *  (c) 2008 - 2009 Sebastian Kutsch
 *  <http://www.jacksasylum.eu/ContentFlow/>
 *
 *  This file is distributed under the terms of the MIT license.
 *  (see http://www.jacksasylum.eu/ContentFlow/LICENSE)
 */

new ContentFlowAddOn ('roundabout', {

	ContentFlowConf: {
        circularFlow: true,
        visibleItems: -1,
        relativeItemPosition: "top center",
	
        /*
         * calculates the size of the item at its relative position x
         * returns a size object
         */
        calcSize: function (relativePosition, side) {
            var rP = relativePosition;
            var maxHeight = this.maxHeight;

            var h = maxHeight/(Math.abs(rP)+1);
            var w = h;
            return {width: w, height: h};
        },

        /*
         * calculates the position of an item within the flow element
         * returns a vector object
         */
        calcCoordinates: function (relativePosition, side) {
            var rP = relativePosition;
            var vI = this._visibleItems;
            var maxHeight = this.maxHeight;

            var f = Math.sin(Math.PI * (rP*(1+1/(rP*rP+1))) / (vI+1));
            var x =  this.Flow.center.x * (1 + vI/(vI+1)* f); 
            var y = this.maxHeight * (1 - Math.abs(rP)*0.75/(vI+1)); 

            return {x: x, y: y};
        }

    }
});
