﻿document.write('<DIV id="loadingg"  style="HEIGHT:100px; WIDTH: 100px;POSITION: absolute; Z-INDEX:100000;FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/loading.png, sizingmethod=image); display:none;"></DIV>')
function showloading() 
{
if (showicon){
	var obj=document.getElementById("loadingg")
	if (obj.style.display!="")
	{
	obj.style.left=((document.documentElement.clientWidth-parseFloat (obj.style.width))/2)+document.documentElement.scrollLeft+"px";
	obj.style.top=((document.documentElement.clientHeight-parseFloat (obj.style.height))/2)+document.documentElement.scrollTop+"px";
	obj.style.display="";
	}else{obj.style.display="none";}
  }
}


function elm(id)
{
	return document.getElementById(id);	
}
function echo(obj,html)
{
	elm(obj).innerHTML=html;
}
function fopen(obj)
{
	elm(obj).style.display="";
}
function fclose(obj)
{
	elm(obj).style.display="none";
}
function createxmlhttp()
{
	var xmlhttp=false;
	try	{
  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} 
	catch (e) {
  		try {
   			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} 
		catch (e) {
   			xmlhttp = false;
 		}
 	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  		xmlhttp = new XMLHttpRequest();
				if (xmlhttp.overrideMimeType) {//設置MiME類別
			xmlhttp.overrideMimeType('text/xml');
		}
	}	

	return xmlhttp;	
}


function getdata(url,obj1,obj2)
{
		url=url+'&rnd='+ Math.random()
		var xmlhttp=createxmlhttp();
		if(!xmlhttp)
		{
			alert("你的瀏覽器不支持XMLHTTP！！");
			return;
		}
		if(elm(obj1)!=null)echo(obj1,"正在加載數據，請稍等......");
		showloading() 
		xmlhttp.onreadystatechange=requestdata;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		function requestdata(){
				if(xmlhttp.readyState==4)
				{
					//alert(xmlhttp.responseText)
					if(xmlhttp.status==200)
					{
						if(elm(obj1)!=null)fclose(obj1);
						fopen(obj2);
						echo(obj2,xmlhttp.responseText);
						showloading() 
					}else{
						echo(obj2,"ErrorCode:"+xmlhttp.status+"\n伺服器傳回:程式錯誤錯誤\n"+xmlhttp.responseText)
					}
				}
			
		}
}
function postdata(url,data,obj,regetit){
		var xmlhttp=createxmlhttp();
		if(!xmlhttp)
		{
			alert("你的瀏覽器不支持XMLHTTP！！");
			return;
		}
		showloading() 
		xmlhttp.open("POST", url, true);
		xmlhttp.onreadystatechange=requestdata;
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send(data);
		function requestdata()
		{
			if(xmlhttp.readyState==4)
			{
				if(xmlhttp.status==200)
				{
					fopen(obj);
					if(xmlhttp.responseText.indexOf("成功")>0){
						try{
							document.forms[0].Message.value='';
							var code_now=new Date();
							elm("validate_img").src='common/getcode.asp?'+code_now.getTime();
							}
						catch(e){};
					}
					echo(obj,xmlhttp.responseText);
					showloading(); 
					if(regetit==1){reget()};
				}else{
					echo(obj,"ErrorCode:"+xmlhttp.status+"\n伺服器傳回:程式錯誤錯誤\n"+xmlhttp.responseText)
				}
			}
		}
}
