﻿function selectNum(obj)
{
    if (obj.className == "CommonLotteryRedBallStyle")
    {
        obj.className = "CommonLotteryGrayBallStyle";
    }
    else
    {
        obj.className = "CommonLotteryRedBallStyle";
    }

    ReflashMoney();
}

function GetVoteString()
{
    var strVoteLine = "";

    for (var i = 7; i >= 1; i--)
    {
        var count = 0;
        for (var j = 0; j < 10; j++)
        {
            var objchoose = document.getElementById("choose" + i + "_" + j);

            if (objchoose.className == "CommonLotteryRedBallStyle")
            {
                strVoteLine += j + ",";
                count++;
            }
        }

        if (count > 0)
        {
            strVoteLine = strVoteLine.substring(0, strVoteLine.length - 1);
            count = 0;
        }

        strVoteLine += "|";
    }

    return strVoteLine.substring(0, strVoteLine.length - 1);
}

function GetVoteCount(strVoteLine)
{
    var arr = strVoteLine.split("|");

    var ball7 = arr[0].split(",");
    var ball6 = arr[1].split(",");
    var ball5 = arr[2].split(",");
    var ball4 = arr[3].split(",");
    var ball3 = arr[4].split(",");
    var ball2 = arr[5].split(",");
    var ball1 = arr[6].split(",");

    var n = 0;
    if (ball7 != "" && ball6 != "" && ball5 != "" && ball4 != "" && ball3 != "" && ball2 != "" && ball1 != "")
    {
        n = ball7.length * ball6.length * ball5.length * ball4.length * ball3.length * ball2.length * ball1.length
    }

    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");
    //var multiple = document.getElementById("InputMultiple").value;

    if (ValidateVote())
    {
        var count = GetVoteCount(GetVoteString());

        votecount.innerText = count;
        totalmoney.innerText = count * 2;
    }
    else
    {
        votecount.innerText = 0;
        totalmoney.innerText = 0;
    }
}

function CleanVote()
{
    for (var i = 7; i >= 1; i--)
    {
        for (var j = 0; j < 10; j++)
        {
            var objchoose = document.getElementById("choose" + i + "_" + j);

            objchoose.className = "CommonLotteryGrayBallStyle";
        }
    }

    CleanMoney();
}

function CleanMoney()
{
    var votecount = document.getElementById("SpanVoteCount");
    var totalmoney = document.getElementById("SpanTotalMoney");
    var multiple = document.getElementById("InputMultiple");


    votecount.innerText = 0;
    totalmoney.innerText = 0;
    multiple.value = 1;
}

function randomBall()
{
    var a = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
    var b = "", c;
    for (i = 1; i <= 7; i++)
    {
        c = Math.floor(Math.random() * a.length);
        b = b + a[c] + "|";
    }
    return b.substring(0, b.length - 1);
}

function randomProjects(i)
{
    for (n = 0; n < i; n++)
    {
        AddList(randomBall(), 2);
    }
}



