var Wick = Wick || {};
Wick.PLP = (function () {
    function bindEvents() {
        $('.rating-overlay').each(function () {

            let rating = $(this).attr("data-rating"),
                stars = $(this).children('.star-overlay');

            stars.each(function () {
                if(rating >= 1) {
                    rating--;
                } else if(rating < 1) {
                    rating = Math.asin( 2 * rating - 1 ) / Math.PI + 0.5;
                    $(this).css('width', rating + 'rem');
                    rating = 0;
                } else if (rating <= 0 ) {
                    $(this).css('width', '0rem');
                }

            });
        });
    }

    function init(){
        bindEvents();
    }

    init();
})();
