DPMe2Post = {
	busy: false,

	write: function(id, pw, post_body, post_tags) {
		if( DPMe2Post.busy ) {
			return;
		}

		var url = '../php/write_post.php';
		var data = 'url=http://me2day.net/api/create_post/' + id + '.xml' + 
				   '&id=' + id +
				   '&pw=' + pw +
				   '&post_body=' + post_body +
				   '&post_tags=' + post_tags;
				   //alert(data);
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Post.callback, data);
		DPMe2Post.busy = true;
	},

	handleSuccess: function(o) {
		DPMe2Post.onSuccess(o);
		DPMe2Post.busy = false;
	},

	onSuccess: function(o) {
	},

	handleFailure: function(o) {
		DPMe2Post.onFailure(o);
		DPMe2Post.busy = false;
	},

	onFailure: function(o) {
	}
};

DPMe2Post.callback = {
	success: DPMe2Post.handleSuccess,
	failure: DPMe2Post.handleFailure,
	scope: DPMe2Post
};

/////////////////////////////////////////////////////////////////////////////////////////

DPMe2Comment = {
	busy: false,

	write: function(id, pw, post_body, post_id) {
		if( DPMe2Comment.busy ) {
			return;
		}

		var url = '../php/write_comment.php';
		var data = 'url=http://me2day.net/api/create_comment/' + id + '.xml' + 
				   '&id=' + id +
				   '&pw=' + pw +
				   '&post_body=' + post_body +
				   '&post_id=' + post_id;
				   //alert(data);
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Comment.callback, data);
		DPMe2Comment.busy = true;
	},

	handleSuccess: function(o) {
		DPMe2Comment.onSuccess(o);
		DPMe2Comment.busy = false;
	},

	onSuccess: function(o) {
	},

	handleFailure: function(o) {
		DPMe2Comment.onFailure(o);
		DPMe2Comment.busy = false;
	},

	onFailure: function(o) {
	}
};

DPMe2Comment.callback = {
	success: DPMe2Comment.handleSuccess,
	failure: DPMe2Comment.handleFailure,
	scope: DPMe2Comment
};

/////////////////////////////////////////////////////////////////////////////////////////

DPMe2Score = {
	busy: false,

	state: '',

	setScore: function(user, score, level) {
		if( DPMe2Score.busy ) {
			return;
		}

		var url = '../php/setScore.php';
		var data = 'user=' + user + '&score=' + score + '&level=' + level;
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Score.callback, data);
		DPMe2Score.state = 'set';
		DPMe2Score.busy = true;
	},

	getScore: function(level) {
		DPMe2Score.getTodayScore(level);
	},

	getTodayScore: function(level) {
		if( DPMe2Score.busy ) {
			return;
		}

		var url = '../php/getScore.php';
		var data = 'level=' + level;
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Score.callback, data);
		DPMe2Score.state = 'get';
		DPMe2Score.busy = true;
	},

	getTotalScore: function(level) {
		if( DPMe2Score.busy ) {
			return;
		}

		var url = '../php/getTotalScore.php';
		var data = 'level=' + level;
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Score.callback, data);
		DPMe2Score.state = 'get';
		DPMe2Score.busy = true;
	},

/*
	initScore: function() {
		if( DPMe2Score.busy ) {
			return;
		}

		var url = 'http://ideapool.co.kr/me2day/minesweeper/php/initScore.php';
		var data = '';
		YAHOO.util.Connect.asyncRequest("POST", url, DPMe2Score.callback, data);
		DPMe2Score.state = 'init';
		DPMe2Score.busy = true;
	},
*/
	handleSuccess: function(o) {
		switch( DPMe2Score.state ) {
		case 'set':
			DPMe2Score.onSet(o);
			break;
		case 'get':
			DPMe2Score.onGet(o)
			break;
		case 'init':
			DPMe2Score.onInit(o);
			break;
		}

		DPMe2Score.busy = false;
	},

	onSet: function(o) {
	},

	onGet: function(o) {
		alert(o.responseText);
	},

	onInit: function(o) {
	},

	handleFailure: function(o) {
		switch( DPMe2Score.state ) {
		case 'set':
			break;
		case 'get':
			break;
		case 'init':
			break;
		}

		DPMe2Score.busy = false;
	}
};

DPMe2Score.callback = {
	success: DPMe2Score.handleSuccess,
	failure: DPMe2Score.handleFailure,
	scope: DPMe2Score
};

/////////////////////////////////////////////////////////////////////////////////////////

DPFileExist = {
	busy: false,

	query: function(filepath) {
		if( DPFileExist.busy ) {
			return;
		}

		var url = '../php/isFile.php?filepath=' + filepath;
		YAHOO.util.Connect.asyncRequest("GET", url, DPFileExist.callback);
		DPFileExist.busy = true;
	},

	handleSuccess: function(o) {
		DPFileExist.busy = false;
		DPFileExist.onSuccess(o);
	},

	onSuccess: function(o) {
	},

	handleFailure: function(o) {
		DPFileExist.busy = false;
		DPFileExist.onFailure(o);
	},

	onFailure: function(o) {
	}
};

DPFileExist.callback = {
	success: DPFileExist.handleSuccess,
	failure: DPFileExist.handleFailure,
	scope: DPFileExist
};

