function discountsup(dz,fullprices,ss) { holsupdays_zz = 0; holsup_zz = 0; holsup_zztemp = 0; hold_zz = 0; ss = ss/1000; overlap_zz(ss,dz,'1521777600','1522641600') if (hold_zz > 0) {holsup_zztemp = Math.round(((50/100)*hold_zz*fullprices)/dz) holsupdays_zz = holsupdays_zz + hold_zz hold_zz = 0 holsup_zz = holsup_zztemp + holsup_zz} overlap_zz(ss,dz,'1514091600','1515301200') if (hold_zz > 0) {holsup_zztemp = Math.round(((50/100)*hold_zz*fullprices)/dz) holsupdays_zz = holsupdays_zz + hold_zz hold_zz = 0 holsup_zz = holsup_zztemp + holsup_zz} return holsup_zz } function overlap_zz(ss,dz,hsdate,hedate) { durms = dz*86400; se = ss + durms; hs = hsdate; he = hedate; //holiday end is midnight of last holiday day, i.e. beginning of next day; so, add a day //he = he + 86400; holms = 0; if (ss < hs && se > hs && se < he ) {holms = se - hs ;} if (ss > hs && se > he && ss < he ) {holms = he - ss ;} if (ss >= hs && se <= he ) {holms = durms ;} if (ss <= hs && se >= he ) {holms = he - hs ;} //hold is holidaydays hold_zz = 0; hold_zz = Math.round(holms/86400); return hold_zz }