/* =========================================================================================================
Name: Slanted text plugin
Date created: 30th July 2010
Copyright: Flag
Author(s): Tom Hare
========================================================================================================= */

(function ($) {
    $.fn.slantedText = function (options) {
        //set default options for plugin
        var defaults = {
            orientation: 'left',
            reverse: false,
            increment: 0.5
        };
        var options = $.extend(defaults, options);

        //set variable to contain increment values
        var aIndents = [];

        $(this).each(function (a) {
            //for each element, put an incremented indent value (pixels)
            aIndents.push(a * options.increment);
        });

        //start the slant at the bottom of the list?
        if (options.reverse == true) {
            aIndents.reverse();
        }
        //do the slant on the right-hand side?
        var orientation = '';
        if (options.orientation == 'right') {
            orientation = 'marginRight';
        } else {
            orientation = 'marginLeft';
        }

        //add the pixel increments from the array to each element
        $(this).each(function (b) {
            $(this).css(orientation, aIndents[b] + 'em');
        });
    };
})(jQuery);
