How to write blinking in more elegant way
<p>The aim: to write a js (using jquery) that will perform 2 blinking of the row.</p>

<p>What I currently have is</p>

<pre><code>var $second_row = $('table tr:eq(1)'),
    target_color = 'PaleGreen',
    original_color = $second_row.css('background-color');

$second_row.css('background-color', target_color);
scheduleOriginalColor();

function scheduleTargetColor() {
    setTimeout(function() {
        $second_row.css('background-color', target_color);
        scheduleOriginalColor(true);
    }, 500);
}

function scheduleOriginalColor(stop) {
    setTimeout(function() {
        $second_row.css('background-color', original_color);

        if (!stop) {
            scheduleTargetColor();
        }
    }, 500);
}
​
</code></pre>

<p><a href="http://jsfiddle.net/zerkms/ecfMU/1/" rel="nofollow">http://jsfiddle.net/zerkms/ecfMU/1/</a></p>

<p>But it looks ugly and I'm sure there is a better way of writing the same.</p>

<p>Any proposals?</p>

<p><strong>UPD</strong>: there is my second attempt, a bit more clear: <a href="http://jsfiddle.net/zerkms/ecfMU/2/" rel="nofollow">http://jsfiddle.net/zerkms/ecfMU/2/</a></p>

<pre><code>var $second_row = $('table tr:eq(1)'),
    target_color = 'PaleGreen',
    original_color = $second_row.css('background-color');

setRowColor(target_color, 500);
setRowColor(original_color, 1000);
setRowColor(target_color, 1500);
setRowColor(original_color, 2000);

function setRowColor(color, timing) {
    setTimeout(function() {
        $second_row.css('background-color', color);
    }, timing);
}
​
</code></pre>
