//點擊切換顯示對像或者隱藏對像
function displayObj(MenuObj){
	MenuObj=document.getElementById(MenuObj);
	if(MenuObj.style.display==''){
		MenuObj.style.display='none';
	}else{
		MenuObj.style.display='';
	}
}

//全選
function CheckAll(form){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.name != 'chkAll')
    e.checked = form.chkAll.checked;
    }
}

//刪除
function del_submit(theform){
	if(confirm('提醒：你確定要刪除這些數據嗎？')){
		theform.action='del.asp';
		theform.submit();
		theform.action='';
	}else{
		return false;
	}
}

function reloadImgSize(imgD,FitWidth,FitHeight){
var image1=new Image();  
image1.onload = function () 
{ 
    if(this.width>0 && this.height>0)  
    {  
        if(this.width/this.height>= FitWidth/FitHeight)  
        {  
            if(this.width>FitWidth)  
            {  
                imgD.width=FitWidth;  
                imgD.height=(this.height*FitWidth)/this.width;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
        else  
        {  
            if(this.height>FitHeight)  
            {  
                imgD.height=FitHeight;  
                imgD.width=(this.width*FitHeight)/this.height;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
    } 
    image1 = null; 
} 
image1.src=imgD.src;  
imgD.style.cursor = 'hand';
}

function setcookie(name,value)
{
  var exp=new Date();
  exp.setYear(exp.getYear()+1);
  //編碼：escape();unescape 解碼
  document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();
}


function GetData(OpenUrl,theResultTable){
 var XmlHttp;

 createXmlHttpRequest();
 // 加隨機數防止緩存
 if (OpenUrl.indexOf("?") > 0){
    OpenUrl += "&randnum=" + Math.random();
 }else{
    OpenUrl += "?randnum=" + Math.random();
 }
    XmlHttp.onreadystatechange=function(){
        if(XmlHttp.readyState==4){
            if(XmlHttp.status==200)
            {
              document.getElementById(theResultTable).innerHTML = bytes2BSTR(XmlHttp.responsebody);
            }
		//以下這3行代碼重要,而且位置一定要在這里,釋放內存主要就靠它了,注:這3行代碼的位置一定要在if (4==xmlhttp.readyState){}里,否則無效或效果不好.
		delete XmlHttp ; 
		XmlHttp=null;
		CollectGarbage;
		///////////////////////////////////
        }
    }
    XmlHttp.open("post",OpenUrl,true);
    XmlHttp.send();

function createXmlHttpRequest(){
  if(window.ActiveXObject){
   XmlHttp = new ActiveXObject("Microsoft.XmlHttp");
  }else{
   XmlHttp = new XmlHttpRequest();
  }
} 
}