﻿
/* 时时乐开奖分布图 */
show_kjzs = function(n) {
    var html = "<div style=\"width:980px;margin:0 auto; \"><table class=\"wrap_body\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\"><tr><td>";
    html += "<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> \
                   <tr><td align=\"center\" class=\"Title_lottery\">时时乐开奖分布图</td></tr> \
                   <tr><td align=\"center\"><a href=\"?id=30\">最近30期</a> &nbsp; <a href=\"?id=50\">最近50期</a> &nbsp; <a href=\"?id=100\">最近100期</a></td></tr> \
                   <tr> \
                     <td align=\"center\" class=\"choose\"> 标注形式选择：\
                       <input type=\"checkbox\" name=\"checkbox\" id=\"c_d\" onclick=\"map.select_checkbox('gYL',this);\" /> <label for=\"c_d\">不带遗漏数据</label> \
                       <input type=\"checkbox\" name=\"checkbox\" id=\"c_x\" onclick=\"map.select_checkbox('gLine',this);\" checked=\"checked\" /> <label for=\"c_x\">带折线</label> \
                       <input type=\"checkbox\" name=\"checkbox\" id=\"c_o\" onclick=\"map.select_checkbox('gLayer',this);\" /> <label for=\"c_o\">遗漏分层</label> \
                       <input type=\"checkbox\" name=\"checkbox\" id=\"c_l\" onclick=\"map.select_checkbox('spaceLine',this);\" checked=\"checked\" /> <label for=\"c_l\">辅助线</label> \
                     </td> \
                   </tr> \
                 </table> \
                 <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" class=\"tab_bg\"> \
                   <tbody id=\"head\"> \
                     <tr> \
                       <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"60\" height=\"1\" /><br /><B>期号</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"60\" height=\"1\" /><br /><B>开奖号码</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
					   <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"40\" height=\"1\" /><br /><B>时间</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td colspan=\"10\"><FONT COLOR=\"#BD5151\"><B>百位</B></FONT></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td colspan=\"10\"><FONT COLOR=\"#1C74AA\"><B>十位</B></FONT></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td colspan=\"10\"><FONT COLOR=\"#BD5151\"><B>个位</B></FONT></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"25\" height=\"1\" /><br /><B>和<br />数<br />值</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"25\" height=\"1\" /><br /><B>奇<br />偶<br />比</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td rowspan=\"2\" class=\"bLine\"><img src=\"images/space.gif\" width=\"25\" height=\"1\" /><br /><B>大<br />小<br />比</B></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		               <td colspan=\"10\"><FONT COLOR=\"#1C74AA\"><B>0-9分布</B></FONT></td> \
		               <td rowspan=\"2\" class=\"padd_1\"><img src=\"images/space.gif\" width=\"1\" height=\"1\" /></td> \
		             </tr> \
		             <tr> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />0</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />1</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />2</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />3</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />4</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />5</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />6</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />7</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />8</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />9</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />0</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />1</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />2</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />3</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />4</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />5</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />6</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />7</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />8</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />9</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />0</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />1</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />2</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />3</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />4</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />5</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />6</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />7</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />8</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />9</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />0</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />1</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />2</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />3</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />4</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />5</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />6</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />7</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />8</td> \
		               <td class=\"line_top bLine\"><img src=\"images/space.gif\" width=\"18\" height=\"1\" /><br />9</td> \
		             </tr> \
		           </tbody>";

    // 参数说明：号码(","：分割符；"-"：空列；"->"：直接输出)$背景样式$字体样式$球样式$是否连线,连线颜色,连线尺寸
    var colspan = ["0,1,2,3,4,5,6,7,8,9$cbg1$yl01$chartBall01$1,#BD5151,2", "0,1,2,3,4,5,6,7,8,9$cbg2$yl02$chartBall02$1,#1C74AA,2", "0,1,2,3,4,5,6,7,8,9$cbg1$yl01$chartBall01$1,#BD5151,2", "->$cbg3$yl03", "->$cbg3$yl03", "->$cbg3$yl03", "0,1,2,3,4,5,6,7,8,9$cbg2$yl02$chartBall02"];

    // 初始化图表显示类
    map = new tb.display(nameXML, colspan, true, true, "0_0_1");

    html += map.show_map(n) + "</table></td></tr>";
    html += "<tr><td colspan=\"57\" class=\"boot_css\"> \
                <div style=\"width:300px;float:left;\"> \
                 参数说明： <br/> \
                 [遗漏分层] 将当期遗漏标注出来 <br/> \
                 [辅助线] 每五期使用分隔线，使横向导航更加清晰 \
                </div> \
             </td></tr>";
    html += "</table></div>";

    document.write(html);

    map.operate();
}

show_kjzs(nExpect(30, 20, 100));

/************************ 以下为图表选号 ************************/

/* 预选区选号事件 */
select_singleball = function(css, obj) {  
    if ((tb.ball).test(obj.className)) {
        obj.className = obj.className.replace(" " + css, "");
    } else {
        obj.className += " " + css;
    }
}

/* 处理行选号 */
function docompose_code(temp) {
    var s = [];
    var code = temp.split("|");
    if (code[0] == "" && code[1] == "" && code[2] == "") {
        s.push("未选择");
        s.push("");
        s.push("");
        s.push("");
        s.push("<a href=\"javascript:void(0);\" onclick=\"change_code(this);\">添加</a>");
        s.push("");
    } else {
        var t = [], select;
        for (var i = 0; i < 3; i++) {
            code[i] = code[i].replace(/,/g, "");
            t.push(code[i] == "" ? "-" : code[i]);
        }
        select = t.join(",");

        if (code[0] == "" || code[1] == "" || code[2] == "") {
            s.push("号码不足");
            s.push(select);
            s.push("");          
        }
        else {
            var choice = select_choice();
            var zhu = getnzhu(select, choice);
            if (zhu > 0) {
                s.push("√");
                s.push(select);
                s.push(zhu);
            } else {
                s.push("玩法不符");
                s.push(select);
                s.push("");
            }
        }
        s.push("常规投注");
        s.push("<a href=\"javascript:void(0);\" onclick=\"change_code(this);\">修改</a>");
        s.push("<img src=\"images/close.gif\" style=\" cursor:pointer;\" onclick=\"delete_code(this);\" />");
    }
    return s;
}

/* 计算注数 */
function getnzhu(code, choice) {
    var a, b, c, d1, d2, d3;
    var zhu = 0, string = "", dump = "";
    var temp = code.split(",");
    switch (choice) {
        case "直选":
            zhu = 1;
            for (a = 0; a < temp.length; a++) {
                zhu *= temp[a].length;
            }
            break;
        case "组选":
            for (a = 0; a < temp[0].length; a++) {
                d1 = temp[0].substr(a, 1);
                for (b = 0; b < temp[1].length; b++) {
                    d2 = temp[1].substr(b, 1);
                    for (c = 0; c < temp[2].length; c++) {
                        d3 = temp[2].substr(c, 1);
                        if (!(d1 == d2 && d2 == d3)) {
                            string = paixu(new Array(d1, d2, d3), "asc").join(",");
                            if (dump.indexOf(string) == -1) {
                                dump += string + ".";
                                zhu++;
                            }
                        }
                    };
                };
            }
            break;
        case "组三":
            for (a = 0; a < temp[0].length; a++) {
                d1 = temp[0].substr(a, 1);
                for (b = 0; b < temp[1].length; b++) {
                    d2 = temp[1].substr(b, 1);
                    for (c = 0; c < temp[2].length; c++) {
                        d3 = temp[2].substr(c, 1);
                        if (!(d1 == d2 && d2 == d3) && (d1 == d2 || d2 == d3 || d3 == d1)) {
                            string = paixu(new Array(d1, d2, d3), "asc").join(",");
                            if (dump.indexOf(string) == -1) {
                                dump += string + ".";
                                zhu++;
                            }
                        }
                    };
                };
            }
            break;
        case "组六":
            for (a = 0; a < temp[0].length; a++) {
                d1 = temp[0].substr(a, 1);
                for (b = 0; b < temp[1].length; b++) {
                    d2 = temp[1].substr(b, 1);
                    for (c = 0; c < temp[2].length; c++) {
                        d3 = temp[2].substr(c, 1);
                        if (d1 != d2 && d2 != d3 && d3 != d1) {
                            string = paixu(new Array(d1, d2, d3), "asc").join(",");
                            if (dump.indexOf(string) == -1) {
                                dump += string + ".";
                                zhu++;
                            }
                        }
                    };
                };
            }
            break;
    }
    return zhu;
}

show_layerHTML();
