﻿
//收藏
//!!!如果修改WishListAction请同时修改Wish.js
function WishListAction(ActionType, ReferID, WishType, update)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	if (update == null) update = true;
	update = (update)?1:0;
	if (ActionType != null && ReferID != null && WishType != null)
	{
		var PostData = "do=" + ((ActionType == 0)?"delmsgwishlist":"addwishlist") + "&referid=" + ReferID + "&wishtype=" + WishType + "&update=" + update;
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}

//!!!如果修改WishListSave请同时修改Wish.js
function WishListSave(ActionType, ReferID, WishType, update)
{
	ScreenConvert();
	var objWishTags = gid("txtWishTags");
	var objComments = gid("txtComments");
	var PostData = null;
	var objValidator=gid("DialogValidator");
	if (ActionType != null && ReferID != null && WishType != null && objWishTags != null && objComments != null)
	{
		if(objWishTags.value.length>=100)
		{objValidator.innerHTML = "<span class=\"Error\">收藏标签的字数不能大于100!</span>";}
		else if(objComments.value.length>=100)
		{objValidator.innerHTML = "<span class=\"Error\">备注的字数不能大于100!</span>";}
		else
		{PostData = "do=savewishlist&type=" + ActionType + "&referid=" + ReferID + "&wishtype=" + WishType + "&update=" + update + "&wishtags=" + StrCode(objWishTags.value) + "&comments=" + StrCode(objComments.value);
		 PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
		}
	}
}

//!!!如果修改WishListDel请同时修改Wish.js
function WishListDel(ReferID,WishType,update)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	if (ReferID != null && WishType != null)
	{
		var PostData = null;
		PostData = "do=delwishlist&referid=" + ReferID + "&wishtype=" + WishType + "&update=" + update;
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}


//function VoteGoodAction(ReviewID, rateObjectType)
//{
// //   VoteGoodAction(voteid, rateObjectType)
//	VoteGoodActionFunc(ReviewID, islist, 0)
//}

//鲜花
function VoteGoodActionFunc(ReviewID, islist, del)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	var PostData = null;
	if (islist)
	{
		PostData = "do=listgood";
	}
	else
	{
		PostData = "do=votegood";
	}
	PostData += "&reviewid=" + ReviewID + "&del=" + del;
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
}

function VoteGoodCount(ReviewID,VoteGoodCount)
{
	var objVoteGoodCount = gid("btnFollower" + ReviewID);
	if (objVoteGoodCount != null)
	{
		if (VoteGoodCount > 0)
		{objVoteGoodCount.innerHTML = VoteGoodCount + "鲜花";}
		else
		{objVoteGoodCount.innerHTML = "鲜花";}
	}
}

function VoteGoodCheck(t, id)
{
	var _AD = "<div id=\"DialogTitle\"><div id=\"DialogTitleText\">删除鲜花</div><div id=\"DialogTitleBtn\" onclick=\"return DialogHide();\" onmouseover=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #000000';\" onmouseout=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #EEE';\"></div></div><div id=\"DialogContent\">您已送过鲜花。是否要删除?</div><div id=\"DialogButtons\"><button onclick=\"VoteGoodActionFunc(" + id + ", " + t + ", 1);return false;\">&nbsp;&nbsp;是&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;<button onclick=\"return DialogHide();\">&nbsp;&nbsp;否&nbsp;&nbsp;</button></div>";
	DialogShow(_AD,250,120,300,150);
}

function VoteGoodLink(VoteGoodAction,UserID,UserNickName)
{
	var objVoteGoodLink = gid("GoodLink");
	
	if (objVoteGoodLink != null)
	{
		var VoteGoodLink = objVoteGoodLink.innerHTML;
		if (VoteGoodAction == 0)
		{objVoteGoodLink.innerHTML = VoteGoodLink.replace(UserNickName,"");}
		else if (VoteGoodAction == 1)
		{objVoteGoodLink.innerHTML = "<div id=\"GoodLinkText\"><a href=\"/member/" + UserID + "\" class=\"SkyBlueUL\">" + UserNickName + "</a></div>" + VoteGoodLink;}
	}
}

//好友

function FriendAction(u, t)
{
	AddFriendAction(u,t);
//	ScreenConvert();
//	DialogShow("<div id=\"DialogLoading\">正在读取用户信息,请稍候...</div>", 180, 20, 180, 20);
//	var PostData = "";
//	if (u)
//	{
//		if (t)
//		{
//			PostData = "do=df&ui=" + u;
//		}
//		else
//		{
//			PostData = "do=fa&ui=" + u;
//		}
//		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
//	}
}

function FriendActionRequest(u)
{
	var msgo = gid("AjaxFriendMsg");
	var msgv = "";
	if (msgo) msgv = msgo.value;
	var vco = gid("AjaxFriendVC");
	var vcv = "";
	if (vco) vcv = vco.value;
	var tags = gid("tags");
	if(tags) tags =tags.value;
	
	var PostData = "do=af&ui=" + u + "&m=" + StrCode(msgv) + "&v=" + vcv+ "&tags="+StrCode(tags);

	DialogShow("<div id=\"DialogLoading\">正在添加,请稍候...</div>", 150, 20, 150, 20);
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
}

function FriendLink(t, u)
{
	var fo = gid("AJAXFriendLink_" + u);
	if (fo)
	{
		if (t)
		{
			fo.onclick = function () {this.blur();FriendAction(u, 1);return false;};
			fo.innerHTML = "删除好友";
		}
		else
		{
			fo.onclick = function () {this.blur();FriendAction(u);return false;};
			fo.innerHTML = "加为好友";
		}
	}
}

//有用无用
function Rate(RateType, RateMode, RateID)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	var PostData = null;
	if (RateType != null && RateMode != null && RateID != null)
	{
		PostData = "do=rate&ratetype=" + RateType + "&ratemode=" + RateMode + "&rateid=" + RateID;
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}

function RateAction(RateType, RateMode, RateID, RateTotal, RateGood)
{
	var objRateGood = gid("RateGood" + RateID);
	var objRateTotal = gid("RateTotal" + RateID);
	var btnRateGood = gid("BtnRateGood" + RateID);
	var btnRateBad = gid("BtnRateBad" + RateID);
	if (objRateGood) objRateGood.innerHTML = RateGood;
	if (objRateTotal) objRateTotal.innerHTML = RateTotal;
	if (RateMode == 0)
	{
		if (btnRateGood) btnRateGood.innerHTML = "<b>无用</b>";
		if (btnRateBad) btnRateBad.innerHTML = "<a href=\"#\" onclick=\"this.blur();Rate(" + RateType + ", 1, " + RateID + ");return false;\" class=\"Btn\">有用</a>";
	}
	else if (RateMode == 1)
	{
		if (btnRateGood) btnRateGood.innerHTML = "<b>有用</b>";
		if (btnRateBad) btnRateBad.innerHTML = "<a href=\"#\" onclick=\"this.blur();Rate(" + RateType + ", 0, " + RateID + ");return false;\" class=\"Btn\">无用</a>";
	}
	DialogHide();
}

//判断是否登录
//!!!如果修改CheckUserLogin请同时修改Wish.js
function CheckUserLogin(Refer)
{
	var PostData = null;
	if (Refer != null )
	{
		PostData = "do=checkuserlogin&refer=" + StrCode(Refer);

		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}
//!!!如果修改CheckUserLogin请同时修改Wish.js

//黑名单function AddBlockByUserNickName(inputID)
{  
    var obj = gid(inputID);
   	var PostData = "";
	
	if(obj !=null && obj.value != '' && obj.value != '请输入昵称')
	{
	    ScreenConvert();
	    DialogShow("<div id=\"DialogLoading\">正在读取用户信息,请稍候...</div>", 180, 20, 180, 20);
	    PostData = "do=addblockbyname&usernickname=" + StrCode(obj.value);
	    PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
	else
	{
	    var emsg = gid("ErrorMsg");
	    
	    if(emsg)
	    {
	        emsg.innerHTML = "<span class=\"Error\">请输入用户名!</span>";
	    }
	}
    
}

function BlockAction(ActionType,UserID)
{
	var objIsFriend = gid('cbIsfriend');
    var isDELFriend = 'false';
	if(objIsFriend)
	{
	    if(objIsFriend.checked)
	    {
	        isDELFriend = 'true';
	    }
	}
	
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,10,124,20);
	
	var PostData = null;
	if (ActionType != null && UserID != null)
	{
		if (ActionType==1)
		{PostData = "do=addblock&userid=" + UserID + "&isdelfriend=" + isDELFriend;}
		else if (ActionType==2)
		{PostData = "do=delblock&userid=" + UserID;}
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}


function BlockText(ActionType,UserID)
{
	var objBlockText = gid("BlockText");
	var objBlockText1 = gid("BlockText" + UserID);
	var strText = null;
	if (UserID != null)
	{
		if (ActionType == 0)
		{strText = "<a href =\"#\" onclick=\"this.blur();BlockAction(1,'" + UserID + "');return false;\" class = \"BL\">加入黑名单</a>";}
		else if (ActionType == 1)
		{strText = "<a href =\"#\" onclick=\"this.blur();BlockAction(2,'" + UserID + "');return false;\" class = \"BL\">解除黑名单</a>";}
	}
	if (objBlockText != null && strText != null) objBlockText.innerHTML = strText;
	if (objBlockText1 != null ) objBlockText1.innerHTML = "";
}
//回应黑名单
function FollowNoteBlock(blockUserID,blockUserNickName)
{
	var PostData = null;
	if (blockUserID != null && blockUserNickName != null)
	{
		PostData = "do=follownoteblock&blockUserID=" + blockUserID + "&blockUserNickName=" + blockUserNickName;
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
}


//新鲜花系统

function VoteGoodAction(voteID, rateObjectType)
{
	//VoteGoodActionFunc(ReviewID, islist, 0)
	JudgeRateObjectType(voteID, rateObjectType);
}

//鲜花
function JudgeRateObjectType(voteID, rateObjectType)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	var PostData = null;
	if (!rateObjectType)
	{
	   rateObjectType = 1;
	}
	
	PostData = "do=rateaction&voteid=" + voteID + "&rateObjectType=" + rateObjectType ;
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Rate.aspx", PostData);
}

function ShowDeleteRate(voteID, rateObjectType)
{   
	var _AD = "<div id=\"DialogTitle\"><div id=\"DialogTitleText\">删除鲜花</div><div id=\"DialogTitleBtn\" onclick=\"return DialogHide();\" onmouseover=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #000000';\" onmouseout=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #EEE';\"></div></div><div id=\"DialogContent\">您已送过鲜花。是否要删除?</div><div id=\"DialogButtons\"><button onclick=\"DeleteRateAction(" + voteID + ", " + rateObjectType + ");return false;\">&nbsp;&nbsp;是&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;<button onclick=\"return DialogHide();\">&nbsp;&nbsp;否&nbsp;&nbsp;</button></div>";
	DialogShow(_AD,250,120,300,150);
}

function DeleteRateAction(voteID,rateObjectType)
{
    ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在删除,请稍候...</div>",110,24,124,24);
	var PostData = null;
	if (!rateObjectType)
	{
	   rateObjectType = 1;
	}
	
	PostData = "do=dorateaction&voteid=" + voteID + "&rateObjectType=" + rateObjectType  + "&dotype=delete";
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Rate.aspx", PostData);
}

function AddRateAction(voteID,rateObjectType)
{

	var PostData = null;
	var rateType = null;
	   
	if (!rateObjectType)
	{
	   rateObjectType = 1;
	}
	
	var objRateType = gna("rblRateType")
	if(objRateType)
	{ 
	    var len=objRateType.length;
        for (var i=0;i<len ;i++ )
        { 
            if( objRateType[i].checked )
            {
                rateType = objRateType[i].value;
            }
        }
	}
	
	PostData = "do=dorateaction&voteid=" + voteID + "&rateObjectType=" + rateObjectType + "&rateTypeID=" + rateType + "&dotype=add";
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Rate.aspx", PostData);
}

//新添加好友
//好友

function AddFriendAction(u, t)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取用户信息,请稍候...</div>", 180, 20, 180, 20);
	var PostData = "";
	if (u)
	{
		if (t)
		{
			PostData = "do=delfriend&ui=" + u;
		}
		else
		{
			PostData = "do=friendaction&ui=" + u;
		}
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Friend.aspx", PostData);
	}
}

function AddFriendActionRequest(u)
{
	var aisv = 0;
	var ais = gid("AjaxIsSub");
	if (ais.checked) aisv = 1;
	
	var msgo = gid("AjaxFriendMsg");
	var msgv = "";
	if (msgo) msgv = msgo.value;
	
	var vco = gid("AjaxFriendVC");
	var vcv = "";
	if (vco) vcv = vco.value;
	
	var friendTag;
	var oddlfriendTag = gid("ddlfriendGroup");
	if(oddlfriendTag)
	{
		for (var i=0; i < oddlfriendTag.length; i++)
		if ( oddlfriendTag[i].selected )
		{
			friendTag = oddlfriendTag[i].value
		}
	}
	
	var PostData = "do=addfriend&ui=" + u + "&msg=" + StrCode(msgv) + "&v=" + vcv+ "&friendTag="+StrCode(friendTag) + "&is=" + aisv;

	DialogShow("<div id=\"DialogLoading\">正在添加,请稍候...</div>", 150, 20, 150, 20);
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Friend.aspx", PostData);
}