﻿function selectRedNum(obj)
{
    if (obj.className == "CommonLotteryRedBallStyle")
    {
        obj.className = "CommonLotteryGrayBallStyle";
    }
    else
    {
        obj.className = "CommonLotteryRedBallStyle";
    }

    ReflashMoney();
}

function GetVoteString()
{
    var strVoteLine = "";
    for (var i = 1; i <= 22; i++)
    {
        var objchooseRed = document.getElementById("chooseRed" + i);

        if (objchooseRed.className == "CommonLotteryRedBallStyle")
        {
            strVoteLine += MakeDoubleNumber(i) + " ";
        }
    }

    strVoteLine = strVoteLine.substring(0, strVoteLine.length - 1);

    return strVoteLine;
}

function GetVoteCount(strVoteLine)
{
    var arr = strVoteLine.split(" ");

    var n = 0;

    if (arr.length >= 5 && strVoteLine != "")
    {
        n = C(arr.length, 5);
    }
    
    return n;
}

function ValidateVote()
{
    if (GetVoteCount(GetVoteString()) == 0)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function ValidateVoteString(strVoteString)
{
    if (GetVoteCount(strVoteString) == 0)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function ReflashMoney()
{
    var votecount = document.getElementById("SpanVoteCount");
    var totalmoney = document.getElementById("SpanTotalMoney");

    if (ValidateVote())
    {
        var count = GetVoteCount(GetVoteString());

        votecount.innerText = count;
        totalmoney.innerText = count * 2;
    }
    else
    {
        votecount.innerText = 0;
        totalmoney.innerText = 0;
    }
}

function CleanMoney()
{
    var votecount = document.getElementById("SpanVoteCount");
    var totalmoney = document.getElementById("SpanTotalMoney");

    votecount.innerText = 0;
    totalmoney.innerText = 0;
}

function CleanVote()
{
    for (var i = 1; i <= 22; i++)
    {
        var objchooseRed = document.getElementById("chooseRed" + i);
        objchooseRed.className = "CommonLotteryGrayBallStyle";
    }

    CleanMoney();
}



function randomBall()
{
    var a = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22");
    var b = "", c;
    for (i = 1; i <= 5; i++)
    {
        c = Math.floor(Math.random() * a.length);
        b = b + a[c] + " ";
        a = a.del(c);
    }
    return b.substring(0, b.length - 1);
}

function randomProjects(i)
{
    for (n = 0; n < i; n++)
    {
        var strVoteLine = randomBall();
        AddList(strVoteLine, 2);
    }
}





