jQuery UI Datepicker Testing

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.8.23/jquery-ui.min.js"></script>
<p>Click in first date field and then in 2nd date field.</p>
<p>
    Dates - 
    1st: <input type="text" id="date1" /> 
    2nd: <input type="text" id="date2" />
</p>
<br /><br />
<p>Fixed.</p>
<p>
    Dates -
    1st: <input type="text" id="date3" />
    2nd: <input type="text" id="date4" />
</p>

JavaScript

$("#date1").datepicker({
    onSelect: function(date)
    {
        $('#date2').datepicker("show");
    }
});
$("#date2").datepicker();

$("#date3").datepicker({
    onSelect: function(date)
    {
        setTimeout(function()
        {
            $('#date4').datepicker("show");
        }, 0);                    
    }
});
$("#date4").datepicker();