/* Author: bbz

*/

(function () {
    try{Typekit.load();}catch(e){}
    

    $(document).ready(function(){
        
        var gradient = function  () {
            var _colors = ["8bc53f", "931f63", "2288ee"]
            ,   _lookup = []
            ,   _count = _colors.length
            ,   _step = 100
            ,    start = 0
            ,    end = 0
            ,   _off = 0;
            
            var hex2dec = function (hex){
                return(parseInt(hex,16));
            }
            
            var dec2hex = function dec2hex(dec){
                return (dec < 16 ? "0" : "") + dec.toString(16);
                
            }
            
            var getColor = function (start, end, pc) {
                var r1 = hex2dec(start.slice(0,2))
                ,   g1 = hex2dec(start.slice(2,4))
                ,   b1 = hex2dec(start.slice(4,6))
                ,   r2 = hex2dec(end.slice(0,2))
                ,   g2 = hex2dec(end.slice(2,4))
                ,   b2=hex2dec(end.slice(4,6))
                
                ,   r = Math.floor(r1+(pc*(r2-r1)) + .5)
                ,   g = Math.floor(g1+(pc*(g2-g1)) + .5)
                ,   b = Math.floor(b1+(pc*(b2-b1)) + .5);
            
                return("#" + dec2hex(r) + dec2hex(g) + dec2hex(b));
            }
            
            var updateColors = function () {
                
                $('li').each(function(n){
                    var p = (_off + n) % (_step * _count);
                    $(this).css('color',_lookup[p]);
                })
                
                _off += 1
            }
            
            var setColors = function () {
                var i
                ,   p
                ,   l = _step * _count;
                
                for(i = 0; i < l; i+= 1) {
                    p = (i % _step);
                    if(p == 0) {
                        start = end;
                        end = (end + 1) % _count;
                    }
                    color = getColor(_colors[start], _colors[end], (p / _step))
                    _lookup.push(color);
                }
                
                setInterval(updateColors, 40);
            }()

            
        }(); 
    });
}())























