jQuery(document).ready(function () {
    function updateThoughtOfTheDay() {
        jQuery.ajax({
            method: 'get',
            url : '/update-thought.php?'+rnd(),
            dataType : 'json',
            success: function (thought) { 
                var thoughtElement = jQuery('#thoughtOfTheDay p#message');
                
                thoughtElement.fadeOut('200', function () {
                    var html = '“' + thought.message + '”<br /><br />' + thought.author;
                    thoughtElement.html(html);                    
                    
                    thoughtElement.fadeIn();
                });
            }
        });
    }
    
    var updateThoughtOfTheDayTimer = setInterval(updateThoughtOfTheDay, 5000);    
});


function rnd(){ return String((new Date()).getTime()).replace(/\D/gi,'') }
