//
// convert all elements with class="convertTimestamp"
//
jQuery(function() {
    var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May',
        'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

    // LOOP OVER AND WRITE IN THE DATE FORMATTED USING
    // THE LOCAL
    jQuery('.convertTimestamp').each(function() {
        var origDateString = this.innerHTML;

        jQuery(this).tooltip({
            bodyHandler:function() {
                return origDateString;
            }
        });

        var utcDate = new Date(origDateString);

        // ADD LEADING ZEROS HOURS
        var hours = new String(utcDate.getHours());
        if (hours.length == 1) {
            hours = '0' + utcDate.getHours();
        }
        // MINUTES
        var minutes = new String(utcDate.getMinutes());
        if (minutes.length == 1) {
            minutes = '0' + utcDate.getMinutes();
        }
        // SECONDS
        var seconds = new String(utcDate.getSeconds());
        if (seconds.length == 1) {
            seconds = '0' + utcDate.getSeconds();
        }
        this.innerHTML = hours + ':' + minutes +
                         " <b>" + utcDate.getDate() + ' ' +
                         months[utcDate.getMonth()] + ' ' +
                         utcDate.getFullYear() + '</b>';
    });
});
