
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(iDocId,strURL,iLoading)
{
	getPageCode(iDocId,strURL,iLoading,null);
}

function getPageCode(iDocId,strURL,iLoading,evalFun)
{

	var xmlobj;
	xmlobj=XmlHttpObj(xmlobj);

	if (1==iLoading)
	{
		SetLoadingStyle(iDocId);
	}

	if (2==iLoading)
	{
		LoadingDivStyle(1);
	}
	
	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){
					
						if (2==iLoading)
						{
							LoadingDivStyle(0);
						}

					
					
					try
					{
						document.getElementById(iDocId).innerHTML = xmlobj.responseText;

						urchinTracker(window.top.location.href);
					}
					catch(e)
					{
						;
					}


					if (null!=evalFun)
					{
						try
						{
							eval(evalFun);
						}
						catch (e)
						{
							;
						}
						
					}
					
				}
			}  
		} 
		xmlobj.send(null);
	}

}



/*
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 = xmlobj.responseText;
					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);
		}
	}

}


function XMLDomObj()
{
	var isIE=(navigator.appName=="Microsoft Internet Explorer"?true:false);
	var isFF=(navigator.appName=="Netscape"?true:false);
	var obj=this;
	var xmlobj=XmlHttpObj(xmlobj);

	this.strURL="";
	this.xmldoc=null;
	

	this.Send=function()
	{
		if (null!=xmlobj)
		{
			xmlobj.open("GET",obj.strURL+"&"+new Date().getTime(),true);
			xmlobj.onreadystatechange=function()
		{
			if (xmlobj.readyState==4) 
			{
				if (xmlobj.status==200 || xmlobj.status==0){
					

					try
					{
						obj.xmldoc=xmlobj.responseXML;
						obj.LoadXmlOK();
						urchinTracker(window.top.location.href);
					}
					catch(e)
					{
						;
					}

				}
			}  
		} 
		xmlobj.send(null);
		}
	}

	this.selectSingleNode = function(objXML,path) {

		var paths = path.split("/");
		
		if (paths.length > 1) {
				if (isIE) {
					return objXML.documentElement.selectSingleNode(path);
				}
				else if (isFF) {
					if (objXML.documentElement.nodeName == paths[1]) {
						var pClildNode = objXML.documentElement;
						for (var i=2; i<paths.length; i++) {
							var tmp_flag = true;
							for (var j=0; j<pClildNode.childNodes.length; j++) {
								if (tmp_flag && (pClildNode.childNodes[j].nodeName == paths[i])) {
									pClildNode = pClildNode.childNodes[j];
									tmp_flag = false;
								}
							}
							if (tmp_flag) {
								return null;
							}
						}
						return pClildNode;
					}												   
					else {
						return null;
					}
				}
			}
			else {
				return null;
			}
	}


	this.LoadXmlOK=function()
	{
		;
	}





}



/*
页面LOADING显示
iDocId:页面元素的ID号
*/
function SetLoadingStyle(iDocId){
var showCode="";

	showCode+="<span style='text-align:center;font-size:12px;'>";
	showCode+="<center>";
	showCode+="<img src='http://caenet.cn/images/ajaxloading.gif'  border='0' />&nbsp;正在加载中......";
	showCode+="</center>";
	showCode+="</span>";
	document.getElementById(iDocId).innerHTML=showCode;
}



function SetLoadingStyle3(iDocId,strCss,strStyle){
var showCode="";
	showCode=showCode+"loading...";
	//alert(showCode);
	document.getElementById(iDocId).innerHTML=showCode;
}


function LoadingDivStyle(iStatus)
{
	var divid="page_loading_msg";
	var intervaltm=null;

	try
	{
			if (1==iStatus)
			{
				centerdiv(divid);
				document.getElementById(divid).style.display='block';
				intervaltm=setInterval("centerdiv('"+ divid +"')", 100); 
			}
			else
			{
				document.getElementById(divid).style.display='none';
				if (null!=intervaltm)
				{
					clearInterval(intervaltm);
				}
				
			}
		
	}
	catch (e)
	{
		;
	}


}



function  centerdiv(divid)  
{  
  var divobj=document.getElementById(divid);
  var w=200;
  var h=50;
  divobj.style.width=w+"px";
  divobj.style.height=h+"px";
  divobj.style.textAlign="center";
  divobj.style.verticalAlign="middle";
  divobj.style.fontSize="14px";
  divobj.style.color="#000000";
  divobj.style.border="1px #cccccc solid";
  divobj.style.padding="5px";
  divobj.style.filter = "alpha(opacity=70)";
  divobj.style.opacity=0.7;
  divobj.style.backgroundColor="#e6e6e6";
  divobj.style.position='absolute';
  //divobj.style.left=parseInt((document.body.offsetWidth-parseInt(w))/2)+"px";  
  //divobj.style.top=parseInt((document.body.offsetHeight-parseInt(h))/2)+"px"; 
  
  divobj.style.top = document.documentElement.scrollTop + parseInt((bodyClientHeight() - divobj.offsetHeight) / 2) + "px";
  divobj.style.left = document.documentElement.scrollLeft + parseInt((bodyClientWidth() - divobj.offsetWidth) / 2) + "px";
}  

function bodyClientWidth() {
	return document.body.clientWidth;
}
function bodyClientHeight(isDOCTYPE) {
	if (isDOCTYPE = false) {
		return document.body.clientHeight;
	}
	else {
		return document.documentElement.clientHeight;
	}
}
