//Request
var arrREQ = new Array();

function CommonXML_CreateObject() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
			}
		}
	}
	return xmlreq;
}

function CommonXML_recv(idx,recv) {
	REQ = arrREQ[idx];
	if (REQ.readyState == 4) {
		if (REQ.status == 200) {
			recv(REQ.responseXML);
		} else {
			alert("XML µ¥ÀÌÅÍ¿¡ ¹®Á¦°¡ ÀÖ½À´Ï´Ù : " +REQ.statusText);
		}
	}
}

function CommonXML_send()
{
	if(this.param == "")
		this.REQ.open("GET", this.page, true);
	else
		this.REQ.open("POST", this.page, true);
	this.REQ.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	this.REQ.send(this.param);
}

function clsReqXML(page,param,recv)
{
	this.idxREQ = arrREQ.length;
	
	this.page = page;
	this.param = param;
	this.recv = recv;
	
	this.REQ = CommonXML_CreateObject();
	arrREQ[this.idxREQ] = this.REQ;	
	eval("this.REQ.onreadystatechange = function() { CommonXML_recv("+this.idxREQ+","+this.recv+"); }");
	this.send = CommonXML_send;
}

//Parse
function CommonXML_setXML(XMLResult)
{
	this.XMLResult = XMLResult;
}
function CommonXML_setXMLName(XMLName)
{
	this.XML = this.XMLResult.getElementsByTagName(XMLName)[0];
}
function CommonXML_setElementName(ElementName)
{
	this.Elements = this.XML.getElementsByTagName(ElementName);
}
function CommonXML_fetchXML()
{
	if(typeof(this.XMLResult) != "object" || typeof(this.XML) != "object" || typeof(this.Elements) != "object") return false;
	
	if(this.Elements.length - 1 <= this.cursor) return false;
	
	this.cursor++;
	
	return true;
}
function CommonXML_BindCol(ColName)
{
	try {
		return this.Elements[this.cursor].getElementsByTagName(ColName)[0].firstChild.nodeValue;
	}
	catch(e){
		return "";
	}
}
function CommonXML_getElementCount()
{
	return this.Elements.length;
}
function clsParseXML()
{
	this.XMLResult = "";
	this.XML = "";
	this.Elements = "";
	this.cursor = -1;
	
	this.setXML = CommonXML_setXML;
	this.setXMLName = CommonXML_setXMLName;
	this.setElementName = CommonXML_setElementName;
	this.fetchXML = CommonXML_fetchXML;
	this.BindCol = CommonXML_BindCol;
	this.getElementCount = CommonXML_getElementCount;
}

function SafeInnserHTML(id,str)
{
	if(document.getElementById(id) != null) document.getElementById(id).innerHTML = str;
}