﻿/*会员动作 - 添加好友*/
function UserAction(friendId,friendName,status,friendStatus){
    if(20 == friendStatus){ 
        ShowActionForm(friendId,friendName,status,friendStatus);
        return false;
    } 
    else{    
        var url = webDir + "/ajax/useraction.aspx";
        var strAction = "action=validatefriendstatus&friendId=" + friendId + "&friendName=" + escape(friendName);
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(result == "22"){
                        friendStatus = 22;
                        PopWin("已经是好友了", "您与 " + ShowUserName(friendName) + " 已经是好友了！", 360, 80, true, 2000, "");
                        return false;
		            }
		            else if(result == "10"){
		                friendStatus = 10;
		                PopWin("加好友", "您的好友请求已经提交，请耐心等待 " + ShowUserName(friendName) + " 的批准。", 360, 80, true, 2000, "");
		                return false;
		            }
		            else if(result == "20"){
		                friendStatus = 20;
		                ShowActionForm(friendId,friendName,status,friendStatus);
		            }
		            else{
		                friendStatus = 0;
		                ShowActionForm(friendId,friendName,status,friendStatus);
		            }
                }
            }
        }    
        return false;
    }    
}
//显示会员信息
function ShowUserName(userName,fontSize){
    fontSize = null ? 14 : fontSize;
    return "<b style=\"color:#005eac;font-size:" + fontSize + "px;\">" + userName + "</b>";
}
/*显示添加好友表单*/
function ShowActionForm(friendId,friendName,status,friendStatus){
    if(20 == friendStatus){
        var content = "<div style=\"line-height:30px;\">批准 <b style=\"color:#005eac;font-size:14px;\">" + 
            friendName + 
            "</b> 的好友请求，并分组" +
            "<br />分组：" + 
            "<select id=\"group\" style=\"z-index:1005;\" class=\"select\">" +
            "   <option value=\"0\">其他</option>" +
            "   <option value=\"1\">通过本站认识</option>" +
            "   <option value=\"2\">通过活动认识</option>" +
            "   <option value=\"3\">通过朋友认识</option>" +
            "   <option value=\"4\">亲人</option>" +
            "   <option value=\"5\">同事</option>" +
            "   <option value=\"6\">同学</option>" +
            "   <option value=\"7\">不认识</option>" +
            "</select>" +
            " <input type=\"button\" onclick=\"AddFriend(" + friendId + ",'" + friendName + "'," + status + "," + friendStatus + ",'');\" value=\"确定\" class=\"btn75\" />" +        
            "</div>";
            
        PopWin("批准请求", content, 360, 180, false, 0, "", true);
    }
    else if(0 == friendStatus){
        var content = "<div style=\"line-height:30px;\">加 <b style=\"color:#005eac;font-size:14px;\">" +
            friendName + 
            "</b> 为好友，附言：<br /><input type=\"text\" id=\"message\" style=\"width:350px; border:solid 1px #ddd;\" maxlength=\"50\" />" + 
            "<br />" + 
            "<span style=\"color:#999;\">(附言为可选，" + ShowUserName(friendName) + " 会看到这条附言，最多为50个字符)</span>" +
            "<br />分组：" + 
            "<select id=\"group\" style=\"z-index:1005;\" class=\"select\">" +
            "   <option value=\"0\">其他</option>" +
            "   <option value=\"1\">通过本站认识</option>" +
            "   <option value=\"2\">通过活动认识</option>" +
            "   <option value=\"3\">通过朋友认识</option>" +
            "   <option value=\"4\">亲人</option>" +
            "   <option value=\"5\">同事</option>" +
            "   <option value=\"6\">同学</option>" +
            "   <option value=\"7\">不认识</option>" +
            "</select>" +
            " <input type=\"button\" onclick=\"AddFriend(" + friendId + ",'" + friendName + "'," + status + "," + friendStatus + ",'message');\" value=\"确定\" class=\"btn75\" />" +        
            "</div>";
            
        PopWin("加好友", content, 360, 180, false, 0, "", true);
    }
}
/*加为好友*/
function AddFriend(friendId,friendName,status,friendStatus,message){
    var group = $I("group");
    if(message != ""){
        message = escape($I("message").value);
    }
    var url = webDir + "/ajax/useraction.aspx";
    var strAction = "action=addfriend&friendName=" + escape(friendName) + "&friendId=" + friendId + 
                ("" == message ? "" : "&message=" + message) + "&groupId=" + group.value + 
                "&status=" + status + "&friendStatus=" + friendStatus;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(parseInt(result,10) > 0){
		            CloseWin();
                    if(friendStatus > 0){
                        PopWin("好友", "恭喜您，您与 " + ShowUserName(friendName) + " 已经是好友了！", 360, 80, true, 2000, "reload");
                    }else{
		                PopWin("加好友", "您的好友请求已经提交，请等待 " + ShowUserName(friendName) + " 批准", 360, 80, true, 2000, "reload");
		            }
		        }
		        else if(result == "-1"){
		            CloseWin();
		            PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		        }
		        else if(result == "-2"){
		            CloseWin();
		            PopWin("加好友", "您的好友请求已经提交，请等待 " + ShowUserName(friendName) + " 的批准。", 360, 80, true, 2000, "reload");
		        }
		        else{
		            CloseWin();
		            PopWin("加好友", "对不起，您的好友请求提交失败，请稍候再试！", 360, 80, true, 2000, "reload");
		        }
            }
        }
    }    
}
/*忽略好友请求*/
function IgnoreFriend(friendId,friendName){    
    if(!confirm("您确定要忽略 " + friendName + " 的好友请求吗？")){
        return false;
    }
    else{
        var url = webDir + "/ajax/useraction.aspx";
        var strAction = "action=ignorefriendrequest&friendId=" + friendId ;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("忽略好友", "您已经忽略了 " + ShowUserName(friendName) + " 的好友请求。", 360, 80, true, 0, "reload");
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else{
		                 PopWin("加好友", "对不起，您的忽略好友请求提交失败，请稍候再试！", 360, 80, true, 2000, "reload");
		            }
                }
            }
        }   
    }
}
/*-----------------会员关注---------------------*/
/*添加会员关注*/
function AddAttention(attentionId,attentionName){
    var url = webDir + "/ajax/useraction.aspx";
    var strAction = "action=addattention&attentionName=" + escape(attentionName) + "&attentionId=" + attentionId;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(parseInt(result,10) > 0){
                    PopWin("您添加了对 " + attentionName + " 的关注，操作成功。", "", 360, 50, true, 2000, "reload");
		        }
		        else if(result == "-1"){
		            PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		        }
		        else if(result == "-2"){
		            PopWin("已关注", "您已经在关注 " + attentionName + " 了。", 360, 80, true, 2000, "reload");
		        }
		        else{
		            PopWin("关注操作失败", "对不起，您对 " + attentionName + " 的关注操作失败，请稍候再试。", 360, 80, true, 2000, "reload");
		        }
            }
        }
    }    
}
/*取消会员关注*/
function CancelAttention(attentionId,attentionName){
    var url = webDir + "/ajax/useraction.aspx";
    var strAction = "action=cancelattention&attentionName=" + escape(attentionName) + "&attentionId=" + attentionId;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(parseInt(result,10) > 0){
                    PopWin("关注已取消", "恭喜您，您取消了对 " + attentionName + " 的关注。", 360, 80, true, 2000, "reload");
		        }
		        else if(result == "-1"){
		            PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		        }
		        else{
		            PopWin("关注取消失败", "对不起，您对 " + attentionName + " 的关注取消失败，请稍候再试。", 360, 80, true, 2000, "reload");
		        }
            }
        }
    }    
}
/*--------------------相册------------------------*/
function BuildAlbum(uid){
    var content = ShowBuildAlbumForm(uid,0,"");
    PopWin("创建相册", content, 400, 300, false, 0, "");
}
function EditAlbum(uid,albumId){
    PopWin("正在加载", "正在加载数据，请稍候...", 400, 80, false, 0, "");
    var url = webDir + "/ajax/userinfo.aspx";
    var strAction = "action=editalbum&userId=" + uid + "&albumId=" + albumId;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(result != "null"){                    
                    var content = ShowBuildAlbumForm(uid,albumId,result);
                    CloseWin();
                    var arrV = new Array();    
                    arrV = result.split("|");                    
                    PopWin("编辑相册", content, 400, arrV[3] == "3" ? 360 : 300, false, 0, "");
		        }
		        else if(result == "-1"){
                    CloseWin();
		            PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		        }
		        else{
                    CloseWin();
		            PopWin("未能加载数据", "对不起，您暂时无法编辑相册，<br />可能服务器正忙，请稍候再试。", 360, 80, true, 2000, "");
		        }
            }
        }
    }    
}

/*显示相册创建、编辑表单*/
function ShowBuildAlbumForm(uid,albumId,arrValue){
    var arrV = new Array();    
    if(albumId > 0 && arrValue != ""){
        arrV = arrValue.split("|");
    }else{
        arrV[0] = "";  //名称
        arrV[1] = "";  //描述
        arrV[2] = "1"; //分类
        arrV[3] = "1"; //访问权限
        arrV[4] = "1"; //分享
        arrV[5] = "1"; //评论
        arrV[6] = "";  //问题
        arrV[7] = "";  //答案
    }
    var content = "<div style=\"line-height:24px;font-size:12px;\">" +
        "<table cellpadding=\"0\" cellspacing=\"0\" class=\"tableform\">" + 
        "   <tr>" + 
        "       <td valign=\"top\">相册名称：</td>" + 
        "       <td><input type=\"text\" id=\"txtAlbumName\" style=\"width:270px; border:solid 1px #ddd;\" maxlength=\"30\" onkeyup=\"ShowWordCount(this,$I('wc1'),30,$I('lblName'));\" value=\"" + arrV[0] + "\"/> <b id=\"wc1\">0</b>/30" + 
        "           <label id=\"lblName\" class=\"lbl\" style=\"height:15px;\"></label>" +
        "       </td></tr>" +
        "   <tr>" + 
        "       <td valign=\"top\">相册描述：<span class=\"explain\">（非必填）</span></td>" + 
        "       <td valign=\"top\">" + 
        "           <textarea type=\"text\" id=\"txtAlbumDesc\" style=\"width:271px; height:60px; border:solid 1px #ddd;font-size:12px; line-height:15px;\" maxlength=\"200\" onkeyup=\"ShowWordCount(this,$I('wc2'),200,$I('lblDesc'));\" >" + arrV[1] + "</textarea> <b id=\"wc2\">0</b>/200" + 
        "           <label id=\"lblDesc\" class=\"lbl\" style=\"height:15px;\"></label></td>" +
        "   </tr>" +
        "   <tr>" + 
        "       <td>相册分类：</td>" + 
        "       <td>" +
        "           <select id=\"albumSort\"  class=\"select\">" +
        "               <option value=\"1\"" + (arrV[2] == "1" ? " selected=\"selected\" " : "") + ">最爱</option>" +
        "               <option value=\"2\"" + (arrV[2] == "2" ? " selected=\"selected\" " : "") + ">人物</option>" +
        "               <option value=\"3\"" + (arrV[2] == "3" ? " selected=\"selected\" " : "") + ">风景</option>" +
        "               <option value=\"4\"" + (arrV[2] == "4" ? " selected=\"selected\" " : "") + ">动物</option>" +
        "               <option value=\"5\"" + (arrV[2] == "5" ? " selected=\"selected\" " : "") + ">游记</option>" +
        "               <option value=\"6\"" + (arrV[2] == "6" ? " selected=\"selected\" " : "") + ">卡通</option>" +
        "               <option value=\"7\"" + (arrV[2] == "7" ? " selected=\"selected\" " : "") + ">生活</option>" +
        "               <option value=\"8\"" + (arrV[2] == "8" ? " selected=\"selected\" " : "") + ">其他</option>" +
        "           </select>" +
        "       </td>" +
        "   </tr>" +
        "   <tr>" + 
        "       <td>谁能访问：</td>" +         
        "       <td>" +
        "           <label for=\"rbp1\"><input id=\"rbp1\" type=\"radio\" name=\"rbp\" value=\"1\"" + (arrV[3] == "1" ? " checked=\"checked\" " : "") + "onclick=\"showQuestion(1);\"/>所有人</label> " +
        "           <label for=\"rbp2\"><input id=\"rbp2\" type=\"radio\" name=\"rbp\" value=\"2\"" + (arrV[3] == "2" ? " checked=\"checked\" " : "") + " onclick=\"showQuestion(2);\"/>全部好友</label> " +
        "           <label for=\"rbp3\"><input id=\"rbp3\" type=\"radio\" name=\"rbp\" value=\"3\"" + (arrV[3] == "3" ? " checked=\"checked\" " : "") + " onclick=\"showQuestion(3);\"/>回答问题</label> " +
        "           <label for=\"rbp4\"><input id=\"rbp4\" type=\"radio\" name=\"rbp\" value=\"4\"" + (arrV[3] == "4" ? " checked=\"checked\" " : "") + " onclick=\"showQuestion(4);\"/>仅自己</label> " +
        "       </td>" +
        "   </tr>" +
        (arrV[3] == "3" ? "<tr id=\"qa\">" : "<tr id=\"qa\" style=\"display:none;\">") + 
        "       <td> </td>" +         
        "       <td>" +
        "           问题：<input type=\"text\" id=\"txtQuestion\" style=\"width:235px; border:solid 1px #ddd;\" maxlength=\"20\" onkeyup=\"ShowWordCount(this,$I('wc3'),20,$I('lblQuestion'));\" value=\"" + arrV[6] + "\"/> <b id=\"wc3\">0</b>/20" +   
        "           <br />" +
        "           答案：<input type=\"text\" id=\"txtAnswer\" style=\"width:235px; border:solid 1px #ddd;\" maxlength=\"20\" onkeyup=\"ShowWordCount(this,$I('wc4'),20,$I('lblQuestion'));\" value=\"" + arrV[7] + "\"/> <b id=\"wc4\">0</b>/20" +
        "           <label id=\"lblQuestion\" class=\"lbl\" style=\"height:15px;\"></label></td>" +
        "       </td>" +
        "   </tr>" +
        "   <tr>" + 
        "       <td valign=\"top\">其他权限：</td>" +         
        "       <td>" +
        "           <label for=\"chbShare\"><input id=\"chbShare\" type=\"checkbox\"" + (arrV[4] == "1" ? " checked=\"checked\" " : "") + "/><span id=\"sse\">允许转载和分享</span></label>" +  
        "           <br />" +
        "           <label for=\"chbComment\"><input id=\"chbComment\" type=\"checkbox\"" + (arrV[5] == "1" ? " checked=\"checked\" " : "") + "/>允许会员评论" +
        "       </td>" +
        "   </tr>" +
        "   <tr>" + 
        "       <td> </td>" +         
        "       <td style=\"padding-top:10px; text-align:right;\">" +
        "           <input type=\"button\" onclick=\"return AddAlbum(" + uid + "," + albumId + ");return false;\" value=\"确定\" class=\"btn65\" /> " +
        "           <input type=\"button\" onclick=\"CloseWin();\" value=\"取消\" class=\"btn65\" />" +
        "       </td>" +
        "   </tr>" +
        "</table>" +
        "</div>";
        return content;
}

function showQuestion(num){
    var share = $I("chbShare");
    var sse = $I("sse");
    var qa = $I("qa");
    var ssetxt = "允许转载和分享";
    var ssetxt1 = "（加密相册不可转载和分享）";
    switch(num){
        case 1:
            share.disabled = false;
            sse.innerHTML = ssetxt;
            sse.style.color = "#000";
            qa.style.display = "none";
            ChangeWinSize(400,300);
            break;
        case 3:
            share.disabled = true;
            share.checked = false;
            sse.innerHTML = ssetxt + ssetxt1;
            sse.style.color = "#999";
            qa.style.display = "";
            ChangeWinSize(400,360);
            break;
        case 2:
        case 4:
        case 5:
            share.disabled = true;
            share.checked = false;
            sse.innerHTML = ssetxt + ssetxt1;
            sse.style.color = "#999";
            qa.style.display = "none";
            ChangeWinSize(400,300);
            break;
    }
}
/*创建相册、修改相册*/
/*albumId=0：创建；albumId>0：修改*/
function AddAlbum(uid,albumId){
    var albumName = $I("txtAlbumName");
    var albumDesc = $I("txtAlbumDesc");
    var albumSortId = $I("albumSort").value;
    var txtQuestion = $I("txtQuestion");
    var txtAnswer = $I("txtAnswer");
    var chbShare = $I("chbShare");
    var chbComment = $I("chbComment");
    var isShare = chbShare.checked == true ? 1 : 0;    
    var isComment = chbComment.checked == true ? 1 : 0;    
    var popedomId = 0;
    
    var rbps = $N("rbp");
    for(var i=0; i<rbps.length; i++){
        if(rbps[i].checked == true){
            popedomId = rbps[i].value;
        }
    }
    var lblName = $I("lblName");
    var lblDesc = $I("lblDesc");
    var lblQuestion = $I("lblQuestion");
    if(albumName.value.trim().equals("")){
        lblName.innerHTML  = "相册名称不能为空！"; albumName.focus(); return false;
    }
    else if(!ShowWordCount(albumName,$I('wc1'),30,lblName)){ return false; }
    else if(!ShowWordCount(albumDesc,$I('wc2'),200,lblDesc)){  return false; }
    else if(popedomId == 3 && txtQuestion.value.trim().equals("")){
        lblQuestion.innerHTML  = "请输入问题！"; txtQuestion.focus(); return false;
    } 
    else if(!ShowWordCount(txtQuestion,$I('wc3'),20,lblQuestion)){ return false; }
    else if(popedomId == 3 && txtAnswer.value.trim().equals("")){
        lblQuestion.innerHTML  = "请输入答案！"; txtAnswer.focus(); return false;
    } 
    else if(!ShowWordCount(txtAnswer,$I('wc4'),20,lblQuestion)){ return false; }
    else{        
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=addalbum&albumName=" + escape(albumName.value.trim()) + "&albumDesc=" + escape(albumDesc.value.trim()) + 
                "&albumSortId=" + albumSortId + "&popedomId=" + popedomId + "&isShare=" + isShare + "&isComment=" + isComment +
                "&question=" + escape(txtQuestion.value.trim()) + "&answer=" + escape(txtAnswer.value.trim());
        if(albumId > 0){
            strAction = "action=updatealbum&albumName=" + escape(albumName.value.trim()) + "&albumDesc=" + escape(albumDesc.value.trim()) + 
                "&albumSortId=" + albumSortId + "&popedomId=" + popedomId + "&isShare=" + isShare + "&isComment=" + isComment +
                "&question=" + escape(txtQuestion.value.trim()) + "&answer=" + escape(txtAnswer.value.trim()) + "&albumId=" + albumId;
        }
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    var lable = albumId > 0 ? "修改" : "创建";
                    if(parseInt(result,10) > 0){
                        var content = "恭喜您，相册 [<b>" + albumName.value + "</b>] 已创建成功。<br />是否马上上传照片到这个相册？<br /><br />" +
                            "<input type=\"button\" onclick=\"location.href='" + webUserUrl + "/" + uid + "/album/" + result + "/';\" class=\"btnsubmit\" value=\"上传照片\" /> " +
                            "<input type=\"button\" onclick=\"CloseWin();window.location.reload();\" class=\"btncancel\" value=\"暂不上传\" />";
                        if(albumId > 0){
		                    CloseWin(); PopWin("相册" + lable + "成功", "", 360, 80, true, 2000, "reload");
                        }else{
		                    CloseWin(); PopWin("相册" + lable + "成功", content, 360, 180, false, 2000, "reload");                        
                        }
		            }
		            else if(result == "-1"){
		                CloseWin(); PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else if(result == "-2"){		                
		                PopWin("相册已存在！", "对不起，该相册已存在，请换另外的相册名称。", 400, popedomId==3 ? 360 : 300, true, 2000, "");
		            }
		            else{
		                CloseWin(); PopWin("相册" + lable + "失败", "对不起，相册" + lable + "失败，请稍候再试。", 360, 80, true, 2000, "reload");
		            }
                }
            }
        }    
    }
}
function DeleteAlbum(userId, albumId){
    if(confirm("删除相册后，该相册中的照片将归到“个人相册”相册下，此操作不可恢复，您确定要继续吗？")){
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=deletealbum&albumId=" + albumId;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("相册删除成功。", "", 200, 30, true, 2000, "reload");
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else{
		                PopWin("相册删除失败，请稍候再试。", "", 260, 30, true, 2000, "reload");
		            }
                }
            }
        }    
    }
}
/*-----------日志-------------*/
function BuildBlog(uid){
    var content = ShowBuildBlogForm(uid,0,"");
    PopWin("添加日志分类", content, 400, 100, false, 0, "");
}
function EditBlog(uid,blogId,blogName){    
    var content = ShowBuildBlogForm(uid,blogId,blogName);              
    PopWin("编辑日志分类", content, 400, 100, false, 0, "");
}

/*显示日志分类创建、编辑表单*/
function ShowBuildBlogForm(uid,blogId,blogName){
    
    var content = "<div style=\"line-height:24px;font-size:12px;\">" +
        "<table cellpadding=\"0\" cellspacing=\"0\" class=\"tableform\">" + 
        "   <tr>" + 
        "       <td valign=\"top\">分类名称：</td>" + 
        "       <td><input type=\"text\" id=\"txtBlogName\" style=\"width:150px; border:solid 1px #ddd;\" maxlength=\"12\" onkeyup=\"ShowWordCount(this,$I('wc1'),12,$I('lblName'));\" value=\"" + blogName + "\"/> <b id=\"wc1\">0</b>/12 (最多12个字母或6个汉字)" + 
        "           <label id=\"lblName\" class=\"lbl\" style=\"height:15px;\"></label>" +
        "       </td></tr>" +
        "   <tr>" + 
        "       <td> </td>" +         
        "       <td style=\"text-align:right;\">" +
        "           <input type=\"button\" onclick=\"return AddBlog(" + uid + "," + blogId + ");return false;\" value=\"确定\" class=\"btn65\" /> " +
        "           <input type=\"button\" onclick=\"CloseWin();\" value=\"取消\" class=\"btn65\" />" +
        "       </td>" +
        "   </tr>" +
        "</table>" +
        "</div>";
        return content;
}
function AddBlog(uid,blogId){
    var txtBlogName = $I("txtBlogName");
    var lblName = $I("lblName");
    if(txtBlogName.value.trim().equals("")){
        lblName.innerHTML  = "分类名称不能为空！"; txtBlogName.focus(); return false;
    }
    else if(!ShowWordCount(txtBlogName,$I('wc1'),12,lblName)){ return false; }
    else{        
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=addblog&blogName=" + escape(txtBlogName.value.trim());
        if(blogId > 0){
            strAction = "action=updateblog&blogName=" + escape(txtBlogName.value.trim()) + "&blogId=" + blogId;
        }
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    var lable = blogId > 0 ? "修改" : "添加";
                    if(parseInt(result,10) > 0){
                        if(blogId > 0){
		                    CloseWin(); PopWin("修改日志分类成功！", "", 260, 30, true, 2000, "reload");
                        }else{
		                    CloseWin(); PopWin("添加日志分类成功！", "", 260, 30, true, 2000, "reload");                        
                        }
		            }
		            else if(result == "-1"){
		                CloseWin(); PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else if(result == "-2"){		                
		                PopWin("日志分类已存在！", "对不起，该日志分类已存在，请换另外的日志分类名称。", 400, 100, true, 2000, "");
		            }
		            else{
		                CloseWin(); PopWin("日志分类" + lable + "失败", "对不起，日志分类" + lable + "失败，请稍候再试。", 360, 80, true, 2000, "reload");
		            }
                }
            }
        }    
    }
}
/*删除日志分类*/
function DeleteBlog(userId, blogId){
    if(confirm("删除分类后，该分类内容将归到“个人日记”分类下，此操作不可恢复，您确定要继续吗？")){
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=deleteblog&blogId=" + blogId;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("日志分类删除成功", "", 240, 30, true, 2000, "reload", false);
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else{
		                PopWin("日志分类删除失败，请稍候再试。", "", 300, 30, true, 2000, "reload", false);
		            }
                }
            }
        }    
    }
}
function AddArticle(){
    CopyToHtmlBox();
    var txtArticleName = $I("txtArticleName");// == null ? $I("ctl00_CPHRight_txtArticleName") : $I("txtArticleName");
    var txtArticleContent = $I("txtArticleContent");// == null ? $I("ctl00_CPHRight_txtArticleContent") : $I("txtArticleContent");
    var TextEdit = $I("TextEdit");
    txtArticleContent.value = TextEdit.value;
    
    if(txtArticleName.value.trim().equals("")){
        lblPrompt.innerHTML  = "请输入日志标题！"; txtArticleName.focus(); return false;
    }
    else if(txtArticleContent.value.trim().equals("")){
        lblPrompt.innerHTML  = "请输入日志内容！";  return false;
    }
    else{  
        if(isMSIE){ 
            $I("btnPublish").click();
        }else{
            $I("btnPublish").click();
        }
        return true;
    }
}
function InsertSubject(){
    var txtSubject = $I("txtSubject");
    var obj = $I("txtFindContent");
    if(txtSubject.value.trim().equals("")){    
        txtSubject.focus(); return false;
    }
    InsertAtCaret(obj,"#" + txtSubject.value.trim() + "#");
    CloseWin();
}
function ShowSubject(obj){
    var content = "输入主题：<input type=\"text\" id=\"txtSubject\" class=\"txt\" style=\"width:180px;\" maxlength=\"20\" /> <input type=\"button\" class=\"btn65\" value=\"确定\" onclick=\"InsertSubject();\" />";
    PopWin("输入主题", content, 360, 80, false, 2000, "", true);   
    
    var txtSubject = $I("txtSubject");
    txtSubject.focus();
}
function InsertPicture(uid) {
    var url = "/uc/upload/ftb.imagegalleryfind.aspx?uid=" + uid;
    var str = showModalDialog(url, "", "dialogWidth:560px;dialogHeight:300px;scroll:no;status:0;help:0");
    if(str != null && str != "undefind"){   
        $I("txtImagePath").value = str;  
        $I("lblImagePath").innerHTML = str;
    } 
}
function AddNewFind(uid,txtLen,findId){
    if(uid == 0){
        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
        return false;
    }
    var findSort = $I("findSort");
    var txtFindTitle = $I("txtFindTitle");
    var txtFindContent = $I("txtFindContent");
    var txtImagePath = $I("txtImagePath");
    var lblPrompt = $I("lblPrompt");
    var lblWC =  $I("lblWC");
    
    if(txtFindTitle.value.trim().equals("")){
        lblPrompt.innerHTML = "请输入标题！";
        txtFindTitle.focus(); return false;
    }
    else if(!ShowWordCount(txtFindTitle,lblWC,50,lblPrompt)){
        lblPrompt.innerHTML = "标题字数不得超过" + 50 + "个字符。";
        txtFindTitle.focus(); return false;
    }
    else if(findSort.value == 0){
        lblPrompt.innerHTML = "请选择分类！"; 
        findSort.focus(); return false;
    }
    else if(txtFindContent.value.trim().equals("")){
        lblPrompt.innerHTML = "请输入内容！";
        txtFindContent.focus(); return false;
    }
    else if(!ShowWordCount(txtFindContent,lblWC,txtLen,lblPrompt)){
        lblPrompt.innerHTML = "内容字数不得超过" + txtLen + "个字符。";
        txtFindContent.focus(); return false;
    }
    else{      
        PopWin("正在提交，请稍候...", "", 200, 30, false, 2000, "",false);   
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=addfind&findTitle=" + escape(txtFindTitle.value.trim()) + "&findContent=" + escape(txtFindContent.value.trim()) + 
            "&findSortId=" + findSort.value + "&imagePath=" + txtImagePath.value;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    CloseWin();
                    if(parseInt(result,10) > 0){
                        PopWin("新鲜事发表成功", "", 200, 30, true, 2000, webUserUrl + "/" + uid + "/find/", false);
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else if(result == "-20"){
		                PopWin("新鲜事发表失败！", "对不起，每天最多只能发表20篇新鲜事，<br />您今天已经发表了20篇新鲜事了，请您明天再发表，<br />敬请谅解。", 360, 120, true, 2000, "", false);
		            }
		            else{
		                PopWin("新鲜事发表失败，请稍候再试。", "", 260, 30, true, 2000, "", false);
		            }
                }
            }
        }    
    }
}
function HiddenNewFind(uid,findId,findSortId,isShow,score){      
    if(!confirm("确定要隐藏这个新鲜事吗？")) return false;
    PopWin("正在提交，请稍候...", "", 200, 30, false, 2000, "",false);   
    var url = webDir + "/ajax/userinfo.aspx";
    var strAction = "action=hiddenfind&findId=" + findId + "&findSortId=" + findSortId + 
        "&isShow=" + isShow + "&score=" + score + "&masterId=" + uid;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                CloseWin();
                if(parseInt(result,10) > 0){
                    PopWin("新鲜事已隐藏，经验值已扣除", "", 280, 30, true, 2000, "reload", false);
	            }
	            else{
	                PopWin("操作失败，请稍候再试。", "", 260, 30, true, 2000, "", false);
	            }
            }
        }
    }
}

//新鲜事好评(真新鲜)
function AddUserFindTop(findId,uid,masterId,masterName){
    if(uid <= 0){
        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
        return false;
    }
    else if(masterId <= 0){
        return false;
    }
    else if(uid == masterId){
         PopWin("您不能给自己加“真新鲜”。", "", 260, 30, true, 2000, "", false);
        return false;
    }
    
    PopWin("正在提交，请稍候...", "", 200, 30, false, 2000, "",false);
    var url = webDir + "/ajax/userinfo.aspx";
    var strAction = "action=addtop&findId=" + findId + "&masterId=" + masterId + "&masterName=" + escape(masterName);
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                CloseWin();
                if(parseInt(result,10) > 0){
                    PopWin("真新鲜评论成功", "", 200, 30, true, 2000, "reload", false);
	            }
	            else if(result == "-1"){
	                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
	            }
	            else if(result == "-2"){
	                PopWin("您已经评过了！", "", 200, 30, true, 2000, "", false);
	            }
	            else if(result == "-5"){
	                 PopWin("您不能给自己加“真新鲜”。", "", 260, 30, true, 2000, "", false);
	            }
	            else{
	                PopWin("评论失败，请稍候再试。", "", 260, 30, true, 2000, "", false);
	            }
            }
        }
    }  
}

function UserAddShare(special,objId,masterId,masterName,shareUrl,shareTitle){    
    var url = webDir + "/ajax/useraction.aspx";
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    var strAction = "action=addshare&special=" + special + "&objId=" + objId + "&url=" + shareUrl + "&title=" + escape(shareTitle) + 
        "&masterId=" + masterId + "&masterName=" + escape(masterName);
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;                
                if(parseInt(result,10) > 0){
                    switch(special){
                        case "blog": 
                            PopWin("分享成功", "您分享了 " + masterName + " 的日志 " + shareTitle, 320, 80, true, 3000, "");
                            break;
                        case "album": 
                            PopWin("分享成功", "您分享了 " + masterName + " 的相册 " + shareTitle, 320, 80, true, 3000, "");
                            break;
                        case "photo": 
                            PopWin("分享成功", "您分享了 " + masterName + " 的照片 " + shareTitle, 320, 80, true, 3000, "");
                            break;
                        case "find": 
                            PopWin("分享成功", "您分享了 " + masterName + " 的新鲜事 " + shareTitle, 320, 80, true, 3000, "");
                            break;
                    }
                }
                else if(result == "-1"){
                    PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 320, 150, false, 3000, webUserUrl + "/user/login.aspx");
                }
                else{
                    PopWin("收藏没有成功", "对不起，您的收藏没有成功，<br />可能服务器正忙，请您稍候再试！", 320, 100, true, 3000, "");
                }
            }
        }
    }
}
function UserDeleteShare(shareId){
    if(confirm("您确定要删除这个分享吗？")){
        var url = webDir + "/ajax/useraction.aspx";
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        var strAction = "action=deleteshare&shareId=" + shareId;
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("删除分享成功", "", 150, 30, true, 0, "reload");
                    }
                    else if(result == "-1"){
                        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 320, 150, false, 3000, webUserUrl + "/user/login.aspx");
                    }
                    else{
                        PopWin("删除分享失败", "对不起，您的分享没有删除成功，<br />可能服务器正忙，请您稍候再试！", 320, 100, true, 2000, "");
                    }
                }
            }
        }
    }
}


function FacilityAddArticle(uid,blogId){
    if(uid == 0){
        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
        return false;
    }
    var txtArticleName = $I("txtArticleName");
    var txtArticleContent = $I("txtArticleContent");
    
    if(txtArticleName.value.trim().equals("")){
        txtArticleName.focus(); return false;
    }
    else if(txtArticleContent.value.trim().equals("")){
        txtArticleContent.focus(); return false;
    }
    else{  
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=addarticle&articleName=" + escape(txtArticleName.value) + "&articleContent=" + escape(txtArticleContent.value) +
         "&blogId=" + blogId;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("日志发表成功", "", 200, 30, true, 2000, webUserUrl + "/" + uid + "/blog/", false);
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else if(result == "-20"){
		                PopWin("日志发表失败！", "对不起，每天最多只能发表20篇日志，<br />您今天已经发表了20篇日志了，请您明天再发表，<br />敬请谅解。", 360, 120, true, 2000, "", false);
		            }
		            else{
		                PopWin("日志发表失败", "日志发表失败，请稍候再试。", 360, 80, true, 2000, "", false);
		            }
                }
            }
        }    
    }
}

function AddComment(special,objId,uid,masterId,txtLen){
    if(uid <= 0){
        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
        return false;
    }else if(masterId <= 0){
        return false;
    }
    var txtCC = $I("txtCommentContent");
    var lblPrompt = $I("lblPrompt"); 
    var lblWC = $I("lblWC"); 
    if(txtCC.value.trim().equals("")){
        lblPrompt.innerHTML = "请输入评论内容。";
        txtCC.focus(); return false;
    }
    else if(!ShowWordCount(txtCC,lblWC,txtLen,lblPrompt)){
        lblPrompt.innerHTML = "评论内容字数不得超过" + txtLen + "个字符。";
        txtCC.focus(); return false;
    }
    else{
        lblPrompt.innerHTML = "";
        
        PopWin("正在提交，请稍候...", "", 200, 30, false, 2000, "",false);
        var url = webDir + "/ajax/userinfo.aspx";
        var strAction = "action=addcomment&commentContent=" + escape(txtCC.value.trim()) + "&special=" + special + "&objId=" + objId +
            "&masterId=" + masterId;
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    CloseWin();
                    if(parseInt(result,10) > 0){
                        PopWin("评论发表成功", "", 200, 30, true, 2000, "reload", false);
		            }
		            else if(result == "-1"){
		                PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 360, 150, true, 2000, webUserUrl + "/user/login.aspx");
		            }
		            else{
		                PopWin("评论发表失败，请稍候再试。", "", 260, 30, true, 2000, "", false);
		            }
                }
            }
        }    
    }
}
function ShowContentNav(str){
    PopWin(str, "", 200, 30, true, 2000, "", false);
}

function ShowWordCount(obj,lblWC,count,lblPro){
    var wl = obj.value.gblen();
    lblWC.innerHTML = wl;
    lblWC.style.color = "#000";
    if(wl > count){
        lblWC.style.color = "#ff5500";
        lblPro.innerHTML = "您已输入" + wl +"个字符（最多" + count + "个字符）";
        return false;
    }else{
        lblPro.innerHTML = "";
        return true;    
    }
}

function ShowFindSortDesc(sortid){
    var str = "";
    if(sortid == 0){
        str = "<b>新鲜事</b> 第一时间发生在身边的新鲜事儿，包括生活趣事，社区新闻，社会活动等等<br />" +
            "<b>新店</b> 第一时间发现的新店铺，以及新店铺的相关信息<br />" +
            "<b>新品</b> 第一时间发现的新产品，以及新产品的详细介绍<br />" +
            "<b>折扣</b> 第一时间发现的折扣活动，以及活动的相关信息<br />" +
            "<b>体验</b> 自己的消费体验，真实生动，为大家出门提供一个参考的有效信息";
        PopWin("新鲜事是什么？", str, 360, 200, false, 2000, "", true);
    }else{
        str = "<b>新鲜事</b> 第一时间发生在身边的新鲜事儿，包括生活趣事，社区新闻，社会活动等等<br />" +
            "<b>新店</b> 第一时间发现的新店铺，以及新店铺的相关信息<br />" +
            "<b>新品</b> 第一时间发现的新产品，以及新产品的详细介绍<br />" +
            "<b>折扣</b> 第一时间发现的折扣活动，以及活动的相关信息<br />" +
            "<b>体验</b> 自己的消费体验，真实生动，为大家出门提供一个参考的有效信息";
        PopWin("新鲜事是什么？", str, 360, 200, false, 2000, "", true);
    }
    
}
