var XML={
text:"Empty",
xml:null,
source:function(){
	var a=null;
	if(window.ActiveXObject){
		a=new ActiveXObject("Msxml2.XMLHTTP");
		if(!a){
			a=new ActiveXObject("Microsoft.XMLHTTP")
		}
	}else if(window.XMLHttpRequest){
		a=new XMLHttpRequest()
	}
	return a;
  },
xLoad:function(url,fun){
	var tX=XML.source();
	tX.open("GET",url,true);
	tX.onreadystatechange=function(){
		if(tX.readyState==4&&tX.status==200){
			XML.text=tX.responseText;
			//alert(XML.text);
			if(fun){
				fun();
			}
		}
	}
	tX.send(null);
 },
repos:function(aid,pid){
	//alert(aid+"\n"+pid);
	XML.xLoad("build.php?action=repos&aid="+aid+"&pid="+pid+"&no="+Math.random());
},
del:function(obj){
//	if(obj.tagName=="IMG")
//		aid=obj.parentNode.parentNode.offsetParent.parentNode.id;
	if(window.confirm("确认关闭？"))
	{
		I$(obj).removeNode(true);
		return true;
	}
	else
		return false;
//	XML.xLoad("build.php?action=del&aid="+aid+"&no="+Math.random(),function(){
//			if(XML.text==1){
//					_gebid(aid).removeNode(true);
//			}
//	});
	//window.location.reload();
},
close:function(obj){
I$(obj).removeNode(true);
},
create:function(){
	var uri=_gebid("feed").value;
	if(!uri){
		alert("URI!!!");
		return;
	}
	addnew=function(){
		var div=document.createElement("DIV");
			div.id="card_"+num;
			div.className="dragDiv";
			div.innerHTML='<TABLE width="100%" cellpadding="0" cellspacing="0" border="0"><TR class="dragTR" onMouseDown="Drag.dragStart();"><TD><SPAN style="float:right;cursor:default;"><IMG ALT="删除" SRC="x.gif" onClick="XML.del(this);" /></SPAN>Loading...</TD></TR><TR><TD>Loading...</TD></TR></TABLE>';
			_gebid("section_0").appendChild(div);
			XML.loadContent(url,aid);
	}
	var aid="card_"+num;
	var url=uri;
	uri=encodeURIComponent(uri);
	XML.xLoad("build.php?action=new&aid="+aid+"&pid=section_0&source="+uri+"&no="+Math.random(),addnew);
	//window.location.reload();
},
loadContent:function(url,id){
	//alert(url);
		XML.xLoad("getxml.php?feed="+url+"&no="+Math.random(),function(){
			if(XML.text.charAt(0)=="<")
				_gebid(id).innerHTML=XML.text;
			else
				_gebid(id).innerHTML='<TABLE width="100%" cellpadding="0" cellspacing="0" border="0"><TR class="dragTR" onMouseDown="Drag.dragStart();"><TD><SPAN style="float:right;cursor:default;"><IMG ALT="删除" SRC="x.gif" onClick="XML.del(this);" /></SPAN><A HREF="'+decodeURIComponent(url)+'" TARGET="_blank" >'+decodeURIComponent(url)+'</A></TD></TR><TR><TD><I>暂时不能显示</I></TD></TR></TABLE>';
			});

		
}
//end of XML
}
