
/*	
	IFを拡張
*/
(
	function() {
		
		/*---------------------------------------------------------------------------------------------------------
			コンストラクタ
		--------------------------------------------------------------------------------------------------------- */
		$.myIF = function(){};
		$.myIF.prototype = $.extend({}, $.superIF.prototype, {
			
			
		});
		
				
		var P = $.myIF.prototype;
		P.cgiURL = "php/entry.php?callback=?";
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.getPIVOT = function(callBack) {
			//サーバと通信
			this.doIF(
			{
			
				action : "getPIVOT"
		
			}, function(d) {
				
				callBack(d);
			});	
		}
		
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.loginCheck = function(callBack) {
			//サーバと通信
			this.doIF(
			{
			
				action : "loginCheck"
		
			}, function(d) {
				
				callBack(d);
			});	
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.login = function(mail,callBack) {
		
			var alertStr = "";
			
			if(!mail || mail.indexOf("@") == -1) {
				alertStr += "メールアドレスをいれてください\n";
				
			}
			
			if(alertStr)
			{
				callBack({alertStr:alertStr});
				return;
			}
			
			//サーバと通信
			this.doIF(
			{
			
				action : "login",
				mail:mail
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.logout = function(callBack) {
		
			
			//サーバと通信
			this.doIF(
			{
			
				action : "logout"
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.regist = function(name, mail,callBack) {
		
			var alertStr = "";
				
			if(mail.indexOf("@") == -1) alertStr += "メールアドレスをいれてください\n";
			if(!name) alertStr += "なまえをいれてください\n";
			if(alertStr)
			{
				callBack({alertStr:alertStr});
				return;
			}
			
			//サーバと通信
			this.doIF(
			{
			
				action : "regist",
				mail:mail,
				name : name
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		
		
		/*---------------------------------------------------------------------------------------------------------*/
		//初期データ取得
		P.getInitData = function(callBack) {
			
			
			//サーバと通信
			this.doIF(
			{
			
				action : "getInitData"
		
			}, function(d) {
				
				callBack(d);
			});
		}

		/*---------------------------------------------------------------------------------------------------------*/
		//member_id　指定メールアドレスのユーザの投稿のみを返却 event_id　指定イベントのみ取得する場合指定
		P.getPost = function(member_id, event_id, callBack) {
			
			if(!member_id) member_id = "";
			if(!event_id) event_id = "";
			
			//サーバと通信
			this.doIF(
			{
			
				action : "getPost",
				member_id : member_id,
				event_id : event_id
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.getLatestPost = function(event_id, callBack) {
			
			if(!event_id) event_id = "";
			
			//サーバと通信
			this.doIF(
			{
			
				action : "getLatestPost",
				event_id : event_id
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.good = function(member_id, eventpost_id, callBack) {
			
			
			
			//サーバと通信
			this.doIF(
			{
			
				action : "good",
				member_id : member_id,
				eventpost_id : eventpost_id
		
			}, function(d) {
				
				callBack(d);
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		P.getEvent = function(event_id, callBack) {
			
			//サーバと通信
			this.doIF(
			{
			
				action : "getEvent",
				event_id : event_id
		
			}, function(d) {
				
				callBack(d);
			});
			
		}
		
		
		
		/*---------------------------------------------------------------------------------------------------------*/
		//イベントの情報変更
		P.updateEvent = function(event_id, p, callBack) {
			
			//complete, date, des, title,
			var alertStr = "";			
			
			if(alertStr) {
				alert("送信パラメータエラー \n "+alertStr);
				return;
			}
			
			var sendP = {};
			sendP.action = "updateEvent";
			sendP.event_id = event_id;
			for(var item in p){
				sendP[item] = p[item];
			}
			
			//サーバと通信
			this.doIF(
			sendP,
			function(d) {
				
				if(callBack) callBack(d);
				
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		//イベントの情報変更
		P.delEvent = function(event_id,callBack) {
			
			//complete, date, des, title,
			var alertStr = "";			
			if(!event_id) alertStr += "event_idが不明さ";
			
			if(alertStr) {
				alert("送信パラメータエラー \n "+alertStr);
				return;
			}
			
			var sendP = {};
			sendP.action = "delEvent";
			sendP.event_id = event_id;
			
			
			//サーバと通信
			this.doIF(
			sendP,
			function(d) {
				
				if(callBack) callBack(d);
				
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		//イベントコメントの情報変更（eventcom_idがなければレコード追加）
		P.updateEventComment = function(eventcom_id, p, callBack) {
			
			//complete, date, des, title,
			var alertStr = "";			
			
			if(alertStr) {
				alert("送信パラメータエラー \n "+alertStr);
				return;
			}
			
			var sendP = {};
			sendP.action = "updateEventComment";
			sendP.eventcom_id = eventcom_id;
			for(var item in p){
				sendP[item] = p[item];
			}
			
			//サーバと通信
			this.doIF(
			sendP,
			function(d) {
				
				if(callBack) callBack(d);
				
			});
		}
		
		
		
		/*---------------------------------------------------------------------------------------------------------*/
		//イベントの参加トグル
		P.updateEventMember = function(member_id, event_id, joinstatus_id, callBack) {
			
			//complete, date, des, title,
			var alertStr = "";			
			
			if(alertStr) {
				alert("送信パラメータエラー \n "+alertStr);
				return;
			}
			
			var sendP = {};
			sendP.action = "updateEventMember";
			sendP.member_id = member_id;
			sendP.event_id = event_id;
			sendP.joinstatus_id = joinstatus_id;
			
			
			//サーバと通信
			this.doIF(
			sendP,
			function(d) {
				
				if(callBack) callBack(d);
				
			});
		}
		
		/*---------------------------------------------------------------------------------------------------------*/
		//イベントの投稿用アドレスを送信
		P.sendEventPostURL = function(member_id, event_id, callBack) {
			
			var alertStr = "";
			
			
			var sendP = {};
			sendP.action = "sendEventPostURL";
			sendP.member_id = member_id;
			sendP.event_id = event_id;			
			
			//サーバと通信
			this.doIF(
			sendP,
			function(d) {
				
				if(callBack) callBack(d);
				
			});
		}

		
	}
	
)();


