var xmlHttp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
	    xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
	else if (window.XMLHttpRequest) {
	    xmlHttp = new XMLHttpRequest();
	}
}

function startRequest(opid,idx,action) {
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	var url = 'http://localen.donga.com/opinion/reco.php?opid='+opid+'&opinion_idx='+idx+'&action='+action;
	xmlHttp.open('GET', url, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlHttp.send(null);
}

function handleStateChange() {
	var ret_res;
	if(xmlHttp.readyState == 4) {
	    if(xmlHttp.status == 200) {
	        ret_res = xmlHttp.responseText;
			switch(ret_res) {
				case '100' :
					alert('로그인 하여 주시기 바랍니다.');
					gourl = location.href;
					window.location.href='http://www.donga.com/members/login.php?gourl='+escape(gourl);;
					break;
				case '200' :
					alert('거부되셨습니다.');
					break;
				case '300' :
					alert('이미 참여 하셨습니다.');
					break;
				case '400' :
					alert('참여해 주셔서 감사합니다.');
					window.location.reload();
					break;
				default :
					alert('잠시후 다시 이용하여 주시기 바랍니다.');
					break;
			}
	    }
	}
}