//1-ая - rgb(65, 41, 118)
//последняя - rgb(209, 16, 130)

var r = [65, 212]; 
var g = [41, 16];
var b = [118, 130]; 

var pageTitle;

function colorizeTitle(){
    if(window.noColorize !== 1){
        pageTitle = $('.colortitle').get();
        for(var x=0; x < pageTitle.length; x++){
            makeColor(pageTitle[x]);
        }
    }
}

function getColor(v, m, l)
{
    return(m[1] - Math.round((m[1]-m[0])/l * (l-v)));
}

function makeColor(t){
    var c = t.innerHTML;
    var l = c.length;
    var text = '';
    for(var i = 0; i < l ;i++){
        cs = c.substring(i, i+1);
        if(cs == " "){
            text += " ";
            i++;
            cs = c.substring(i, i+1);
        }
        if(cs == "<"){
            chk = 0;
            while(chk == 0){
                cs = c.substring(i, i+1);
                text += cs;
                i++;
                if(cs == ">") chk = 1;
                if(c.substring(i, i+1) == "<") chk = 0;
            }
            cs = c.substring(i, i+1);
        }
        if(cs == "&"){
            while(cs != ";"){
                cs = c.substring(i, i+1);
                text += cs;
                i++;
            }
            cs = c.substring(i, i+1);
        }
        cr = getColor(i, r, l);
        cg = getColor(i, g, l);
        cb = getColor(i, b, l);
        text += "<i style='color: rgb("+cr+","+cg+","+cb+")'>"+cs+"</i>";
    }
    t.innerHTML = text;
}

$(function(){ colorizeTitle(); });
