var ajaxConn = new XHConn();
var new_mails = new Number();
var checkMail_ajaxDone = function (oXML) {
    var mail = new Array();

    if (new_mails < 1) {
        mail = oXML.responseText.split(";");
        mail[0] = Number(mail[0]);
        if (mail[0] > 0) {
            var confirmed = confirm("You have " + mail[0] + " new "
                                    + ((mail[0] == 1) ? "mail from " : "mails, last from ")
                                    + mail[1] + "\\nIf you want to read it, click OK");
            if (confirmed == true) {
                window.location.assign("/id/24");
            }
        }
        else {
            timer = setTimeout("check_mail()", 3 * 60 * 1000);
        }
        new_mails = mail[0];
    }
}

function check_mail() {
    ajaxConn.connect("/ajax/check_new_mail.php", "GET", "", checkMail_ajaxDone);
}

timer = setTimeout("check_mail()", 3 * 60 * 1000);