﻿function setDaysDropDown() { var m = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_txtCoverStartDate"); var f = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_txtCoverEndDate"); var o = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_ddlCoverDateDaysMonths"); var j = new Date(); var c = new Date(); var n = m.value.split(/[^0-9]/gi); var d = 0; var a = 0; var h = 0; try { if (n.length == 3) { d = parseInt(removeLeadingZeros(n[0]), 10); a = parseInt(removeLeadingZeros(n[1]), 10); h = parseInt(removeLeadingZeros(n[2]), 10); if (h.toString().length <= 2) { h = h + 2000 } j = new Date(h, a - 1, d) } } catch (k) { } try { n = f.value.split(/[^0-9]/gi) } catch (k) { } try { if (n.length == 3) { d = parseInt(removeLeadingZeros(n[0]), 10); a = parseInt(removeLeadingZeros(n[1]), 10); h = parseInt(removeLeadingZeros(n[2]), 10); if (h.toString().length <= 2) { h = h + 2000 } c = new Date(h, a - 1, d) } } catch (k) { } var g = c.getTime() - j.getTime(); var b = ((((g / 1000) / 60) / 60) / 24); var l = o.options.length; for (i = 0; i < l; i++) { if (b < o.options[i].value) { o.options[i].selected = true; break } } } function setDateOnDaysChange(b) { var n = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_txtCoverStartDate"); var f = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_txtCoverEndDate"); var h = 1; if (b == "dd") { var p = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_ddlCoverDateDaysMonths"); h = parseInt(removeLeadingZeros(p.options[p.selectedIndex].value)) } else { if (b == "tb") { var p = document.getElementById("_ctl0_ContentPlaceHolder1_coverdetails_ddlCoverDateDaysMonths"); h = parseInt(removeLeadingZeros(p.value)); if (isNaN(h) || (h == 0)) { h = 1 } } else { return } } var j = new Date(); var o = n.value.split(/[^0-9]/gi); try { if (o.length == 3) { var d = parseInt(removeLeadingZeros(o[0])); var a = parseInt(removeLeadingZeros(o[1])); var g = parseInt(removeLeadingZeros(o[2])); if (g.toString().length <= 2) { g = g + 2000 } j = new Date(g, a - 1, d) } } catch (l) { } var c = new Date(j); var k = parseInt(j.getDate()); var m = (k + h) - 1; c.setDate(m); n.value = FormatDateToString(j); f.value = FormatDateToString(c) } function removeLeadingZeros(a) { while (a.charAt(0) == "0") { a = a.substring(1, a.length) } return a } function FormatDateToString(c) { var b = c.getDate(); var e = (c.getMonth() + 1); var d = c.getFullYear(); var a = ""; if (b < 10) { a += "0" + b } else { a += b } if (e < 10) { a += "/0" + e } else { a += "/" + e } a += "/" + d; return a };