var xmlobj;                                 //定义XMLHttpRequest对象
function CreateXMLHttpRequest() {
    if(window.ActiveXObject) 
                     //如果当前浏览器支持ActiveXObject，则创建ActiveXObject对象
    {
         xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if(window.XMLHttpRequest)
                           //如果当前浏览器支持XMLHttpRequest，则创建XMLHttpRequest对象
    {
         xmlobj = new XMLHttpRequest();
    }
	return xmlobj;   
}

function ShowArticle(url)                      //主程序函数
{
    xmlobj=CreateXMLHttpRequest();                 //创建对象
    var showurl = url;                     //构造URL
    xmlobj.onreadystatechange = StatHandler;  //判断URL调用的状态值并处理
    xmlobj.open("GET", showurl, true);      //调用test.html
    xmlobj.send(null);                      //设置为不发送给服务器任何数据
}

function SendArticle(url,msg)                      //主程序函数
{
    xmlobj1=CreateXMLHttpRequest();                 //创建对象
    var showurl = url;                     //构造URL
	params=msg;
//	alert(params);
    xmlobj1.onreadystatechange = StatHandler;  //判断URL调用的状态值并处理
    xmlobj1.open("POST", showurl, true);      //调用test.html
    xmlobj1.setrequestheader("content-length",params.length); 
    xmlobj1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlobj1.setRequestHeader("Connection", "close");
    xmlobj1.send(params);
}

function UploadArticle(url,fields,picfile)                      //主程序函数
{

	data = "" 
	spliter = "-------7d8d733180846" 
	datadata = data + spliter + "\r\n" 
	fields=unescape(fields);
	alert(fields);
	datadata = data + "Content-Disposition: form-data; name=\"picfile\"; filename=\""+picfile+"\"\r\n" 
	// datadata = data + "Content-Type: image/pjpeg" + vbCrLf 
	datadata = data + "Content-Type: text/plain" + "\r\n" + "\r\n" 
	postLength = text.length + data.length + 2 + spliter.length + 4 
	package = data + text + "\r\n" + spliter + "--\r\n" 
	alert(package) 
	// 把XML文档发送到Web服务器 

	return false;


	
}


function StatHandler()                      //用于处理状态的函数
{
    if(xmlobj.readyState == 4 && xmlobj.status == 200)                                                                  //如果URL成功访问，则输出网页
    {
		lines=split("\n",xmlobj.responseText);
		operat=false;
		for( i = 0; i < lines.length; i ++ ) { 
			if(lines[i]=="<end>")operat=false;
			if(operat && lines[i]!=""){
				one=split("^",lines[i]);
				one_divid=one[0];
				one_str=one[1];
		//		alert(one_str);
				if(one_divid=="AJAX_im_window_focus"){
					if(one_str=="1"){
					refwindow();
					}else{
					reswindow();
					}
				}
				if(document.getElementById(one_divid)){
				document.getElementById(one_divid).innerHTML = one_str;
				}
			}
			if(lines[i]=="<start>")operat=true;
		}
    }
}


function ShowAJAXnews(no){
ShowArticle('/news/ajax.php?news_id=' +no);
}