﻿/*
Ajax获取页面HTML通用方法			2006-11-19 by Jinti Ray

在 IE 6 及 MOZILLA 5 下测试通过
注意：仅限获取本地UTF-8编码
*/


/*
返回XMLHTTP对象
CheckXmlHttp()	:	XMLHTTP Object
xmlobj 			:	外部定义新的对象
*/
function XmlHttpObj(xmlobj)
{
	var checkxml=true;
	xmlobj=null;
	
	//for IE
	try
	{
		xmlobj=new ActiveXObject("Msxml2.XMLHTTP");
		return xmlobj;
	} 
	catch(e) 
	{
		checkxml=false;
	}
	if (!checkxml)
	{
		try
		{
			xmlobj=new ActiveXObject("Microsoft.XMLHTTP");
			checkxml=true;
			return xmlobj;
		} 
		catch(e)
		{
			checkxml=false;
		}
	}

	//for mozilla
	if (!checkxml) {
		try
		{
 			xmlobj = new XMLHttpRequest(); 
			checkxml=true;	
			return xmlobj;
		}
		catch(e)
		{
			checkxml=false;
		}
	}

	return xmlobj;
}


/*
获取页面代码	

iDocId:页面元素的ID号
strURL:要获取页面的URL
iTimeId:清理时间
iWidth:图层或FRAME的宽度
iHeight:图层或FRAME的高度
*/
function getPageCode(xmlobj,iDocId,strURL,iTimeId,iWidth,iHeight)
{	
	
	if (null!=xmlobj)
	{
		xmlobj.open("GET",strURL+"&"+new Date().getTime(),true);
	
		xmlobj.onreadystatechange=function()
		{
			if (xmlobj.readyState==4) 
			{
				if (xmlobj.status==200 || xmlobj.status==0){
					document.getElementById(iDocId).innerHTML = "<div id='+iDocId+'  >"+xmlobj.responseText+"</div>";
					if (null!=iTimeId && ""!=iTimeId)
					{
						clearInterval(iTimeId);
						//alert(xmlobj.responseText);
					}				

				}
			}  
		} 
		xmlobj.send(null);
	}
	else
	{
		document.getElementById(iDocId).innerHTML="";
		document.write("<div id='"+iDocId+"'><iframe frameborder='0' height='"+iWidth+"' width='"+iHeight+"' scrolling='no' src='"+strURL+"' ></iframe></div>");
		
		if (null!=iTimeId && ""!=iTimeId)
		{
			clearInterval(iTimeId);
		}
	}

}


/*
span
*/

function getPageCode2(xmlobj,iDocId,strURL,iTimeId,iWidth,iHeight)
{	
	
	if (null!=xmlobj)
	{
		xmlobj.open("GET",strURL+"&"+new Date().getTime(),true);
	
		xmlobj.onreadystatechange=function()
		{
			if (xmlobj.readyState==4) 
			{
				if (xmlobj.status==200 || xmlobj.status==0){
					document.getElementById(iDocId).innerHTML = "<span id='+iDocId+'  >"+xmlobj.responseText+"</span>";
					if (null!=iTimeId && ""!=iTimeId)
					{
						clearInterval(iTimeId);
						//alert(xmlobj.responseText);
					}				

				}
			}  
		} 
		xmlobj.send(null);
	}
	else
	{
		document.getElementById(iDocId).innerHTML="";
		document.write("<div id='"+iDocId+"'><iframe frameborder='0' height='"+iWidth+"' width='"+iHeight+"' scrolling='no' src='"+strURL+"' ></iframe></div>");
		
		if (null!=iTimeId && ""!=iTimeId)
		{
			clearInterval(iTimeId);
		}
	}

}










/*
页面LOADING显示
iDocId:页面元素的ID号
strCss:Css样式
strStyle:自定义Style
*/
function SetLoadingStyle(iDocId,strCss,strStyle){
var showCode="";
	showCode=showCode+"<div id='"+iDocId+"' >";
	showCode=showCode+"<span class='"+strCss+"'  style='"+strStyle+"' >";
	showCode=showCode+"<center><br /><br />请稍候！页面正在加载中......<br /><br />";
	showCode=showCode+"<img src='/images/ajaxloading.gif'  border='0' />";
	showCode=showCode+"<br /> <br />  </center> </span> </div>";
	//alert(showCode);
	document.getElementById(iDocId).innerHTML=showCode;
}

function SetLoadingStyle2(iDocId,strCss,strStyle){
var showCode="";
	showCode=showCode+"<div id='"+iDocId+"' >";
	showCode=showCode+"<span class='"+strCss+"'  style='"+strStyle+"' >";
	showCode=showCode+"loading...";
	showCode=showCode+"";
	showCode=showCode+"</span></div>";
	//alert(showCode);
	document.getElementById(iDocId).innerHTML=showCode;
}


function SetLoadingStyle3(iDocId,strCss,strStyle){
var showCode="";

	showCode=showCode+"<span id='"+iDocId+"'class='"+strCss+"'  style='"+strStyle+"' >";
	showCode=showCode+"loading...";
	showCode=showCode+"";
	showCode=showCode+"</span>";
	//alert(showCode);
	document.getElementById(iDocId).innerHTML=showCode;
}