/* Adds Date/Timestamp to a comments field when it's selected for modifiying. */


$(function() {
   // $('#comments').attr('readonly', 'readonly');
    
    var userinitials = $('#userInitials').html();

    $('#dateButton').click(function() {
	datetime(userinitials);
	return false;
    });
});


function datetime(userinitials) {
   // $('#comments').attr('readonly','');
    $('#dateButton').button('disable');
    var currentTime = new Date();
    month = currentTime.getMonth() + 1;
    day = currentTime.getDate();
    year = currentTime.getFullYear();
    hour = currentTime.getHours();
    minute = currentTime.getMinutes();
    if(minute < 10) {
	minute = '0'+minute;
    }

    var newValue = '[' + day + '-' + month + '-' + year + ' @' + hour + ':' + minute +' '+ userinitials +']' + '\n' + $('#comments').val();

    $('#comments').val(newValue);

    return false;
}
