<!--
// 스크랩하기
scrap = function(){
	this.docXML;				// XML데이터 return 값
	this.callback = null;		// XML결과 return함수
	this.httpRequest = null;	// httpRequest객체


	// httpRequest 객체 생성 함수
	scrap.prototype.getXMLHttpRequest = function() {
		if (window.ActiveXObject) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e1) { return null; }
			}
		} else if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			return null;
		}
	}	//	end getXMLHttpRequest function
	
	// httpRequest send 함수
	scrap.prototype.sendRequest = function(url, params, callback, method) {
		this.callback = callback;

		this.httpRequest = this.getXMLHttpRequest();
		var httpMethod = method ? method : 'GET';
		if (httpMethod != 'GET' && httpMethod != 'POST') {
			httpMethod = 'GET';
		}
		var httpParams = (params == null || params == '') ? null : params;
		var httpUrl = url;
		if (httpMethod == 'GET' && httpParams != null) {
			httpUrl = httpUrl + "?" + httpParams;
		}
		this.httpRequest.open(httpMethod, httpUrl, true);
		this.httpRequest.setRequestHeader(
			'Content-Type', 'application/x-www-form-urlencoded');
		
		var request = this;
		this.httpRequest.onreadystatechange = function() {
			request.onStateChange.call(request);
		}
		this.httpRequest.send(httpMethod == 'POST' ? httpParams : null);	
	}	// end sendRequest function

	// httpRequest return 함수
	scrap.prototype.onStateChange = function() {
		this.callback(this.httpRequest);
	}	// end onStateChange end


	// 레벨추가/수정
	scrap.prototype.scrapRequest = function(kind, code){
		params  = "kind="+encodeURIComponent(kind);
		params += "&code="+encodeURIComponent(code);

		this.sendRequest("/core/xml/scrap.xml.html", params, this.scrapResult, "POST");
	}	// end scrapRequest function	


	// XML결과
	scrap.prototype.scrapResult = function(){
		if(this.httpRequest.readyState == 4){
			if(this.httpRequest.status == 200){

				this.docXML = this.httpRequest.responseXML;
				code = this.docXML.getElementsByTagName("code").item(0).firstChild.nodeValue;	// 결과코드
				message = this.docXML.getElementsByTagName("message").item(0).firstChild.nodeValue;	// 리턴메시지

				alert(message);
			}
		}
	}	// end scrapResult function

}	// end scrap Class

var scrap = new scrap();


//-->
