To expand on user 190106's answer, this code should give you what you wanted:
function getNextDay(day, resetTime){
var days = {
sunday: 0, monday: 1, tuesday: 2,
wednesday: 3, thursday: 4, friday: 5, saturday: 6
};
var dayIndex = days[day.toLowerCase()];
if (dayIndex !== undefined) {
throw new Error('"' + day + '" is not a valid input.');
}
var returnDate = new Date();
var returnDay = returnDate.getDay();
if (dayIndex !== returnDay) {
returnDate.setDate(returnDate.getDate() + (dayIndex + (7 - returnDay)) % 7);
}
if (resetTime) {
returnDate.setHours(0);
returnDate.setMinutes(0);
returnDate.setSeconds(0);
returnDate.setMilliseconds(0);
}
return returnDate;
}
alert(getNextDay('thursday', true));