﻿/*  
* User
*/

$(document).ready(function() {
   $(".showUCardNumberDetail").hover(function(){$(".uCardNumberDetail").show();},function(){$(".uCardNumberDetail").hide();});
    $("#mySaveSubBar .sTitle").toggle(function(){ $(this).children('span').html('+');$(this).next().hide();},function(){$(this).children('span').html('-');$(this).next().show();});
    $("#addFollow").click(function(){addNewFollow(this.name);});
    $("#getAboutMe").hover(function(){$("#aboutMeDetail").show();},function(){$("#aboutMeDetail").hide();});
    $("#getContact").hover(function(){$("#contactDetail").show();},function(){$("#contactDetail").hide();});
        
    editMyBlogTag();
 });
 
 function postContentLoginCheck(){
     $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        dialogJSBox("发表随记","../User/js/userPost.js",function(){PostContentInit();});            
       }
    });
 }
 
 function addNewFollow(userId)
 {
    $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        $.getJSON("../user/ajaxFollow.ashx",{oper:"addFollow",userId:userId,t:Math.random()},function(json){
            if(json.success)
            {
                alert('添加成功~');
            }
            else
            {
                alert(json.error);
            }
        });         
       }
    });
 }
 
 function editMyBlogTag()
 {
    var d = $("#blogTagBox .edits");
    d.click(function(e){
        e.preventDefault();
        dialogJSBox("编辑我的类别","../User/js/editMyBlogTag.js",function(){myBlogTagInit();});
    });  
 }
 
 function saveBlog(id)
 {
    $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        dialog("收藏","");
        $('#jqmDialog .jqmDialogContent').html("收藏中，请稍等...");
        $.getJSON("../user/ajaxBlogEdit.ashx",{oper:"saveBlog",blogId:id,t:Math.random()},function(json){
            if(json.success)
            {
                $('#jqmDialog').jqmHide();
                alert('收藏成功~');
            }
            else
            {
                $('#jqmDialog').jqmHide();
                alert(json.error);
            }
        });         
       }
    });
 }
 
 function repasteBlog(blogId)
 {
    $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        dialogJSBox("分享中...","../User/js/repasteBlog.js",function(){repasteBlogInit(blogId,'0','0');});   //从原文分享nodeId为0        
       }
    });
 }
 
 function repasteBlogRP(blogId,rpId,rpNumber)
 {
    $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        var qs = $.deparam.querystring();
        if(qs.r)
        {
            if(qs.n)
            { 
                rpId = qs.r;
                rpNumber = qs.n;
            }
        }
         
        dialogJSBox("分享中...","../User/js/repasteBlog.js",function(){repasteBlogInit(blogId,rpId,rpNumber);});           
       }
    });
 }
 
 function removeMyRepaste(rpId)
 { 
    confirmBox("删除提示：","确定要删除这个分享吗？<br/>(选择<strong>确定</strong>进行删除；选择<strong>取消</strong>不删除。",function(){
     $.getJSON("../user/ajaxBlogEdit.ashx",{oper:"removeMyRepaste",rpId:rpId,t:Math.random()},function(json){
                if(json.success){
                    location.reload();
                }
                else
                {
                    alert(json.error);
                }
            });
    });
 } 
 
 function replyBlog(id,comment,getReply)
 {
    $.getJSON("../user/ajax.ashx",{oper:"checkLogin",t:Math.random()},function(json){
       if(json.error == "nopass"){dialog("e岛网说:你未登陆或登陆时间到啦 :)","../User/uc.aspx?uc=login",function(){});return false;
      }
      else
      {
        dialogJSBox("回应中...","../User/js/replyBlog.js",function(){replyBlogInit(id,comment,getReply);}); 
      }
    });
 }
 
 function removeComment(cId)
 {
    confirmBox("删除提示：","确定要删除这个回应吗？<br/>(选择<strong>确定</strong>进行删除；选择<strong>取消</strong>不删除。",function(){
     $.getJSON("../user/ajaxBlogEdit.ashx",{oper:"removeComment",cId:cId,t:Math.random()},function(json){
                if(json.success){
                    location.reload();
                }
                else
                {
                    alert(json.error);
                }
            });
    });
 } 
