$(document).ready(function ($) {

  $("#menusecond").children().filter("a[href*=/"+MODULE+".asp]").attr("class","oranger");
  sendStatuRefresh();
});
//显示错误信息
$(function () {
	if (typeof errMsg !== "undefined" && errMsg.length > 0) {
		msgbox(errMsg);
	}
});

function sendStatuRefresh() {
	$.post("../account/refreshStatus.asp?t=" + new Date().getTime(), function (resp) {
		var str = resp.replace(/(\s*)|(\r)|(\n)/g, "");
	});
	setTimeout(sendStatuRefresh, 300000);
}

//查询系统通知
function getFriendRequest() {
	var ran = new Date().getTime();
	$.post("../message/notifycount.html", {ran:ran}, function (resp) {
		resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
		if (resp > 0) {
			$("#systemnotice").show();
			$("#systemnotice").val(resp + "\u4e2a\u65b0\u901a\u77e5");
		} else {
			$("#systemnotice").hide();
		}
	});
}

//上边导航下拉菜单实现
var Num;
var NumTemp = 1;
function showc(Num) {
	document.getElementById("cont" + NumTemp).style.display = "none";
	document.getElementById("cont" + Num).style.display = "block";
	NumTemp = Num;
}
function hidec(Num) {
	document.getElementById("cont" + Num).style.display = "none";
}
$(function () {
	$("#deleteId").click(function () {
		if (confirm("\u786e\u5b9a\u5220\u9664\u4e48?")) {
			return true;
		} else {
			return false;
		}
	});
});
/**
 *包含JS文件
 *
 */
function IncludeJS(jsFile) {
	document.write("<script type=\"text/javascript\" src=\"" + jsFile + "\"></script>");
}
/**
 * 计算字符串长度
 *
 *@param string sString 检测的字符串
 */
function JHshStrLen(sString) {
	var sStr, iCount, i, strTemp;
	iCount = 0;
	sStr = sString.split("");
	for (i = 0; i < sStr.length; i++) {
		strTemp = escape(sStr[i]);
		if (strTemp.indexOf("%u", 0) == -1) {
			iCount = iCount + 1;
		} else {
			iCount = iCount + 2;
		}
	}
	return iCount;
}
function isValidEmail(s) {
	var re = new RegExp("^[\\w-\\.\\+]+@([\\w-]+\\.)+[\\w-]{2,4}$");
	return re.test(s);
}
function isValidURL(s) {
	if (s.indexOf("http://") != 0) {
		s = "http://" + s;
	}
	var re = new RegExp("^http\\://(([a-zA-Z0-9\\-]+\\.)*[a-zA-Z0-9\\-]+\\.[a-zA-Z]{2,4})(/[^/][a-zA-Z0-9\\.\\,\\?\\'\\/\\+&amp;%\\$#\\=~_\\-@]*)*$");
	return re.test(s);
}

function SetCookie(inName, inValue) 
{ 
  document.cookie = inName + "=" + escape(inValue) + "; path=/";
} 

// Retrieve the value of the cookie with the specified name.
function GetCookie(inName)
{
  // cookies are separated by semicolons
  var m_cookie = document.cookie.split("; ");
  for (var i=0; i < m_cookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var m_crumb = m_cookie[i].split("=");
    if (inName == m_crumb[0]) 
    {
    	var val = unescape(m_crumb[1]);
        val = val.replace(/^"(.*)"$/g, "$1");
        return val;
 	}
  }

  // a cookie with the requested name does not exist
  return null;
}

String.prototype.trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
 
String.prototype.ltrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 
 
String.prototype.rtrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 

function joingroup(groupid, id){
    var ran = new Date().getTime();
    $.post("../group/joinByInvite.asp", {
        groupId: groupid,
        userId: id,
        ran: ran
    }, function(resp){
     resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
        $("#invite" + groupid).parent().parent().hide("slow");
        changeInviteCount();
    });
    
}

function requestgroup(groupid, id){
    var ran = new Date().getTime();
    $.post("../group/doJoinByAdmin.asp", {
        groupId: groupid,
        uid: id,
        ran: ran
    }, function(resp){
      resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
        $("#request" + groupid).parent().parent().hide("slow");
        changeInviteCount();
    });
    
    
}
function activity(groupid, id){
    $.post("../activity/doJoinByAdmin.asp", {aid:groupid,uid:id
    }, function(resp){
     resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
         $("#request" + groupid).parent().parent().hide("slow");
         changeInviteCount();
    });
   
}

function encyclopedia(qid, id){
    $.post("../Encyclopedia/joinbyinvite.asp", {qid:qid,uid:id
    }, function(resp){
     resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
        $("#request" + qid).parent().parent().hide("slow");
        changeInviteCount();
    });
}

function addFriend1(fid,id){
    var ran = new Date().getTime();
    $.post("../friend/insert.asp", {
        uid: id,
        ran: ran
    }, function(resp){
     resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
         $("#agreefriend" + fid).parent().parent().hide("slow");
         changeInviteCount();
    });
}

function ignore(id){
    var ran = new Date().getTime();
    $.post("../message/ignorenotify.asp", {
        mid: id,
        ran: ran
    }, function(resp){
        resp = resp.replace(/(\s*)|(\r)|(\n)/g, "");
        $("#ignore" + id).parent().parent().hide("slow");
        changeInviteCount();
    });
}

function msgbox(msg) {
    var txt = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"30\" align=\"center\"><span style=\"color:#4a4a4a; font-weight:bold;\">"+msg+"</span></td></tr>";
    txt += "<tr><td height=\"30\" align=\"center\"><input type=\"submit\" value=\"确  定\" class=\"orabutton\" onClick=\"$.facebox.close()\"/></td></tr></table>";
	
	jQuery.facebox(txt, "\u6e29\u99a8\u63d0\u793a");//温馨提示
}
function msgboxshow(msg) {
	var txt = "<div class=\"fb_content\">" + msg + "\t\t</div>\t\t<div class=\"bottom\">\t\t<input type=\"button\" value=\"\u786e\u5b9a\" class=\"orabutton\" onClick=\"$.facebox.close()\" />\t\t</div>";
	jQuery.facebox(txt, "\u63d0\u793a");
	setTimeout(function(){
	              $.facebox.close();
	              }, 1500);
}