﻿var currentTipIndex = 0;
var currentQuoteIndex = 0;
var currentMoneyIndex = 0;
var tipLength = 0;
var quoteLength = 0;
var moneyLength = 0;


$(document).ready(function () {
    //jQuery.jQueryRandom = 0;
    //jQuery.extend(jQuery.expr[":"], { random: function (a, i, m, r) { if (i == 0) { jQuery.jQueryRandom = Math.floor(Math.random() * r.length); }; return i == jQuery.jQueryRandom; } });
    tipLength = $("#tipsBox-tips").find("p").length;
    quoteLength = $("#tipsBox-quotes").find("p").length;
    moneyLength = $("#tipsBox-moneys").find("p").length;
    currentTipIndex = Math.floor(Math.random() * tipLength);
    currentQuoteIndex = Math.floor(Math.random() * quoteLength);
    currentMoneyIndex = Math.floor(Math.random() * moneyLength);
    showNextTip();
});
function showNextTip() {
    $("#tipsBox-tips").show();
    $("#tipsBox-quotes").hide();
    $("#tipsBox-moneys").hide();

    $("#tipsBox-tips").find("p").hide();
    //$("#tipsBox-tips p:random").show();

    if (currentTipIndex == tipLength) {
        currentTipIndex = 1;
    } else {
        currentTipIndex = currentTipIndex + 1;
    }
    $("#tipsBox-tips p:nth-child(" + currentTipIndex + ")").show();
}
function showNextQuote() {
    $("#tipsBox-tips").hide();
    $("#tipsBox-quotes").show();
    $("#tipsBox-moneys").hide();

    $("#tipsBox-quotes").find("p").hide();
    //$("#tipsBox-quotes p:random").show();

    if (currentQuoteIndex == quoteLength) {
        currentQuoteIndex = 1;
    } else {
        currentQuoteIndex = currentQuoteIndex + 1;
    }
    $("#tipsBox-quotes p:nth-child(" + currentQuoteIndex + ")").show();
}
function showNextMoney() {
    $("#tipsBox-tips").hide();
    $("#tipsBox-quotes").hide();
    $("#tipsBox-moneys").show();

    $("#tipsBox-moneys").find("p").hide();
    //$("#tipsBox-moneys p:random").show();

    if (currentMoneyIndex == moneyLength) {
        currentMoneyIndex = 1;
    } else {
        currentMoneyIndex = currentMoneyIndex + 1;
    }
    $("#tipsBox-moneys p:nth-child(" + currentMoneyIndex + ")").show();
}
