setDate JQuery doesn't work in IE
I have a JQuery function which works in FireFox and but stops in IE. The whole function is below but the error I am getting is on this line: I am using jquery-1.10.2
Unhandled exception at line 272, column in eval code
0x800a138f - JavaScript runtime error: Unable to get property 'setDate' of undefined or null reference
depart.setDate(depart.getDate() + nights);
The whole function
-----------------------------
$('#dtCalendarFinalSubmit2').focusout(function () {
var nights = parseInt($('#TextBoxFinalSubmitDayIncrement').val());
var depart = $.datepicker.parseDate('mm/dd/yy', $('#dtCalendarFinalSubmit2').val());
var incType = $("#DropDownListFinalSubmitDayType option:selected").text();
if (incType == 'Business')
nights = AddBusinessDays(nights);
depart.setDate(depart.getDate() + nights);
$('#dtCalendarFinalReview2').val($.datepicker.formatDate('mm/dd/yy', depart));
});