var xx = 1;
var xx2 = 0;

function addxx() {
    xx = 1;
}
function reducexx() {
    xx = 0;
    
}
function addxx2() {
    xx2 = 1;
}
function reducexx2() {
    xx2 = 0; 
    setTimeout("addxx()",500)

}




var _timer_1;
var haveTimer = false;
function start() {
    if (haveTimer == false) { _timer_1 = window.setInterval("webexam_Timer()", 1000); haveTimer = true; }


}
function setNotLefe() {
    $("select").bind("mousemove", addxx2).bind("mouseover", addxx2).bind("mouseout", reducexx2); 
    document.onmouseover = addxx;
    document.onmouseout = reducexx;
    start()
}
function delTimer() {
    if (haveTimer) { window.clearInterval(_timer_1); haveTimer = false; var msg = document.getElementById("timerDiv"); if (msg != null) { document.body.removeChild(msg) } }


}

var _downcountConst = 11;
var _downcount = _downcountConst;
function webexam_Timer() {

    //var msg = document.getElementById("timerDiv");
    var windowHeight = $(window).height() + 300;
    var windowWidth = $(window).width()+50;
    var screenHeight = window.screen.height;
    var screenWidth = window.screen.width;
    //window.status = windowHeight + "'" + screenHeight + "'" + windowWidth + "'" + screenWidth
    if (((xx == 0) && (xx2 == 0)) || windowHeight-20 < screenHeight || windowWidth-20 < screenWidth) {
        
        //if (msg == null) {
            //msg = document.createElement("div"); msg.id = "timerDiv";
            //var msgH = 130; var msgW = 130;

           // var x = Math.round(Math.random() * ($(window).height()  - msgH - 0 + 1) + 0);
           // var y = Math.round(Math.random() * ($(window).width() - msgW - 0 + 1) + 0);

            //if (x < 0) x = 0; if (y < 0) y = 0;
           // msg.style.top = x
            //msg.style.left = y
            //msg.style.zIndex = 999999
            //msg.style.position = "fixed"
       // }
        if (_downcount == _downcountConst)
            document.getElementById("bgMusic").src = "/paperStyle/3.1/standard/exam/warning.mp3";
        _downcount--;
        __message("");
        var message = "<p style='color:red;'>";
        if ((xx == 0) && (xx2 == 0))
            message += "☆请不要离开考卷页面 ";
        if (windowHeight - 20 < screenHeight || windowWidth - 20 < screenWidth)
            message += "☆请保持浏览器界面最大化";
        message += "</p><p>正在准备提交试卷</p><div id='progressbar' style='height:5px;'></div>";
        
        $("p[class='message']").html(message);
        
        //document.body.appendChild(msg)
        
        $("#progressbar").progressbar({
            value: _downcount*10
        });
        if (_downcount <= 0) { window.clearInterval(_timer_1); submitKey(); }
    }

    else {
       document.getElementById("bgMusic").src =""; _downcount = _downcountConst;$.modal.close(); //if (msg != null) document.body.removeChild(msg); 
    }

}  