/*///////////////////////////////////////////////////////////////////////////////////////////

	XML on JS - 1.0.0.0      2004.11.27

	http://muhwa.com
	
	(c)2004 muhwa all rights reserved.

/*/////////////////////////////////////////////////////////////////////////////////////////////	


if(window.XML) alert('Can\'t using XML');

XML = new function () {
	
	try {
		this.Connector = new ActiveXObject("Microsoft.XMLHTTP");
		this.getAllText = function(xml){return (xml.lastChild) ? xml.xml : ''}
		this.merge = function (xml,xsl){return xml.transformNode(xsl);}

	} catch (e) {
		try {
			this.Connector	= new XMLHttpRequest();
			this.Serializer	= new XMLSerializer();
			this.Processor	= new XSLTProcessor();

			this.getAllText = function(xml){return this.Serializer.serializeToString(xml)}
			this.merge = function (xml,xsl){
				this.Processor.importStylesheet(xsl);
				return this.Serializer.serializeToString(this.Processor.transformToFragment(xml, document));
			}
		} catch (e) { alert('Can\'t using mXML'); }
	}

	this.open = function (url, method, sync){

		sync = (sync) ? true : false;

		var tmp = '', QueryData = null;
		
		if(method){
			if(method.toUpperCase() == "P" || method.toUpperCase() == "POST"){
				tmp=url.split("?");
				url=tmp[0];
				QueryData=tmp[1];
				method = "POST";
			}
		}else method='GET';

		this.Connector.open(method, url, sync);
		if(QueryData){
			this.Connector.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") 
			this.Connector.setRequestHeader("Content-length", QueryData.length) 
		}
		this.Connector.send(QueryData);

		var rtn=this.Connector.responseXML;
		
		return rtn;
	}

}

function XMLObject(url) {

	this.XML=XML.open(url);
	this.toHTML=this.transform=XMLObject_transform;
	this.toText=XMLObject_toText;

}
function XMLObject_toText() {
	return XML.getAllText(this.XML.lastChild)
}
function XMLObject_transform(xml) {

	if(!xml) return this.toText();
	if(xml.constructor == String) xml=XML.open(xml);
	else if(xml.XML) xml=xml.XML;

	return XML.merge(this.XML,xml);
}

