function vAge(birthMM,birthDD,birthYYYY,targetAge) { if (!testAge(birthMM,birthDD,birthYYYY,13)) { document.cookie = "underage=true; path=/; domain=.yesnetwork.com"; document.location.replace("/ineligible.jsp"); } return testAge(birthMM,birthDD,birthYYYY,targetAge); } function testAge(birthMM,birthDD,birthYYYY,targetAge) { var thisMM=12, thisDD=15, thisYYYY=(2017-targetAge); if (birthYYYY > thisYYYY) { return false; } else if (birthYYYY == thisYYYY) { if (birthMM > thisMM) { return false; } else if (thisMM == birthMM) { if (birthDD > thisDD) return false; } } return true; }