﻿// JScript 檔
///Class代號：      MessageBox
///Class名稱：      讀取MessageBox.xml文件信息
///程式說明:     　 從MessageBox.xml文件中循環讀取符合要求的信息

function ShowError(strCode,strPara)
{
try
{
    var o_Culture = document.getElementById('hid_CULTURE');
    if(strPara==undefined) strPara='';//實現類似于多載 
    var messageStr = ShowMessage(strCode,strPara);
    alert(messageStr);
//    if(o_Culture.value.toUpperCase()=="EN-US")
//    {
//        document.getElementById("PopupWin1titleEl").innerHTML="Error Prompt";
//    }
//    else
//    {
//        document.getElementById("PopupWin1titleEl").innerHTML="錯誤提示";//抓取提示窗口的標頭ID  //抓取提示窗口的显示内容的超链接ID
//    }
//    document.getElementById("PopupWin1aCnt").innerHTML=messageStr;//抓取提示窗口的顯示內容的超鏈接ID  //抓取提示窗口的显示内容的超链接ID
//    ErrorColor();
//    PopupWin1espopup_ShowPopup1();
    } catch(oc)
    {
//        if(document.getElementById("PopupWin1titleEl")!=null)
//        document.getElementById("PopupWin1titleEl").style.display="none";
//        if(document.getElementById("PopupWin1aCnt")!=null)
//        document.getElementById("PopupWin1aCnt").style.display="none";
    }
    return false;
}
function ShowOk(strCode,strPara)
{
try
{
    var o_Culture = document.getElementById('hid_CULTURE');
    if(strPara==undefined) strPara='';//實現類似于多載 
    var messageStr = ShowMessage(strCode,strPara);
    alert(messageStr);
//    if(o_Culture.value.toUpperCase()=="EN-US")
//    {
//        document.getElementById("PopupWin1titleEl").innerHTML="Success Prompt";//抓取提示窗口的標頭ID  //抓取提示窗口的显示内容的超链接ID
//    }
//    else
//    {
//        document.getElementById("PopupWin1titleEl").innerHTML="成功提示";//抓取提示窗口的標頭ID  //抓取提示窗口的显示内容的超链接ID
//    }
//    document.getElementById("PopupWin1aCnt").innerHTML=messageStr;//抓取提示窗口的顯示內容的超鏈接ID  //抓取提示窗口的显示内容的超链接ID
//    OkColor();
//    PopupWin1espopup_ShowPopup1();
       } catch(oc)
    {
//    if(document.getElementById("PopupWin1titleEl")!=null)
//    document.getElementById("PopupWin1titleEl").style.display="none";
//   if(document.getElementById("PopupWin1aCnt")!=null)
//   document.getElementById("PopupWin1aCnt").style.display="none";
    } 
    return false;
}
function PopupWin1espopup_ShowPopup1(show)
        {
          //if (PopupWin1dxTimer!=-1) { el.filters.blendTrans.stop(); }

          if ((PopupWin1tmrHide!=-1) && ((show!=null) && (show==PopupWin1showBy)))
          {
            clearInterval(PopupWin1tmrHide);
            PopupWin1tmrHide=setInterval(PopupWin1espopup_tmrHideTimer,PopupWin1hideAfter);
            return;
          }
          if (PopupWin1tmrId!=-1) return;
          PopupWin1showBy=show;

          elCnt=document.getElementById('PopupWin1_content')
          elTit=document.getElementById('PopupWin1_header');
          el=document.getElementById('PopupWin1');
          el.style.left=PopupWin1oldLeft==null?"":PopupWin1oldLeft;
          el.style.top='';
          el.style.filter='';

          if (PopupWin1tmrHide!=-1) clearInterval(PopupWin1tmrHide); PopupWin1tmrHide=-1;

          document.getElementById('PopupWin1_header').style.display='none';
          document.getElementById('PopupWin1_content').style.display='none';

          if (navigator.userAgent.indexOf('Opera')!=-1)
            el.style.bottom=(document.body.scrollHeight*1-document.body.scrollTop*1
                            -document.body.offsetHeight*1+1*PopupWin1popupBottom)+'px';
          
          if (PopupWin1bChangeTexts)
          {
            PopupWin1bChangeTexts=false;
            document.getElementById('PopupWin1aCnt').innerHTML=PopupWin1nMsg;
            document.getElementById('PopupWin1titleEl').innerHTML=PopupWin1nTitle;
          }

          PopupWin1actualHgt=0; el.style.height=PopupWin1actualHgt+'px';
          el.style.visibility='';
          if (!PopupWin1resetTimer) el.style.display='';
          PopupWin1tmrId=setInterval(PopupWin1espopup_tmrTimer,(PopupWin1resetTimer?1000:20));
        }

/*

當提示為成功時改變MSN的顏色
*/
function OkColor()
{
     document.getElementById("PopupWin1").style.cssText = '';
    document.all.PopupWin1.style.backgroundColor = '#E0E9F8';
    document.all.PopupWin1.style.borderRight = '1px solid #455690';
    document.all.PopupWin1.style.borderBottom='1px solid #455690';
    document.all.PopupWin1.style.borderLeft='1px solid #B9C9EF';
    document.all.PopupWin1.style.borderTop='1px solid #B9C9EF';
    document.all.PopupWin1.style.position='absolute';
    document.all.PopupWin1.style.zindex='9999';
    document.all.PopupWin1.style.width='200px';
    document.all.PopupWin1.style.height='100px';
    document.all.PopupWin1.style.right='15px';
    document.all.PopupWin1.style.bottom='15px';
 
    document.getElementById("PopupWin1_header").style.cssText = '';
    document.getElementById("PopupWin1_header").style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#FFE0E9F8', EndColorStr='#FFFFFFFF')";
    document.getElementById("PopupWin1_header").style.cursor='default';
    document.getElementById("PopupWin1_header").style.position='absolute'
    document.getElementById("PopupWin1_header").style.left='2px';
    document.getElementById("PopupWin1_header").style.width='194px';
    document.getElementById("PopupWin1_header").style.top='2px';
    document.getElementById("PopupWin1_header").style.height='14px';
    document.getElementById("PopupWin1_header").style.font='12px arial,sans-serif';
    document.getElementById("PopupWin1_header").style.color='#1F336B';
    document.getElementById("PopupWin1_header").style.textDecoration='none';

    
    document.getElementById("PopupWin1_content").style.cssText = '';
    document.getElementById("PopupWin1_content").style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#FFE0E9F8', EndColorStr='#FFFFFFFF')";
     document.getElementById("PopupWin1_content").style.borderLeft='1px solid #728EB8';
     document.getElementById("PopupWin1_content").style.borderTop='1px solid #728EB8';
     document.getElementById("PopupWin1_content").style.borderBottom='1px solid #B9C9EF';
     document.getElementById("PopupWin1_content").style.borderRight='1px solid #B9C9EF';
     document.getElementById("PopupWin1_content").style.background='#E0E9F8';
     document.getElementById("PopupWin1_content").style.padding='2px';
     document.getElementById("PopupWin1_content").style.overflow='hidden';
     document.getElementById("PopupWin1_content").style.textAlign='center';
     document.getElementById("PopupWin1_content").style.position='absolute';
     document.getElementById("PopupWin1_content").style.left='2px';
     document.getElementById("PopupWin1_content").style.width='194px';
     document.getElementById("PopupWin1_content").style.top='20px';
     document.getElementById("PopupWin1_content").style.height='76px';
}
/*
當提示為錯天時改變MSN的顏色
*/
function ErrorColor()
{
    document.getElementById("PopupWin1").style.cssText = '';
    document.all.PopupWin1.style.backgroundColor = '#DCC8C8';
    document.all.PopupWin1.style.borderRight = '1px solid #800000';
    document.all.PopupWin1.style.borderBottom='1px solid #800000';
    document.all.PopupWin1.style.borderLeft='1px solid #C8AAAA';
    document.all.PopupWin1.style.borderTop='1px solid #C8AAAA';
    document.all.PopupWin1.style.position='absolute';
    document.all.PopupWin1.style.zindex='9999';
    document.all.PopupWin1.style.width='200px';
    document.all.PopupWin1.style.height='100px';
    document.all.PopupWin1.style.right='15px';
    document.all.PopupWin1.style.bottom='15px';
 
    document.getElementById("PopupWin1_header").style.cssText = '';
    document.getElementById("PopupWin1_header").style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#FFDCC8C8', EndColorStr='#FFFFFFFF')";
    document.getElementById("PopupWin1_header").style.cursor='default';//
    document.getElementById("PopupWin1_header").style.position='absolute'
    document.getElementById("PopupWin1_header").style.left='2px';
    document.getElementById("PopupWin1_header").style.width='194px';
    document.getElementById("PopupWin1_header").style.top='2px';
    document.getElementById("PopupWin1_header").style.height='14px';
    document.getElementById("PopupWin1_header").style.font='12px arial,sans-serif';
    document.getElementById("PopupWin1_header").style.color='#400000';
    document.getElementById("PopupWin1_header").style.textDecoration='none';

    
    document.getElementById("PopupWin1_content").style.cssText = '';
    document.getElementById("PopupWin1_content").style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#FFDCC8C8', EndColorStr='#FFFFFFFF')";
     document.getElementById("PopupWin1_content").style.borderLeft='1px solid #A05A5A';
     document.getElementById("PopupWin1_content").style.borderTop='1px solid #A05A5A';
     document.getElementById("PopupWin1_content").style.borderBottom='1px solid #C8AAAA';
     document.getElementById("PopupWin1_content").style.borderRight='1px solid #C8AAAA';
     document.getElementById("PopupWin1_content").style.background='#DCC8C8';
     document.getElementById("PopupWin1_content").style.padding='2px';
     document.getElementById("PopupWin1_content").style.overflow='hidden';
     document.getElementById("PopupWin1_content").style.textAlign='center';
     document.getElementById("PopupWin1_content").style.position='absolute';
     document.getElementById("PopupWin1_content").style.left='2px';
     document.getElementById("PopupWin1_content").style.width='194px';
     document.getElementById("PopupWin1_content").style.top='20px';
     document.getElementById("PopupWin1_content").style.height='76px';
}

//---------------------------------------------------------------------[在頁面上彈出信息提示] (函數)

function ShowMsg(strCode,StrPara)
{
   return ShowMessage(strCode,StrPara);
}
//---------------------------------------------------------------------[在登陸換面使用] (函數)

function FnLogin(strCode,StrPara)
{
    document.getElementById('txtUserID').value='';
    document.getElementById('txtUserPwd').value='';
    document.getElementById('txtUserID').focus();
   return false;
}
//---------------------------------------------------------------------[在頁面上彈出信息提示] (函數)

function Show(strCode,StrPara)
{
   if(StrPara==undefined) StrPara='';
   var msg=ShowMessage(strCode,StrPara);
   alert(msg);
}
//---------------------------------------------------------------------[在頁面上彈出信息提示] (函數)

///程式說明:     　無參數
//function Show(strCode)
//{
//   var msg=ShowMessage(strCode,'');
//   alert(msg);
//}
//---------------------------------------------------------------------[給指定的Web控件,彈出確認框信息提示] (函數)
function ShowConfirm(strCode,StrPara)
{
   if(StrPara==undefined)
   {
      StrPara='';
   }
   var msg=ShowMessage(strCode,StrPara);
   if(status=="XML Error!"){
        alert(msg);
        return false
   }
   else{
        return  confirm(msg);
    }
}
//---------------------------------------------------------------------[給指定的Web控件,彈出確認框信息提示] (函數)
///程式說明:     　無參數
function ShowConfirm(strCode)
{
   var msg=ShowMessage(strCode,'');
   if(status=="XML Error!"){
        alert(msg);
        return false
   }
   else{
        return  confirm(msg);
    }
}
//---------------------------------------------------------------------[彈出信息提示,並轉向指的頁面] (函數)
function ShowAndRedirect(strCode,StrPara,url)
{
	 var msg=ShowMessage(strCode,StrPara);
	 alert(msg);
	 top.location.href=url;
}
//---------------------------------------------------------------------[彈出信息提示,並轉向指的頁面] (函數)
function ShowAndBaseRedirect(strCode,StrPara,url)
{
	 var msg=ShowMessage(strCode,StrPara);
	 alert(msg);
	 window.parent.location.href=url;
}
//程式代號：BasePage
//程式名稱：app_code/BasePage.cs使用

function ReplMsgDesc(vstrMsg,vstrPara){
if(vstrPara==undefined)
        vstrPara="";
		var vntArray=vstrPara.split('$');
		for(var i=0;i<vntArray.length;i++){
		    var strRepl ='{'+ i +'}' ;
			var intPos = vstrMsg.indexOf(strRepl);
			if(intPos!=-1){
				vstrMsg = vstrMsg.replace(strRepl, vntArray[i]);
				
			}
		}
		return vstrMsg
}

//ShowMessage(strCode,vstrPara)
//strCode 消息代號
//vstrPara 帶入消息中的字串參數
//ShowMessage('E0001','def$abc') 
//strCode為E0001時得" Save error！Table:{0}{1} ",vstrPara為"def$abc"
//會將{0}用def替換掉.{1}用abc替換掉
function ShowMessage(strCode,vstrPara)
{
    var k = GetCulture();
    var oDoc = new ActiveXObject("MSXML2.DOMDocument");
    var result = "../WEBSITE/Message.xml";
    oDoc.async=false;
    oDoc.load(result);
    var root=oDoc.documentElement;
    if(root==null)
    {
        var result ="../../WEBSITE/Message.xml";
        oDoc.async=false;
        oDoc.load(result);
        var root=oDoc.documentElement;
    }
    if(root==null)
    {
        var result ="WEBSITE/Message.xml";
        oDoc.async=false;
        oDoc.load(result);
        var root=oDoc.documentElement;
    }
    if (root==null) return "Error";
    var i; 
    for(i=0;i<root.childNodes.length;i++)
    {     
        if(root.childNodes[i].childNodes[0].text==strCode)
        {
        //   if(root.childNodes[i].childNodes[k].text.trim().length>0)
      //     {
              return ReplMsgDesc(root.childNodes[i].childNodes[k].text,vstrPara);
        //   }
        //   else
       //    {
        //    return "ID"+strCode+", Message  value not find";
         //  }
          
        }
    }
   return "ID"+strCode+",Message  value not find";
}
