var is_ajax_debug = false;

function getAjaxData(URL,params,func, interID)
{
	var myAjax = new Ajax.Request( URL,
		{
			asynchronous: true,
			method: "post",
			parameters: params,
			onSuccess: function(xmlHttp){
				try {
					var data = eval("(" + xmlHttp.responseText + ")");

					if(!ajaxReturnErrorCheck(data)) return;
				} catch(e) {
					var errorObj = {
						'e':e,
						'x':xmlHttp
					};
					ajax_debug(errorObj);
					return;
				}
				func(data);
			},
			onFailure : function (request)
			{
				func("FAIL");
				return;
			}
		}
	);
}

function doAjax(URL,pars,func)
{
	var myAjax = new Ajax.Request( URL,
		{
			parameters: pars,
			onSuccess: function(xmlHttp){
				func.call();
			}
		}
	);
}

function ajax_debug(data) {
	if(is_ajax_debug) {
		alert('AjaxCall : ' + data.e + ' - ' + data.x.responseText);
	}
}

function ajaxReturnErrorCheck(data) {
	if(data.resultCode == 'ERROR') {
		Common._closeBackGround();
		if(data.message) alert(data.message.replace(/\\n/gi, "\n"));

		if(data.result == 'not login') {
			Common.goHome();
		}
		else if(data.result == 'memo list') {
			document.location.href = Common.getRoot() + "memo/memomain/memomain_list";
		}

		return false;
	}

	return true;
}

