﻿window.onload = function(){
  $('btnGoPage1').onclick = function(){GoPage(1);}
  $('btnGoPage2').onclick = function(){GoPage(2);}
}
function GoPage(inputid){
  var ForumUrl = $('ForumUrl').value;
  var page = parseInt($('tbGoPage'+inputid).value);
  if(isNaN(page)){
    alert('请输入正确的数字');
  }else{
    location.href=ForumUrl.replace("{0}",page);
  }
}


function checkall()
{
    var checklist = document.getElementsByName("ckbItem");
    
    for(i=0;i<checklist.length;i++)
    {
        checklist[i].checked = $('ckbAll').checked;
    }
}



function submitexc()
{
    $('hdeidlist').value = '';
    var slt = $('sltexc');

    if(slt.value!='removetopic'&&slt.value!='')
    {
        if(window.confirm('确认要对选中帖子执行【'+slt.options[slt.selectedIndex].text+'】操作吗？'))
            $('excform').target='_self';
        else
            return;
    }
//    if($('sltexc').value=='deletetopic')
//    {
//        if(window.confirm('确认要删除选中帖子吗？'))
//            $('excform').target='_self';
//        else
//            return;
//    }
        
    var checklist = document.getElementsByName("ckbItem");
    var j =0;
    for(i=0;i<checklist.length;i++)
    {
        if(checklist[i].checked)
        {
            j++;
            $('hdeidlist').value = $('hdeidlist').value +","+checklist[i].id;
        }
    }
    
    if(j>0)
        $('excform').submit();
}


function confirmforum(fid)
{
    closeboard();
    window.open('/addtopic.aspx?boardid='+fid);
    //window.location = "/addtopic.aspx?boardid="+fid;
}

function GetChildForum(fid)
{
    var noroot = true;
    var url = '/web/topic.asmx/GetChildForum';
    var pars = 'forumid='+fid+'&noroot='+noroot;

    var myAjax = new Ajax.Request(
    url,
    {
        method: 'post',
        parameters: pars,
        asynchronous:false,
        onSuccess: function(originalRequest){
        var Result = originalRequest.responseText;
        var regExp = />([{][^<]{0,}[}])</;
        regExp.exec(Result);
        Result = RegExp.$1;
        var Json = Result.evalJSON();
        if(Json.Success){
            showboard(Json.Info,fid);
            return;
        }
        else{
            window.open('/addtopic.aspx?boardid='+fid);
        }
        },
        onFailure: function(){
            window.open('/addtopic.aspx?boardid='+fid);
        }
    });
    
}

var divdilog;
var divcontent;

function showboard(info,fid)
{
    //创建提示框内容部分
    var divcontent = document.createElement("div");
    divcontent.style.width="600px";
    divcontent.style.backgroundColor="#FFFFFF";
    divcontent.style.padding="10px";
    divcontent.style.border = "solid 1px #CCCCFF";

    //border-width:1px; border-color:;
    
    //向提示框内容部分画需要显示的信息
    info = info.replace(/&lt;/g,'<');
    info = info.replace(/&gt;/g,'>');

    info= "选择发帖版块<div style='width:100%;height:300px; padding-top:15px;padding-bottom:15px; border-top:solid 1px #CCCCFF;OVERFLOW-X:hidden;OVERFLOW:scroll;'>" + info;
    info+="</div><div style='width:100%; text-align:center;padding-top:5px'>【<a href='#' onclick = 'confirmforum("+fid+");return false;'>就在本版</a>】    【<a href='#' onclick = 'closeboard();return false;'>取消</a>】</div>";
    divcontent.innerHTML = info;
    
    //实例化提示框
    divdilog = new DivAlert(divcontent);
    //显示提示框
    divdilog.show();
}

function closeboard()
{
    divdilog.remove();
}

function DivAlert(messageDiv){
    this.messageDIV=messageDiv;
    //创建提示框底层 
    this.bottomDIV = document.createElement("div");
    //获取body中间点
    var x=document.documentElement.clientWidth/2,y=document.documentElement.clientHeight/2;
    //配置样式
    this.bottomDIV.style.opacity="0.70";
    this.bottomDIV.style.filter="Alpha(opacity=70);";
    this.bottomDIV.style.backgroundColor="#CCCCCC";
    this.bottomDIV.style.height=document.documentElement.scrollHeight+"px";
    this.bottomDIV.style.width="100%";
    this.bottomDIV.style.marginTop="0px";
    this.bottomDIV.style.marginLeft="0px";
    this.bottomDIV.style.position="absolute";
    this.bottomDIV.style.top="0px";
    this.bottomDIV.style.left="0px";
    this.bottomDIV.style.zIndex=100;
    //显示提示框
    this.show = function(){
        //显示提示框底层 
        document.body.appendChild(this.bottomDIV);
        //显示messageDIV
        document.body.appendChild(this.messageDIV);
        //把messageDIV定位到body中间
        this.messageDIV.style.position="absolute";
        x=x-this.messageDIV.clientWidth/2;
        y=y-this.messageDIV.clientHeight/2+document.documentElement.scrollTop;
        this.messageDIV.style.top=y+"px";
        this.messageDIV.style.left=x+"px";
        this.messageDIV.style.zIndex=101;
    }

    //移除提示框
    this.remove = function(){
        document.body.removeChild(this.bottomDIV);
        document.body.removeChild(this.messageDIV);
    }
}




