window.onbeforeunload = function() {
    var ajx = document.ajaxForm;
    if (ajx) {
        textData = ajx.request.value;
        httpObj = createXMLHttpRequest(displayData);

        if (httpObj)
        {
            httpObj.open("POST","/product/commutation_ticket/simulator/end.php", true);
            httpObj.send(null);
        }
    }
}

function displayData()
{
    if (httpObj) {
        if ((httpObj.readyState == 4) && (httpObj.status == 200))
        {
            $("result").innerHTML = httpObj.responseText;
        } else {
            $("result").innerHTML = "<b>Wait...</b>";
        }
    }
}

function check() {
    var flg = document.createElement("input");
    flg.type = "hidden";
    flg.name = "flg";
    flg.value = "1";
    document.getElementById("inputform").appendChild(flg);
    document.inputform.submit();
}

