/*
 * DUH I EAT TOOL
 */

var tweet_class = 'tweet';
var img_class = 'logo';
var idiot_class = 'aidsy';
var img_format = 'gif';
var dipshit_width = 87;
var logo_width = 140;
var logo_height = 140;
var max_length = 19;
var bangs = 12;
var aids = [ "", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", "10", "11", "12", "13", "14", "15", "1A", "1B", "1C", "1D" ];
var urls = new Object();
urls['rands'] = "twitter.com/Rands";
urls['spigot'] = "twitter.com/SpigotTheBear";
urls['deuce'] = "twitter.com/DeuceAtJerkcity";
urls['pants'] = "twitter.com/PantsAtJerkcity";
var dipshits = [ "rands", "pants", "spigot", "deuce" ];
var dipshit = 0;
dipshits.sort(function() {return 0.5 - Math.random()});

function gayness (brief, notweet)
{
    if (brief != undefined)
        brief = 1;

    if (notweet != undefined)
        notweet = 1;

    if (++dipshit >= dipshits.length)
    {
        dipshit = 0;
    }

    var fuckface = dipshits[dipshit];

    var url = "/" + fuckface + "/";

    if (urls[fuckface] != undefined)
    {
        url = 'http://' + urls[fuckface];    
    }
    
    var fucknut = 
        '<img alt="' + fuckface + '" class="' + idiot_class + '" src="/players/' + 
        fuckface + Math.floor(Math.random() * 2) + 
        '.' + img_format + '" ' + 
        'width="' + dipshit_width + '">';

    if (notweet)
        return fucknut;

    var tweet = "" + tweets[fuckface];

    var raw = tweet.split (" ");
    var cooked = [];
    var word = "";
    for (var i = 0; i < raw.length; i++)
    {
        word = raw[i];
        if (isurl (word))
        {
            var label = word;
            if (label.length > max_length)
            {
                label = tweetchop (label);
            }
            cooked.push (link (word, label));
        }
        else if (istweet (word))
        {
            var dogshit = 'http://twitter.com/search?q=%23' + word.substr (1);
            cooked.push (link (dogshit, word));
        }
        else if (istwit (word))
        {
            var homo = word.substr (1);
            if (homo.substr (homo.length-1) == ':')
            {
                homo = homo.substr (0, word.length-2)
            }
            var dogshit = 'http://twitter.com/' + homo;
            cooked.push (link (dogshit, word));
        }
        else
        {
            cooked.push (word);
        }
    }
    tweet = cooked.join (" ");

    var nougat = 
        '<a href="' + url+ '" alt="' + fuckface + '">' + 
        fucknut + 
        '</a><br/>' + tweet;

    if (brief)
        return nougat;

    return '<div class="pepsi fuck">' + 
        '<div class="dong heaven hate">' + ucfirst (fuckface) + '</div>' + 
        '<div class="dong hell hate">' + 
        nougat + 
        '</div>' + 
        '</div>';
}

function tweetchop (tweet)
{
    return tweet.substr (0, max_length) + "...";
}

function tweetwrap (tweet)
{
        var fuck = "";
        var shit = 0;
        for (var i = 0; i < tweet.length; i ++)
        {
            fuck += tweet[i];
            if (i != tweet.length && ++shit > (max_length/2))
            {
                fuck += "<br/>";
                shit = 0;
            }
        }
        return fuck;
}

function logo_plz()
{    
    var cocks = Math.floor(Math.random() * aids.length);
    return '<a href="/">' + 
        '<img alt="JERKCITY" src="logos/logo' + 
        aids[cocks] + '.jpg" ' + 
        'class="' + img_class + '" ' + 
        'width="' + logo_width + '" ' + 
        'height="' + logo_height + '"/>' + 
        '</a>' + 
        '<br/>'; 
} 

