﻿//操作会员离开
function Leave()
{
    if(__P_M=="")
    {
        top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;
    }
         showProgressBar(false,true);  
          $("$divIput$").style.display = "none";
        var leaveDesc="<div style='width:370px; overflow:hidden'>"+GP115.replace(/\{0\}/gi,groupTitle)+"</div><br/><div class='popup_button'><input value='"+GP230+"' class='button' onclick='opWebSerLeave()' type='button'/>&nbsp;&nbsp;<input type='button' value='"+C0056+"' class='buttong' onclick='webFailure()' /></div>";     
        var obj = {}
        $ShowMessageBox$(leaveTitle,leaveDesc,obj,webFailure,400);
}
//执行离开
function opWebSerLeave()
{
    $EndMessageBox$();
    $("LeaveGID").value=groupID;
    $("Form1").action = "/groups/mygroups.htm";
    $("Form1").submit();
}
//加入组
function Join(jo)
{
    if(__P_M=="")
    {
        top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;
        //top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;
    }
   if(jo=="2")
   {
    showProgressBar(false,true); 
     $("$divIput$").style.display = "none";
        var _joinDesc="<div style='width:370px; overflow:hidden'>"+joinDesc+"</div><br/><div class='popup_button'><input value='"+GP232+"' class='button' onclick='opWebSerJoin()' type='button'/>&nbsp;&nbsp;<input type='button' value='"+C0056+"' class='buttong' onclick='webFailure()' /></div>";     
        var obj = {}
        $ShowMessageBox$(joinTitle,_joinDesc,obj,webFailure,400);
    }
    else
    {
    $("$divIput$").style.display = "none";
        var _joinDesc1="<div style='width:370px; overflow:hidden'>"+joinDesc1+"</div><br/><div class='popup_button'><input value='"+GP231+"' class='button' onclick='opWebSerJoin1()' type='button'/>&nbsp;&nbsp;<input type='button' value='"+C0056+"' class='buttong' onclick='webFailure()' /></div>";   
        var obj = {}
      $ShowMessageBox$(joinTitle,_joinDesc1,obj,webFailure,400);

    }
}
//加入组需要验证的掉用WebServices方法操作
function opWebSerJoin()
{
    WebServices.WWW.Groups.Join1Group(groupID,onsuccGroup,webFailure);
}
//加入组不要验证的表单提交刷新操作
function opWebSerJoin1()
{

$EndMessageBox$();
    $("Rety").value="join";
    $("Form1").action = top.location;
    $("Form1").submit();
}
//加入组需要验证的掉用WebServices方法操作成功时候
function onsuccGroup(result)
{
    if(typeof(result.d) != "undefined")result=result.d;
    if(result.State)
    {
            $EndMessageBox$();
            //window.location.reload();
    }
    else
    {
        $EndMessageBox$();
    }
}
//调用webService方法失败
function webFailure()
{
    $EndMessageBox$();
}
//申请管理员
function AppAdmin()
{
    if(__P_M==""){top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;}
    showProgressBar(false,true);
     $("$divIput$").style.display = "none";
    var appAdminBody="<div class='popup_content'>"+GP116+":<br/><div id='AppAdminError' style='display:none' class='red12'>"+ST155+"</div><textarea id='AppAdminInfo' rows='5' class='textarea common100D'></textarea></div><div class='popup_button'><input id='btnAppAdmin' value='"+GP224+"' class='button' onclick='opWebSerAppAdmin()' type='button'/>&nbsp;&nbsp;<input type='button' value='"+C0056+"' class='buttong' onclick='webFailure()' /></div>";     
    var obj = {}
    $ShowMessageBox$(appAdminTitle,appAdminBody,obj,webFailure);    
 
}
//确定申请管理员
function opWebSerAppAdmin()
{
    var message=$("AppAdminInfo").value;
    if(message.length<3||message.length>1000)
    {
        $("AppAdminError").style.display = ""
        return;
    }
    $("AppAdminError").style.display = "none"
    WebServices.WWW.Groups.AppAdmin(groupID,NickName,groupTitle,message,onsuccGroup1,webFailure);      
}
//申请管理员成功
function onsuccGroup1(result)
{
        if(typeof(result.d) != "undefined")result=result.d;
        $EndMessageBox$();
}
//添加帖
function AddTopic()
{

    if(__P_M=="")
    {
        top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;
    }
    $("Rety").value=groupTitle;
    $("Form1").action = "/groups/"+groupID+"/add-topic.htm";
    $("Form1").submit();
}
//提交讨论话题
function SaveTopic()
{
    if(__P_M==""){top.location = LoginHost+"/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;}
    var valTitle = $("txtTitle").value;    
    var valDesc = tinyMCE.get('txtDesc').getContent();   
    if(valTitle.length<3 || valTitle.length>110)
    {
         $("ErrorTitle").style.display = "";
         return;
    }
    $("ErrorTitle").style.display = "none";      
    var valDescRe=EncodeMessage(valDesc).replace(/<\/?[^>]+>/gi, '');
    if(valDescRe.length<3 || valDescRe.length>9999)
    {
        $("ErrorDesc").style.display = "";
        return;
    }
    $("ErrorDesc").style.display = "none"; 
    SetButtonValue("btnSave",true); 
    
    //调用webserver方法
        WebServices.WWW.Groups.AddTopicOrShare(groupID,valTitle,valDesc,GetUserOAuthType(),onsuccOP);
}
function onsuccOP(result)
{   
    
    if(typeof(result.d) != "undefined")result=result.d;
    //RefHref();
    if(result.State)
    {
    var lk=lhost+"/groups/"+groupID+"/topic/"+result.Msg+".htm";     
     top.location=lk;
    }else
    {
       if(result.Msg=="-2")
       {
       $("ErrorDesc").style.display = "";
        $("ErrorDesc").innerHTML=GP306;
       }else if(result.Msg=="-1")
       {
        $("ErrorDesc").style.display = "";
        $("ErrorDesc").innerHTML=GP304;
       }
    }
    SetButtonValue("btnSave",false); 
}
