Date.prototype.TN_ToTimeString = function() {
    var hoursRaw = this.getUTCHours();
    var hoursDisplay = '';
    var amOrPm = 'AM';
    if (hoursRaw > 11) {
        hoursDisplay = (hoursRaw == 12) ? '12' : '' + hoursRaw - 12;
        amOrPm = 'PM';
    }
    else {
        hoursDisplay = (hoursRaw == 0) ? '12' : '' + hoursRaw;
    }

    var minsRaw = this.getUTCMinutes();
    var minutesDisplay = (minsRaw < 10) ? '0' + minsRaw : '' + minsRaw;


    if(hoursDisplay == 3 && minutesDisplay == 30 && amOrPm == 'AM')
    {
        return 'TBA';
    }
    else
    {
        return hoursDisplay + ':' + minutesDisplay + ' ' + amOrPm;
    }
};

Date.prototype.TN_ToDateString = function() {
    var monthRaw = this.getUTCMonth() + 1;
    var retStr = (monthRaw < 10) ? '0' + monthRaw : '' + monthRaw;
    var dateRaw = this.getUTCDate();
    retStr += '/';
    retStr += (dateRaw < 10) ? '0' + dateRaw : '' + dateRaw;

    retStr += '/' + this.getUTCFullYear();

    return retStr;
};

Date.prototype.TN_AddDays = function(someNum) {
    return new Date( this.getTime() + (someNum * 24 * 60 * 60 * 1000) );    
};

Date.prototype.TN_ToDayOfWeekString = function() {    
    return ConvertIntIndexToDayStr(this.getUTCDay());
};

function ConvertIntIndexToDayStr(index)
{
    switch(index)
    {
        case 0:
            return 'Sunday';
        case 1:
            return 'Monday';
        case 2:
            return 'Tuesday';
        case 3:
            return 'Wednesday';
        case 4:
            return 'Thursday';
        case 5:
            return 'Friday';
        default:
            return 'Saturday';
    }
}





Array.prototype.TN_Contains = function(obj)
{
    var i = this.length;
    while(i--)
    {
        if(this[i] == obj)
        {
            return true;
        }
    }
    return false;
}

Array.prototype.TN_ContainsDateTime = function(date)
{
    var i = this.length;
    while(i--)
    {
        if(this[i].getTime() == date.getTime())
        {
            return true;
        }
    }
    return false;
}

Array.prototype.TN_Remove = function(obj)
{
    var i = this.length;
    while(i--)
    {
        if(this[i] == obj)
        {
            this.splice(i, 1);
        }
    }
}



function ConvertIDToParentCatName(inID)
{
    switch(inID)
    {
        case 1:
            return 'Sports';
        case 2:
            return 'Concerts';
        case 3:
            return 'Theater';
        default:
            return 'Other';
    }
}

// Initializes a new instance of the StringBuilder class

// and appends the given value if supplied

function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}

// Appends the given value to the end of this instance.

StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}

// Clears the string buffer

StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}

// Converts this instance to a String.

StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

