/**
* 显示url网页内容的通用函数
*
*中铖公司
*陈海生
*20070614
*
* Parameters:
* url——要获取内容的网页
* obj——显示内容的容器对象，如:DIV
**/
//一执行就退出
function getContent(url,obj)
{
	var xmlhttp;
	if (typeof XMLHttpRequest != 'undefined') {
      xmlhttp = new XMLHttpRequest();
  }else if (typeof ActiveXObject != 'undefined') {
      xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
  }
	//obj.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("POST",url,true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				obj.innerHTML=xmlhttp.responseText;
			}else{
				obj.innerHTML="<font color=red>数据源错误。</font>";
			}
		}
	};
	xmlhttp.send(null);
}


//加载完才退出
function getContent1(url,obj)
{
	var xmlhttp;
	if (typeof XMLHttpRequest != 'undefined') {
      xmlhttp = new XMLHttpRequest();
  }else if (typeof ActiveXObject != 'undefined') {
      xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
  }
	//obj.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	//xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				obj.innerHTML=xmlhttp.responseText;
			}else{
				obj.innerHTML="<font color=red>数据源错误。</font>";
			}
		}
	//};
	
}

//执行脚本
function getContent2(url,obj)
{
	var xmlhttp;
	if (typeof XMLHttpRequest != 'undefined') {
      xmlhttp = new XMLHttpRequest();
  }else if (typeof ActiveXObject != 'undefined') {
      xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
  }
	//obj.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	//xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				var Html="";
				var jsCode = "";
				var resText1;
				var resText=xmlhttp.responseText.split("<script language=\"javascript\">");
				for(var i=0;i<resText.length;i++){
					var stmp=resText[i];
					if (stmp.indexOf("</script>")>0){
						resText1 = stmp.split("</script>"); 
						//alert(resText1[0]);
						//eval(resText1[0]);//执行脚本 
						jsCode = jsCode+resText1[0];						
						Html=Html+resText1[1];						
					}else{
						Html=Html+stmp;
					}
				}
				if (jsCode!=""){
					eval(jsCode);//执行脚本 
				}
				//alert(Html+resText1[1]);
				obj.innerHTML=Html;  
			}else{
				obj.innerHTML="<font color=red>数据源错误。</font>";
			}
		}
	//};
	//xmlhttp.send(null);
	
}

/*
*type有值时，且不为0时，不用多线程
*lt 1--加载中放入层内。2-加载中放在层上
*/
function loading(url,objname,type,lt)
{
	var loadName="加载中...";
	if (lt!=null && lt==2) loadName="<div style='position:absolute;Z-INDEX:100;'>加载中...</div>";
	var obj=null;
	obj=document.getElementById(objname);
	obj.innerHTML=loadName;
	if (type==null || type=="0") getContent(url,obj);
	else getContent1(url,obj);
}



