datepicker opens after ajax call on second click? how to open it on first click?
===

before ajax call I write the code for date picker is:

    <script type="text/javascript">
        $(function() {
            $("#birthdate").focus(function() {
                $(this).datepicker().datepicker( "show" )
            });
        });
        $(function() {
            $("#joindate").focus(function() {
                $(this).datepicker().datepicker( "show" )
            });
        });
        </script>           


 this function called after onfocus event:         


  

    <tr>
                  <td align="left">
                    <input type="text" id="birthdate"  name="birthdate"  onfocus="$('#birthdate').datepicker({changeMonth: true,changeYear: true,dateFormat: 'dd/mm/yy',defaultDate: '-20y -1m -247d',yearRange: '-50:+0'});"   tabindex="14"  style="width:300px; "   value="<? if($get_emp!='0')echo $employee_birth; ?>" /><span style="color:#F00;">*</span></td>                                       
                                                      
        <td>
            <input type="text" name="joindate" id="joindate" onfocus="$('#joindate').datepicker({changeMonth: true,changeYear: true,dateFormat: 'dd/mm/yy',defaultDate: '-3y -1m -247d',yearRange: '-50:+0'});"  tabindex="15" style="width:300px; " value="<? if($get_emp!='0')echo $employee_join; ?>"/><span style="color:#F00;">*</span>
            </td>
         </tr>

after ajax call I call the same code but it not opens on first click , however it opens on second click?
please help me to sort out this problem..........................                
