﻿function __ShowMessage(vstrMsg)
{
    if(window.attachEvent)
    {
        window.attachEvent("onload", function() {alert(vstrMsg);} );
    }else{
        //window.addEventListener("load", function() {alert(vstrMsg);} )
        alert(vstrMsg);
    }
};

//function __ShowMessageByStr(vstrMsg)
function __ShowMessageByStr(executor, eventArgs)
{
    var vstrMsg = executor;
    try{
        if (executor.get_responseAvailable()) {
            vstrMsg = Sys.Serialization.JavaScriptSerializer.deserialize(executor.get_responseData());
        };
    }catch(e){
    };
        if(vstrMsg){
            if((vstrMsg.childNodes)){
                if(vstrMsg.childNodes.length==2){
	                    alert(vstrMsg.childNodes[1].text);
	  	        };
	  	    }else{
	  	        alert(vstrMsg);
	  	    };
	  	};
};

function __ShowMessageById(vstrMsgId)
{
    $.post('GetMessage_WS.aspx/ShowMessage',{MType:'0',MsgId:vstrMsgId},function(data) {__ShowMessageByStr(data);});
};

function __ShowMessageById(vstrMsgId,vstrContent1)
{
    $.post('GetMessage_WS.asmx/ShowMessage',{MType:'1',MsgId:vstrMsgId,Content1:vstrContent1},function(data) {__ShowMessageByStr(data);});
};

function __ShowMessageById(vstrMsgId,vstrContent1,vstrContent2)
{
    $.post('GetMessage_WS.asmx/ShowMessage',{MType:'2',MsgId:vstrMsgId,Content1:vstrContent1,Content2:vstrContent2},function(data) {__ShowMessageByStr(data);});
};

function __ShowMessageById_Req(vstrMsgId)
{
    $.post('GetMessage_WS.asmx/ShowMessage',{MType:'R0',MsgId:vstrMsgId},function(data) {__ShowMessageByStr(data);});
};

function __ShowMessageById_Req(vstrMsgId,vstrContent1)
{
    $.post('GetMessage_WS.asmx/ShowMessage',{MType:'R1',MsgId:vstrMsgId,Content1:vstrContent1},function(data) {__ShowMessageByStr(data);});
};

function __ShowMessageById_Req(vstrMsgId,vstrContent1,vstrContent2)
{
    $.post('GetMessage_WS.asmx/ShowMessage',{MType:'R2',MsgId:vstrMsgId,Content1:vstrContent1,Content2:vstrContent2},function(data) {__ShowMessageByStr(data);});
};

/* 測試程式

__ShowMessageById_Req(10103);
__ShowMessageById_Req(10101,'1');
__ShowMessageById_Req(10101,'2','3');

__ShowMessageById(10104);
__ShowMessageById(10101,'1');

__ShowMessageById(10101,'2','3');
 */
