
//window.onload = showExamGrid;

function showExamGrid(currentNo)
{
    //alert(99);
    //var ifrWindow = $("ifr_examGrid").contentWindow;  //iframe window

    var allCount = $("txtAllCount");
    allCount = allCount.value;
    if (allCount != undefined && allCount != "")
        allCount = new Number(allCount);

    if (allCount != 0)
    {
        var html = '<ul id="examGrid_ul">';
        for (var i = 1; i <= allCount; i++)
        {
            //html += '<li onclick="toggleLiBg(this)"><a href="#">33</a></li>';
            html += Format('<li onclick="toggle_li_bg(this)"><a href="{0}">{1}</a></li>', "OnLineExam.aspx?currentNo=" + i, i);
        }
        html += "</ul>";
        $("examGrid").innerHTML = html;

        if (currentNo != undefined)
        {
            setCurrent_no_bg(currentNo);
        }
    }
}

function showExamGrid_s()
{
    showExamGrid = function()
    {
        //alert(76);
        var allCount = $("txtAllCount");
        allCount = allCount.value;
        if (allCount != undefined && allCount != "")
            allCount = new Number(allCount);

        var ifrWindow = $("ifr_examGrid").contentWindow;  //iframe window

        ifrWindow.onloadHandle.call(this, allCount);
    }
    document.getElementById('ifr_examGrid').src = 'ExamGrid.htm';
    //alert(4);
}

function showExamGrid_()
{
        //$("ifr_examGrid").attachEvent('onload', onloadHandle);
//    var ifr = document.createElement('<iframe id="ifr_examGrid" frameborder="0" style="width: 100%;border: solid 1px #AAAAAA;" scrolling="no" ></iframe>');
//    ifr.onload = function() { alert(88); };
//    ifr.src = "ExamGrid.htm";
//    document.body.appendChild(ifr);
//    if (ifr.readyState == "complete")  //state: loading ,interactive,   complete
//    {
//        onloadHandle();
//    }
//    else
//    {
//        window.setTimeout(showExamGrid, 100);
    //    }

    //document.getElementById('ifr_examGrid').src = 'ExamGrid.htm';    
}

//window.onload = showExamGrid;

    function toggle_li_bg(obj)
    {
        var childNodes = document.getElementById("examGrid_ul").children;
        var length = childNodes.length;
        for (var i = 0; i < length; i++)
        {
            if (childNodes[i].nodeType != 1) continue;
            childNodes[i].style.background = "";
        }
        obj.style.background = "#aaafff";
    }

    function setCurrent_no_bg(no)
    {
        if (no == undefined) return;
        no = new Number(no);
        var childNodes = document.getElementById("examGrid_ul").children;
        var length = childNodes.length;
        for (var i = 0; i < length; i++)
        {
            if (childNodes[i].nodeType != 1) continue;
            if (i == no)
            {
                childNodes[no].style.background = "aaafff";
                break;
            }
    
            childNodes[i].style.background = "";
        }
        //obj.style.background = "#aaafff";
    }
//window.onload = showExamGrid;