var poke = {

id: null,
user: null,

init: function(u, id) {
   poke.user = u;
   poke.id = id;
},

show: function(u, id) {
   if (!isUserLogined){
      checkLoginAndReturn('javascript:poke.show(\''+u+'\',null)');
      return;
   } 
   poke.init(u, id);
   getConfirmBox(
      '<div style="text-align: center">要戳'+poke.user+'了喔？</div>', 
      17, 'poke.go()');
   funpDlg.show('confirmBox');
},

go: function() {
   funpDlg.close()
   new Ajax.Request(PEOPLE_P+'poke.ajax.php', {
      method: 'post',
      parameters: {'action':'add', 'to':poke.user, 'id':poke.id},
      onSuccess: poke.success,
      onFailure: poke.failure
   });
},

success: function(rs) {
   rsobj = ej(rs.responseText);
   if (rsobj.rs > 0) {
      showAlertBox('戳到了。');
      poke.hide();
   } else {
      poke.failure();
   }
},

failure: function() {
   showAlertBox('一天只能戳一次啊。');
},

hide: function() {
   if (poke.id) Element.remove('poke_'+poke.id);
},

ignore: function(u, id) {
   poke.init(u, id);
   new Ajax.Request(PEOPLE_P+'poke.ajax.php', {
      method: 'post',
      parameters: {'action':'del', 'from':poke.user},
      onSuccess: poke.hide,
      onFailure: poke.hide
   });
}

};
