$(document).ready(function() {
    wow = new WOW({
        animateClass: 'animated',
        offset: 100,
        callback: function(box) {
            console.log("WOW: animating <" + box.tagName.toLowerCase() + ">")
        }
    });
    wow.init();


    var percent = [3, 3.5, 4];
    var minMoney = [100, 10000, 50000];
    var maxMoney = [9999, 49999, 100000];
    $("#amount").val(minMoney[0]);

    //Calculator
    function calc() {
        amount = parseFloat($("#amount").val());
        id = -1;
        var length = percent.length;
        var i = 0;
        do {
            if (minMoney[i] <= amount && amount <= maxMoney[i]) {
                id = i;
                i = i + length;
            }
            i++
        }
        while (i < length)

        if (id != -1) {
            profitDaily = amount / 100 * percent[id];
            profitDaily = profitDaily.toFixed(2);
            profitHourly = amount / 100 * percent[id];
            profitHourly = profitHourly.toFixed(2);
            profitWeekly = profitDaily * 1;
            profitWeekly = profitWeekly.toFixed(2);
            profitMonthly = profitDaily * 1;
            profitMonthly = profitMonthly.toFixed(2);


            if (amount < minMoney[id] || isNaN(amount) == true) {
                $("#profitHourly").text("Error!");
                $("#profitDaily").text("Error!");
                $("#profitWeekly").text("Error!");
                $("#profitMonthly").text("Error!");
            } else {
                $("#profitHourly").text("$" + profitHourly);
                $("#profitDaily").text("$" + profitDaily);
                $("#profitWeekly").text("$" + profitDaily);
                $("#profitMonthly").text("$" + profitMonthly);
            }
        } else {
            $("#profitHourly").text("Error!");
            $("#profitDaily").text("Error!");
            $("#profitWeekly").text("Error!");
            $("#profitMonthly").text("Error!");
        }
    }
    if ($("#amount").length) {
        calc();
    }
    $("#amount").keyup(function() {
        calc();
    });


});