function maketimus(timestampz)
{
    if(timestampz == 0)
    {
        return '<span style="font-style:italic;color:#CCCCCC;">N.A</span>';
    }
    else
    {
        var linktime = new Date(timestampz * 1000);
        var linkday = linktime.getDate();
        var freakingmonths=new Array();
        freakingmonths[0]="jan";
        freakingmonths[1]="feb";
        freakingmonths[2]="mar";
        freakingmonths[3]="apr";
        freakingmonths[4]="may";
        freakingmonths[5]="jun";
        freakingmonths[6]="jul";
        freakingmonths[7]="aug";
        freakingmonths[8]="sep";
        freakingmonths[9]="oct";
        freakingmonths[10]="nov";
        freakingmonths[11]="dec";
        var linkmonthnum = linktime.getMonth();
        var linkmonth = freakingmonths[linkmonthnum];
        var linkyear = linktime.getFullYear();
        var linkhour = linktime.getHours();
        var linkminute = linktime.getMinutes();
        if (linkminute < 10)
        {
            linkminute = "0" + linkminute;
        }
        var fomratedtime = linkday + linkmonth + linkyear + " " + linkhour + ":" + linkminute + "h";
        return fomratedtime;
    }
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}


function shoratt(dr,dv,wr,wv,mr,mv,yr,yv,r,v)
{
    var shocode = '<center><table><tr><td>' +
    '<acronym title="today\'s rating: ' + dr + ', ' + dv + ' votes" style="cursor:help;">' + makebar(dr,dv) + '</acronym>' +
    '<acronym title="this week\'s rating: ' + wr + ', ' + wv + ' votes" style="cursor:help;">' + makebar(wr,wv) + '</acronym>' +
    '<acronym title="this month\'s rating: ' + mr + ', ' + mv + ' votes" style="cursor:help;">' + makebar(mr,mv) + '</acronym>' +
    '<acronym title="this year\'s rating: ' + yr + ', ' + yv + ' votes" style="cursor:help;">' + makebar(yr,yv) + '</acronym>' +
    '<acronym title="all-time rating: ' + r + ', ' + v + ' votes" style="cursor:help;">' + makebar(r,v) + '</acronym>' +
    '</td></tr></table></center>';
    return shocode;
}
function makebar(r,v)
{
    var moveratingcolor = '#CCCCCC';
    if(v != 0)
    {
        var light = 30;
        var percent_good = r * 10;
        var quantity_of_green = (200 * (percent_good / 100)) - 1;
        quantity_of_green = Math.floor(quantity_of_green);
        var percent_bad = (10 - r) * 10;
        var quantity_of_red = (200 * (percent_bad / 100)) - 1;
        quantity_of_red = Math.floor(quantity_of_red);

        //safety
        quantity_of_red = quantity_of_red +light;
        if(quantity_of_red>255)
        {
            quantity_of_red=255;
        }
        quantity_of_green = quantity_of_green +light;
        if(quantity_of_green>255)
        {
            quantity_of_green=255;
        }

        moveratingcolor = ' rgb(' + quantity_of_red + ', ' + quantity_of_green + ', ' + light + ')';
    }

    var barminheight = 10;
    var barextrapxpervote = 1.5;
    var barmaxheight = 40;
    var barheight = barminheight + (v * barextrapxpervote);
    if(barheight > barmaxheight)
    {
        barheight = barmaxheight;
    }

    var thebarhtml = '<span style="display:inline-block;border:1px solid #000000;width:10px;height:' + barheight + 'px;background-color:' + moveratingcolor + ';"><!-- --></span>';
    return thebarhtml;
}
