complainStart = function(){
	//this.docXML_FD;				// XMLµ¥ÀÌÅÍ return °ª
	this.callback = null;		// XML°á°ú returnÇÔ¼ö
	this.httpRequest = null;	// httpRequest°´Ã¼
	this.form = null ;                //form °´Ã¼
	
	
	this.ACTION_URL="";
	this.COMPLAIN_ID="";
	this.COMPLAIN_NAME="";
	this.COMPLAIN_TEL="";
	this.COMPLAIN_BODY="";
	this.REQUEST_PAGE="";
	
	//º¯¼ö ÃÊ±âÈ­
	complainStart.prototype.setInitail = function(id, name, tel, body, frm, action, request_page){
		this.COMPLAIN_ID=id;
		this.COMPLAIN_NAME=name;
		this.COMPLAIN_TEL=tel;
		this.COMPLAIN_BODY=body;
		this.form = frm;
		this.ACTION_URL = action;
		this.REQUEST_PAGE = request_page;
	}
	// httpRequest °´Ã¼ »ý¼º ÇÔ¼ö
	complainStart.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;
		}
	}
	
	complainStart.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 ÇÔ¼ö
	complainStart.prototype.onStateChange = function() {
		this.callback(this.httpRequest);
	}	
	
	//µî·Ï	
	complainStart.prototype.input = function(){		
		var params  = "complain_id="+this.COMPLAIN_ID+"&complain_name="+this.COMPLAIN_NAME+"&complain_tel="+this.COMPLAIN_TEL+"&complain_body="+this.COMPLAIN_BODY + "&request_page=" + this.REQUEST_PAGE;
//		/alert(params)		;
			
		this.sendRequest(this.ACTION_URL, params, this.inputResult, "GET");
	}	// end nameCheck function
		
	complainStart.prototype.inputResult = function(){
					
		if(this.httpRequest.readyState == 4){
			if(this.httpRequest.status == 200){
	//			var xmltxt = this.httpRequest.responseText;
	//			alert(xmltxt);
				var xmldoc = this.httpRequest.responseXML;
				var code = xmldoc.getElementsByTagName("code").item(0).firstChild.nodeValue;			// ¼º°ø¿©ºÎ		
				var msg = xmldoc.getElementsByTagName("msg").item(0).firstChild.nodeValue;			// ¸Þ¼¼Áö		
				var email = xmldoc.getElementsByTagName("email").item(0).firstChild.nodeValue;			// ¸Þ¼¼Áö		
				var type = xmldoc.getElementsByTagName("type").item(0).firstChild.nodeValue;			// ¸Þ¼¼Áö		
				if(code == "200"){
					alert(msg);
					document.getElementById("complain_name").value="";
					document.getElementById("complain_tel").value=email;
					document.getElementById("complain_body").value="ÀÚ·á°¡ ¾ø´Â °æ¿ì, ¼­ºñ½º ÀÌ¿ë¿¡ \r\nºÒÆíÇÑ Á¡, ¹Ù¶ó´Â Á¡ °ÇÀÇ»çÇ× µî¿¡ \r\n´ëÇØ ¾Ë·ÁÁÖ¼¼¿ä.";
					COMPLAIN_BODY_CNT=0;
					if(type == "close"){
						self.close();
					}
				}else{
					alert('Á¢¼Ó Àå¾ÖÀÔ´Ï´Ù.\r\n´Ù½ÃÇÑ¹ø ½ÃµµÇØÁÖ¼¼¿ä');
					location.reload();
				}
	
	
			}
		}
	}	// end nameResult function
	
}


var COMPLAIN_BODY_CNT=0;

function goComplain(frm){
	var ACTION_URL ="/report/complain_post.html";
	var id = document.getElementById("complain_id").value;
	var name = document.getElementById("complain_name").value;
	var tel = document.getElementById("complain_tel").value;
	var body = document.getElementById("complain_body").value;
	var request_page = document.getElementById("request_page").value;
	
	var complain = new complainStart();
	
	if(name == ""){
		alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
		document.getElementById("complain_name").focus();
		return false;
	}
	if(tel == "" || tel=="ÀüÈ­¹øÈ£ ¶Ç´Â ÀÌ¸ÞÀÏ ÁÖ¼Ò"){
		alert('ÀüÈ­¹øÈ£ ¶Ç´Â ÀÌ¸ÞÀÏ ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
		document.getElementById("complain_tel").focus();
		return false;
	}
	if(body == "" || COMPLAIN_BODY_CNT==0){
		alert('³»¿ëÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
		document.getElementById("complain_body").focus();
		return false;
	}
	complain.setInitail(id, name, tel, body, frm, ACTION_URL, request_page);
	
	complain.input();
	return false;
	
}