title: Datepicker start by default with next available month
body: <p>I have a calendar that allows booking and selecting dates, but I need to disable specific weekdays, specific months, in some cases third friday or second tuesday. So I have this functions and variables. But now I realized that the calendar always start with the actual month. </p>
  
  <p>In the cases that the actual month is disabled, the calendar starts with it. In this special case the actual month is august, but on the top of the calendar the select a month(dropdown) option displays the name of the next available month (as i added a code to make it remove the non-available months from the dropdown.</p>
  
  <p>Please take a look to this fiddle: <a href="http://jsfiddle.net/amatoro/yFtLP/10/" rel="nofollow">http://jsfiddle.net/amatoro/yFtLP/10/</a></p>
  
  <p>It shows the august calendar (starting with Thursday 1st, and ending with saturday 31), but on the top it appears "sep" - September.</p>
  
  <p>I need it to start with the next available month calendar. In this case September. But I cannot make it static with "defaultDate: (function to start with september)". As the days and months change, so if we were on december the calendar will be wrong if it starts with september ( i know this is something really silly to clarify, but just in case). </p>
  
  <pre><code>jQuery("#datepicker").datepicker({
      showOn: "button",
      dateFormat : 'yy/mm/dd',
      buttonText: "Select",
      beforeShowDay: disableSpecificWeekDaysandMonths,
      changeMonth: true,
      changeYear: true,
      minDate: 0,
      stepMonths: 0,
      maxDate: '2y'
  }).focus(function() {
      $(".ui-datepicker-prev, .ui-datepicker-next").remove();
      $.each(
          monthsToDisable,
          function( intIndex, objValue ){     
              $(".ui-datepicker-month &gt; option[value='" + objValue + "']").remove();
          }
       );
  });
  
  var daysToDisable = [0, 1, 2, 3, 4, 6]; 
  var monthsToDisable = [4,5,6,7]; 
  var specificDaysToDisable = [5]; 
  var weektoEnable = [3];
  
  function disableSpecificWeekDaysandMonths(date) {
  
      var day = date.getDay();
      if ($.inArray(day, daysToDisable) != -1) {
          return [false];
      }
  
      var month = date.getMonth();
      if ($.inArray(month, monthsToDisable) != -1) {
          return [false];
      }
  
      var date2 = date.getDate();
      if ($.inArray(day, specificDaysToEnable) != -1 &amp;&amp; date.getWeekOfMonth()!= weektoEnable) {
          return [false];
      }
      return [true]
  }
  
  Date.prototype.getWeekOfMonth = function(exact) {
      var month = this.getMonth()
          , year = this.getFullYear()
          , firstWeekday = new Date(year, month, 1).getDay()
          , lastDateOfMonth = new Date(year, month + 1, 0).getDate()
          , offsetDate = this.getDate() + firstWeekday - 1
          , index = 1 // start index at 0 or 1, your choice
          , weeksInMonth = index + Math.ceil((lastDateOfMonth + firstWeekday - 7) / 7)
          , week = index + Math.floor(offsetDate / 7)
      ;
      if (exact || week &lt; 2 + index) return week;
      return week === weeksInMonth ? index + (weeksInMonth -1 ) : week;
  };
  </code></pre>
  
  <p>I'll keep trying some options but sometimes I create really long codes that work instead of the simple and direct ones, due to my lack of knowledge.</p>
  
  <p>Thanks in advance!</p>