
    function SystemMessagesOK()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=confirm",
            success: function(output)
            {
                if(output == "REFRESH") history.go(0);
                else                    window.location.href = output;
            }
        });
    }

    function SystemMessagesOKBySender()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=confirm_sender",
            success: function(output)
            {
                if(output == "REFRESH") history.go(0);
                else                    window.location.href = output;
            }
        });
    }


    function SystemMessagesCANCEL()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=denied",
            success: function(output)
            {
            }
        });
    }

    function SystemMessagesCANCEL2()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=delete_by_receiver",
            async: false,
            success: function(output)
            {
            }
        });
    }
    function SystemMessagesCANCELBySender()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=delete_by_sender",
            success: function(output)
            {
            }
        });
    }

    function SystemMessagesRefreshWindow()
    {
        SystemMessagesCANCEL2();
        history.go(0);
    }


    function SystemMessagesChecking()
    {
        $.ajax(
        {
            type: "POST",
            url: "ajax_handler.php",
            data: "script=modules/WQ/ajax_requested/system_message.php&req=check",
            success: function(output)
            {
                if(output != "")
                {
                    $('#confirm_screen').css('display', 'none');
                    $('#alert_screen').css('display', 'none');

                    var parse = output.substr(0,4);
                    var caption_text = output.substr(4);

                    var pos = caption_text.indexOf(">");
                    var caption = caption_text.substr(1,pos-1);
                    var text = caption_text.substr(pos+1);

                    if(parse == "<R1>")
                        designed_confirm(caption,text,SystemMessagesOK,SystemMessagesCANCEL);
                    else if(parse == "<R2>")
                        designed_alert(caption,text,SystemMessagesRefreshWindow);
                
                    else if(parse == "<S1>")
                        designed_alert(caption,text,SystemMessagesCANCELBySender, "cancel");
                    else if(parse == "<S2>")
                        designed_alert(caption,text,SystemMessagesCANCELBySender);
                    else if(parse == "<S3>")
                        designed_alert(caption,text,SystemMessagesOKBySender);
                    else if(parse == "<N1>")
                        designed_alert(caption,text,noop);
                }
            }
        });
    }

