/**
 * Nasp AJAX Object
 *
 */
function nsajax(server)
{
	this.server = server;
}



/**
 * Nasp のコマンドを呼び出す（POST系）
 *
 */
nsajax.prototype.naspExecute = function(command, fdata)
{
	var pbody = "c=" + command + "&" + fdata
	return this.httpPost(pbody);
}



/**
 * Nasp のコマンドを呼び出す（GET系）
 *
 */
nsajax.prototype.naspLoad = function(command, param)
{
	var query = "c=" + command + "&" + param
	return this.httpGet(query);
}



/**
 * HTTP POST
 *
 */
nsajax.prototype.httpPost = function(pbody)
{
	var rd;
	$.ajax({
		dataType: "json",
		async: false,
		type:  "POST",
		url:   this.server,
		data:  pbody,
		success: function(rdata, rstatus) {
			if( rdata.Status == 0 ){
				rd = rdata;
			}else{
				throw(rdata);
			}
		},
		error: function(request, rstatus, err) {
alert(rstatus);
			throw("通信エラー[" + request.status + "]");
		}
	});

	return rd;

}



/**
 * HTTP GET
 *
 */
nsajax.prototype.httpGet = function(query)
{

	var url = this.server + "?" + query;
	var rd;
	$.ajax({
		dataType: "json",
		async:    false,
		type:     "GET",
		url:      url,
		success: function(rdata, rstatus) {
			if( rdata.Status == 0 ){
				rd = rdata;
			}else{
				throw(rdata);
			}
		},
		error: function(request, rstatus, err) {
			throw("通信エラー[" + request.status + "]");
		}
	});

	return rd;

}



