﻿var forum_right_width = 200; //中间左边宽度
var forum_imgdiv_width = 400; //滚动图片宽度
var forum_frame_width = 40;
var clientwidth = 0;
//设置同步
$.ajaxSetup({
    async: false
});
//鼠标谈起时 实现只能输入数字
function keyup(obj) {
    $(obj).val($(obj).val().replace(/[^\d]/g, ''));
}
function setclientwidth() {
    $.post("/website/Skins/forumthin/ashx/InfoHandle.ashx", { state: "SetClientWidth", ClientWidth: 710 }, function (data) { });
}
function searchPost(url) {
    if ($("#txtPostTitle").val().replace(/(^\s*)|(\s*$)/g, "") != "") {
        window.location.href = url + "/PostList/Title$" + $("#txtPostTitle").val();
    } else {
         alert("搜索内容不能为空！");
    }
}
//设置当前菜单样式
var upObj = undefined;
function setWH(obj,title) {
    if (upObj != undefined) {
        upObj.className = "mgr_item_list";
    }
    upObj = obj
    upObj.className = "mgr_item_list_current";
    $("#navigation_title").html(title);
}
$(function () {
    var tab_current = undefined;
    $(".tab_item").hover(
    function () {
        if (tab_current != undefined) {
            tab_current.attr("className", "tab_item");
            $("#div_" + tab_current.attr("id")).css("display", "none");
        }
        tab_current = $(this);
        tab_current.attr("className", "tab_item_current");
        $("#div_" + tab_current.attr("id")).css("display", "block");
    });
    $($(".tab_item")[0]).mouseover();
    var title_current = undefined;
    $(".title_item").hover(
    function () {
        if (title_current != undefined) {
            title_current.attr("className", "title_item");
            $("#div_" + title_current.attr("id")).css("display", "none");
        }
        title_current = $(this);
        title_current.attr("className", "title_item_current");
        $("#div_" + title_current.attr("id")).css("display", "block");
    });
    $($(".title_item")[0]).mouseover();
    $(".board_content_list").hover(
        function () {
            $(this).attr("className", "board_content_list_current");
        },
        function () {
            $(this).attr("className", "board_content_list");
        });
    $(".post_list").hover(
        function () {
            $(this).attr("className", "post_list_current");
        },
        function () {
            $(this).attr("className", "post_list");
        });

    $(".board_head_open").click(function () {
        if ($(this).attr("className") == "board_head_open") {
            $("#div_" + $(this).attr("id")).css("display", "none");
            $(this).attr("className", "board_head_fold");
        }
        else {
            $("#div_" + $(this).attr("id")).css("display", "block");
            $(this).attr("className", "board_head_open");
        }
    });
    //信息列表
    $(function () {
        $(".item_info_list").hover(
      function () {
          $(this).attr("className", "item_info_list_current");
      },
      function () {
          $(this).attr("className", "item_info_list");
      });
    });
});
//frame自动拉伸
function iframe_resize() {
    document.getElementById("bgcontentFrame").style.height = bgcontentFrame_name.document.body.scrollHeight;   //  IE7 和Firefox  都可以
    document.getElementById("bgcontentFrame").style.width = bgcontentFrame_name.document.body.scrollWidth;   //  IE7 和Firefox  都可以
}

function reinitIframe() {
    var iframe = document.getElementById("bgcontentFrame");
    try {
        iframe.height = "10px";
        var bHeight = iframe.contentWindow.document.body.scrollHeight;
        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
        var height = Math.max(bHeight, dHeight);
        iframe.height = bHeight + 10;
    } catch (ex) { }
}
//全选
function chkAll(obj, Count) {
    for (var i = 1; i <= Count; i++) {
        var chk_Id = "chk_Id" + i;
        var chkobj = document.getElementById(chk_Id);
        if (chkobj != null) {
            chkobj.checked = "checked";
        } else {
            break;
        }
    }
}
//反选
function chkReverse(obj, Count) {
    for (var i = 1; i <= Count; i++) {
        var chk_Id = "chk_Id" + i;
        var chkobj = document.getElementById(chk_Id);
        if (chkobj != null) {
            if (chkobj.checked)
                chkobj.checked = "";
            else
                chkobj.checked = "checked";
        } else {
            break;
        }
    }
}
//滚动图片
var _c = _h = 0;
$(function () {
    $('#slidenum > a').click(function () {
        _c = $(this).text() - 1;
        clearInterval(_h);
        changeimg(_c);
        startslide();
    })
    $("#slideimg img").hover(function () { clearInterval(_h) }, function () { startslide() });
    autoslide();
    startslide();
})
function startslide() {
    _h = setInterval("autoslide()", 3000);
}
function changeimg(i) {
    $('#slidenum > a').css('background-color', '#ffffff').eq(i).css('background-color', '#1a4963').blur();
    $('#slidenum > a').css('color', '#1a4963').eq(i).css('color', '#ffffff').blur();
    $("#slideimg img").hide().eq(i).fadeIn('slow');
    $("#slideimg img").eq(i).css("display", "block");
}
function autoslide() {
    _c++;
    if (_c >= $("#slideimg img").size()) _c = 0;
    changeimg(_c);
}
var CObj5 = undefined;
var txtCode = "";
var txtTitle = "";
var DDLCate = "";
var LogonName;

$.ajaxSetup({
    async: false
});
function succeed() {
    var obj = document.getElementById("fileQueue");
    if (obj != null) {
        if (obj.innerHTML.replace(/(^\s*)|(\s*$)/g, "") == "") {
            document.getElementById("DivSucceed").style.display = "block";
            document.getElementById("DivSucceed").innerHTML = "附件全部上传成功！";
            return false;
        }
    }
    setTimeout("succeed()", 1000);
}
function Upload() {
    var obj = document.getElementById("fileQueue");
    if (obj != null) {
        if (obj.innerHTML.replace(/(^\s*)|(\s*$)/g, "") != "") {
            $('#uploadify').uploadifyUpload();
            succeed();
        } else {
            alert("请添加上传的附件！");
        }
    }
}
function ChNull() {
    var obj1 = document.getElementById(DDLCate);
    var obj2 = document.getElementById(txtTitle);
    var obj3 = document.getElementById(txtCode);
    var obj4 = document.getElementById("fileQueue");
    if (obj1 != null) {
        if (obj1.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            alert("请选择有效的模块")
            obj1.focus();
            return false;
        }
    }
    if (obj2 != null) {
        if (obj2.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            alert("标题不能为空")
            obj2.focus();
            return false;
        }
    }
    if (editor != null) {
        if (editor.getData().replace(/(^\s*)|(\s*$)/g, "") == "") {
            alert("内容不能为空")
            editor.focus();
            return false;
        }
    }
    if (obj4 != null) {
        if (obj4.innerHTML.replace(/(^\s*)|(\s*$)/g, "") != "") {
            alert("请先上传附件在提交帖子！")
            return false;
        }
    }
    if (obj3 != null) {
        if (obj3.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            alert("验证码不能为空")
            obj3.focus();
            return false;
        }
    }
    return true;
}
function ChangeColor(obj, StartS, ChS, stateObj) {
    var Hobj = undefined;
    if (stateObj == "CObj5") {
        Hobj = CObj5;
    }
    if (Hobj != undefined && Hobj != obj) {
        Hobj.className = StartS;
    }
    obj.className = ChS;
    if (stateObj == "CObj5") {
        CObj5 = obj;
    }
}
function GetFocus() {
    editor.focus();
}
function LogonInfo() {
    if (userid == "") {
        alert("请登录后再发帖！");
        if (document.getElementById("ctl00_ctl00_Logon_txtLoginName") != null)
            document.getElementById("ctl00_ctl00_Logon_txtLoginName").focus();
        return false;
    }
    return true;
}
function DisList(id) {
    var Obj = document.getElementById(id);
    var ObjD = document.getElementById(id + "D");
    if (Obj.style.display == "none") {
        Obj.style.display = "block";
        ObjD.className = "ForumTUP";
    }
    else {
        Obj.style.display = "none";
        ObjD.className = "ForumTD";
    }
}


function check_event(event) {
    var code = event.keyCode;
    if (code == 13) {
        event.keyCode = 9;
    }
}
function check_event2(event, id) {
    var code = event.keyCode;
    if (code == 13) {
        event.keyCode = 9;
        document.getElementById(id).click();
    }
}
function check_event1(event, id) {
    var code = event.keyCode;
    if (code == 13) {
        event.keyCode = 9;
        document.getElementById("ctl00_ContentPlaceHolder_btnSubmits").click();
    }
}
function userlogout(url) {
    if (confirm("你确认要注销吗？")) {
        $.post("/ashx/UserLogout.ashx", {}, function (data) {
            location.href = url;
        });
    }
}
var upobj = "";
var conobj = "";
function changestyle(obj, contentid, startStyle, OverStyle) {
    obj.style.cursor = "hand";
    if (upobj != "" && upobj != obj.id) {
        document.getElementById(conobj).style.display = "none";
        document.getElementById(upobj).className = startStyle;
    }
    upobj = obj.id
    conobj = contentid
    obj.className = OverStyle;
    document.getElementById(contentid).style.display = "block"
}
function ShowMove(insideID, state, outID) {
    showDiv(insideID, state, outID);
    return false;
}
function ShowCollect(txtTitle) {
    document.getElementById("txtTitle").value = txtTitle;
    showDiv("AddCollectDiv", "block", "AllDiv");
    return false;
}
function CollectCheck() {
    var titleObj = document.getElementById("txtTitle");
    if (titleObj != null) {
        if (titleObj.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            alert("标题不能为空！")
            titleObj.focus();
            return false;
        }
    }
    return true;
}
//加为好友
function addFriend(userid) {
    $.post("/ashx/UpdateInfo.ashx", { State: "GetUserID" }, function (data) {
        if (data.toLowerCase() != userid.toLowerCase()) {
            showDiv('friendcategory', 'block', 'page_outdiv');
            document.getElementById("FriendID").value = userid;
        } else {
            alert("抱歉，自己不能加自己为好友！");
            return;
        }
    });
}
//发短信
function sendmessage(url,userid) {
    $.post("/ashx/UpdateInfo.ashx", { State: "GetUserID" }, function (data) {
        if (data.toLowerCase() != userid.toLowerCase()) {
            window.open(url);
        } else {
            alert("抱歉，自己不能给自己发消息！");
            return;
        }
    });
}
//未登录的提示信息
function logonalter(msg) {
    alert(msg);
    $("#txtLogonName").focus();
}
//帖子内容引用
function quoteinfo(divid) {
    //getData() 获取值
    editor.setData($("#" + divid).html());
    GetFocus();
}
//改变字体大小
function changesize(id,size) {
    document.getElementById(id).style.fontSize = size;
}
//返回顶部
function returnup() {
    scroll(0, 0);
}
//搜索验证
function checksearch() {
    if ($("#txtInfo").val().replace(/(^\s*)|(\s*$)/g, "") == "") {
        
        return;
    }
}
