(function () {
    "use strict";

    function generatePrimes() {
        var min = (document.getElementById("Min")).value;
        var max = (document.getElementById("Max")).value;
        var sieve = new PrimeSieves.TurnerSieve();
        var p = new PrimeSieves.Prime(0);

        do
        {
            p = sieve.nextPrime();
        }
        while (p.value < min);

        var primesString = "";
        var first = true;
        while (p.value < max) {
            if (first == true) {
                primesString += p.value;
                first = false;
            }
            else {
                primesString += ", ";
                primesString += p.value;
            }
            p = sieve.nextPrime();
        }
        document.getElementById("PrimesList").innerHTML = primesString;
    }

    WinJS.Namespace.define("Primes", {
        generatePrimes: generatePrimes
    });
})();