daysInPeriodvar = Math.max(Math.min(endPeriod, dateOut) - Math.max(startPeriod, dateIn), 0);
IE8 SUPPORTS THIS,,,...???
If not what is the cross browser method? implement manual min max methods?