var limit=49; var count=6; function formHandler(form) { var page = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = page; } function randomNumber() { do { today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin(num) * 1000000)) % (limit - 1); } while (num == 0); return num; } function setRange() { var val = document.numbers.lottery_name.options [document.numbers.lottery_name.selectedIndex].value; switch (val) { case "na_lotto_649": case "at_649": case "bc_49": case "on_49": case "qc_49": case "we_649": limit = 49; count = 6; break; case "on_lottario": limit = 45; count = 6; break; case "na_super_7": limit = 47; count = 7; break; case "na_lotto_max": limit = 49; count = 7; } if (count == 7) document.numbers.search_7.style.visibility = 'visible'; else document.numbers.search_7.style.visibility = 'hidden'; } function populateNumbers() { setRange(); array = new Array(); for (i = 1; i <= count; i++) { array[i] = randomNumber(); for (j = 1; j < i; j++) if (array[i] == array[j]) i--; } last = 0; for (i = 1; i <= count; i++) { lowest = 100; for (j = 1; j <= count; j++) if (array[j] > last && array[j] < lowest) lowest = array[j]; last = lowest; eval('document.numbers.search_' + i + '.value = lowest;'); } for (i = 7; i > count; i--) eval('document.numbers.search_' + i + '.value = "";'); } function isDigit(c) { return ((c >= "0") && (c <= "9")); } function checkDuplicate(cmp) { found = 0; for (j = 1; j <= count; j++) { val = eval('document.numbers.search_' + j + '.value'); if (val == cmp) found++; } return (found > 1); } function checkNumbers() { for (i = 1; i <= count; i++) { value = eval('document.numbers.search_' + i + '.value'); if (value == '') { alert(count + " numbers are required for the lottery you've selected."); return (false); } if (isDigit(value) == false) { alert('"' + value + '"' + ' is not a number, please select a number between 1 and ' + limit + '.'); return (false); } if (value > limit) { alert('The number "' + value + '" is too big, the highest possible number is ' + limit + '.'); return (false); } if (value == '0') { alert('The number "0" is not a valid number, please select a number between 1 and ' + limit + '.'); return (false); } if (checkDuplicate(value)) { alert("You've entered the number \"" + value + '" more than once.'); return (false); } } if (count != 7 && document.numbers.search_7.value > 0) { alert("Only " + count + " are required for the lottery you've selected."); return (false); } } function checkEmail(thisForm) { if (thisForm.email.value.length == 0) { alert("You did not fill out your email address"); return false; } return true; } function checkName(thisForm) { if (thisForm.name.value.length == 0) { alert("You did not fill out your name"); return false; } return true; } function escapeFrames() { if (window != window.top) top.location.href = location.href; if (parent.frames[1]) parent.location.href = self.location.href; }