﻿//举报
function Report(TypeID,ID)
{
	var PostData = "do=showdig&type=" + TypeID + "&reportid=" + ID;
	PostRequest(window.location.protocol + "//"+ window.location.host +"/ajax/doreport", PostData);
	ScreenConvert();DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,10,124,20);
}

function ReportOK(Type,ID)
{
	var objReportName = gid("ReportName");
	var objReportEmail = gid("ReportEmail");
	var objReportComments = gid("ReportComments");
	var objDialogValidator = gid("DialogValidator");
	if (objReportName != null && objReportEmail != null && objReportComments != null && objDialogValidator != null)
	{
		if (Trim(objReportName.value).length < 1 || Trim(objReportName.value).length > 50)
		{
			objDialogValidator.innerHTML = "<span class=\"Error\">姓名长度应在1-50字之间!</span>";
			objReportName.focus();
			return false;
		}
		if (Trim(objReportEmail.value).length < 1 || Trim(objReportEmail.value).length > 100)
		{
			objDialogValidator.innerHTML = "<span class=\"Error\">邮件地址长度应在1-100字之间!</span>";
			objReportEmail.focus();
			return false;
		}
		else
		{
			var rx = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
			var matches = rx.exec(Trim(objReportEmail.value));
			if (matches == null || Trim(objReportEmail.value) != matches[0])
			{
				objDialogValidator.innerHTML = "<span class=\"Error\">邮件地址格式错误,请重新输入!</span>";
				objReportEmail.focus();
				return false;
			}
		}
		if (Trim(objReportComments.value).length < 1 || Trim(objReportComments.value).length > 300)
		{
			objDialogValidator.innerHTML = "<span class=\"Error\">举报内容长度应在1-300字之间!</span>";
			objReportComments.focus();
			return false;
		}
		var PostData = "do=add&type=" + Type + "&reportid=" + ID + "&name=" + StrCode(Trim(objReportName.value)) + "&mail=" + StrCode(Trim(objReportEmail.value)) + "&comments=" + StrCode(Trim(objReportComments.value));
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/doreport", PostData);
		DialogShow("<div id=\"DialogLoading\">正在提交,请稍候...</div>",80,24,124,24);
	}
	return false;
}

//收藏
//!!!如果修改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)?"delmsgfavorite":"adddfavorite") + "&referid=" + ReferID + "&favoritetype=" + WishType;
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
		

	}
}

//!!!如果修改WishListSave请同时修改Wish.js
function WishListSave(ActionType, ReferID, WishType, update)
{
	ScreenConvert();
	var objWishTags = gid("txtWishTags");
	var objComments = gid("txtComments");
	var objfavtext = gid("favtext");
	var PostData = null;
	var favtext="";
	if  (objfavtext)
	{
	    favtext=StrCode(objfavtext.value);
	}
	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=savefavorite&type=" + ActionType + "&referid=" + ReferID + "&favoritetype=" + WishType + "&update=" + update + "&tags=" + StrCode(objWishTags.value) + "&remark=" + StrCode(objComments.value)+"&favtext="+favtext;
		 PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
		}
	}
}

//!!!如果修改WishListDel请同时修改Wish.js
function WishListDel(ReferID,WishType)
{

	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	if (ReferID != null && WishType != null)
	{
		var PostData = null;
		PostData = "do=delfavorite&referid=" + ReferID + "&favoritetype=" + WishType;
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
	}
}

//通用操作
function CommonAction(typeid,referid,showflag)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	var PostData = "do=commonaction&referid=" + referid+"&typeid="+typeid+"&showflag="+showflag;
	PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
}

function EventJoinShow(allcount,eventid,userid,htmldata)
{
    var objJoinCount = gid("spanJoin"+eventid);
    var objBtnJoin =gid("spanbtnJoin"+eventid)
    if (objJoinCount!=null)
    {
        if (allcount>0)
        {
            objJoinCount.innerHTML =allcount;
        }
        else
        {
            objJoinCount.innerHTML = "0";
        }
    }
    
    if (objBtnJoin!=null)
    {
        objBtnJoin.innerHTML=htmldata;
    }
}

function EventAttentionShow(allcount,eventid,userid,htmldata)
{
    var objAttentionCount = gid("spanAttention"+eventid);
    var objBtnAttention =gid("spanbtnAttention"+eventid)
    if (objAttentionCount!=null)
    {
        if (allcount>0)
        {
            objAttentionCount.innerHTML =allcount;
        }
        else
        {
            objAttentionCount.innerHTML = "0";
        }
    }
    
    if (objBtnAttention!=null)
    {
        objBtnAttention.innerHTML=htmldata;
    }
}



//鲜花
function VoteGoodAction(ReviewID)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
	var PostData = "do=votegood&commentid=" + ReviewID;
	PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
}

function VoteGoodCount(ReviewID,VoteGoodCount)
{
	var objVoteGoodCount = gid("btnFollower" + ReviewID);
	if (objVoteGoodCount != null)
	{
		if (VoteGoodCount > 0)
		{objVoteGoodCount.innerHTML = VoteGoodCount + "鲜花";}
		else
		{objVoteGoodCount.innerHTML = "鲜花";}
	}
}

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(ActionType,UserID,style)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,10,124,20);
	var PostData = null;
	if (ActionType != null && UserID != null)
	{
	    if (style !=null)
	    {
	    //会员主页样式为1
	        if (ActionType==0)
		    {PostData = "do=delmsgfriend&userid=" + UserID+"&style="+style;}
		    else if (ActionType==1)
		    {PostData = "do=addfriend&userid=" + UserID+"&style="+style;}
		    else if (ActionType==2)
		    {PostData = "do=delfriend&userid=" + UserID+"&style="+style;}
	    }
	    else
	    {
		    if (ActionType==0)
		    {PostData = "do=delmsgfriend&userid=" + UserID;}
		    else if (ActionType==1)
		    {PostData = "do=addfriend&userid=" + UserID;}
		    else if (ActionType==2)
		    {PostData = "do=delfriend&userid=" + UserID;}
		}
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/douserfriend", PostData);
	}
}


function FriendText(ActionType,UserID)
{
	var objFriendText = gid("FriendText");
	var objFriendText1 = gid("FriendText" + UserID);
	var strText = null;
	var strText1 = null;
	if (UserID != null)
	{
		if (ActionType == 0)
		{
			strText = "<a href =\"#\" onclick=\"this.blur();FriendAction(1,'" + UserID + "');return false;\" class = \"BL Bold\">加为好友</a>";
			strText1 = "<a href =\"#\" onclick=\"this.blur();FriendAction(1,'" + UserID + "');return false;\" class = \"BL\">加为好友</a>";
		}
		else if (ActionType == 1)
		{
			strText = "<a href =\"#\" onclick=\"this.blur();FriendAction(0,'" + UserID + "');return false;\" class = \"BL Bold\">删除好友</a>";
			strText1 = "<a href =\"#\" onclick=\"this.blur();FriendAction(0,'" + UserID + "');return false;\" class = \"BL\">删除好友</a>";
		}
	}
	if (objFriendText != null && strText != null) objFriendText.innerHTML = strText;
	if (objFriendText1 != null && strText != null) objFriendText1.innerHTML = strText1;
}



//有用无用
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 BlockAction(ActionType,UserID)
{
	ScreenConvert();
	DialogShow("<div id=\"Loading\">正在读取,请稍候...</div>",110,10,124,20);
	var PostData = null;
	if (ActionType != null && UserID != null)
	{
		if (ActionType==1)
		{PostData = "do=addblock&userid=" + UserID;}
		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 AddTagBox(referid,intype)
{
        var msgbox ="<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\">标签：<input type=\"text\" size=70 id=\"txtajaxTag\"  maxlength=\"100\" onkeypress=\"return ClickButton(event,'AddTagOk')\" />"+        
        "</div><div class=\"gray ml10\">多个标签请用“空格”分割</div><div id=\"DialogValidator\"><span class=\"Error\" id=errorshow></span></div><div id=\"DialogButtons\"><button id=\"AddTagOk\" class=\"btn\" onclick=\"return tagadd("+referid+","+intype+");\">加上去</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"TellFriendCancle\" class=\"btn\" onclick=\"return DialogHide();\">取消</div></div>";
        ScreenConvert();
        DialogShow(msgbox,500,70,500,70);
   

}

function tagadd(referid,inttype)
{

var objtxttag = gid("txtajaxTag");
var objinfo = gid("errorshow");
if (objtxttag)
{
    if (Trim(objtxttag.value).length ==0)
    {
        objinfo.innerHTML = "请输入标签，多个标签请用空格分割";
        return false;
    }

DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
var PostData = "do=addtag&typeid=" + inttype+"&referid="+referid+"&tagtext="+StrCode(objtxttag.value);
	PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
	
    
}

}

function tagshow(typeid,tagtext)
{
    var taginfo =  gid("taginfo");
    if (typeid ==2)
        taginfo.innerHTML = tagtext;
    DialogHide();
}