﻿//將每個父項目的值設為第一個
/*
   oClass 所要驗證的物件名稱
*/
function SetInitialValue(oClass) {
   var arrObj = oClass.split(",");

   for (shtR = 0; shtR < arrObj.length; shtR++)
      document.getElementById(arrObj[shtR]).options[0].selected = true;
}

//存子項目的值到HtmlInputHidden物件
/*
   oSource  所要選擇的來源物件的值
   oTarget  所要設定的目標物件
*/
function SetSubValue(oSource, oTarget) {
   document.getElementById(oTarget).value = oSource;
}

/*
   strType   所要使用的傳輸方式
   strURL    所要連結的URL位址
   oTarget   所要設定的目標物件(Detail)
   strValue  表目標物件的值[主要用在修改]
*/
function GetListItem(strType, strURL, oTarget, strEmptyErrID, strERRID, strSccessMsg) {
   var objHTTP_Request = false;
   
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       objHTTP_Request = new XMLHttpRequest();
   } else if (window.ActiveXObject) { // IE
       try {
           objHTTP_Request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               objHTTP_Request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }
   
   if (!objHTTP_Request) {
      alert("無法建立XMLHTTP介面，請向系統管理員反應！");
      return false;
   }

    if (oTarget.value == "") {
        alert(strEmptyErrID);
        return false;
    } else {		    
       objHTTP_Request.open(strType, strURL, true);
       objHTTP_Request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
       objHTTP_Request.send(null);
       objHTTP_Request.onreadystatechange = function () {
       	    if (objHTTP_Request.readyState == 4) {  
                var strResult = objHTTP_Request.responseText;
                if (strResult == "true") {
                    oTarget.value = "";
                    alert(strERRID);
                    return false;
                } else {
                    alert(strSccessMsg);
                    return true;
                }
             }
       }
    }
}

function show_loading() { 
    IE = (document.all && navigator.userAgent.indexOf("Opera") == -1);

    if (IE) {
      document.getElementById("ctl00_UpLoading").style.display = "inline";
      document.getElementById("ctl00_UpLoading").offsetHeight;
      document.getElementById("ctl00_UpLoading").style.pixelTop = (document.body.clientHeight/2)-(document.getElementById("ctl00_UpLoading").offsetHeight/2)+(document.body.scrollTop); 
      document.getElementById("ctl00_UpLoading").style.pixelLeft = (document.body.clientWidth/2)-(document.getElementById("ctl00_UpLoading").offsetWidth/2)+(document.body.scrollLeft); 
    }
} 

function hide_loading() {
    document.getElementById("ctl00_UpLoading").style.display = "none";
}
