﻿function share_show(id) {
    var obj = document.getElementById(id);
    if (!obj) return;
    obj.style.display = "";
}
function share_hide(id) {
    var obj = document.getElementById(id);
    if (!obj) return;
    obj.style.display = "none";
}
var ObjShare = {
    title: '',
    url: '',
    pic: '',
    video: '',
    linkTarget: '',
    isEncodeUrl: true,
    newShare: function (site, obj) {
        var titleText = encodeURIComponent(this.title);
        var urlText = this.isEncodeUrl ? encodeURIComponent(this.url) : this.url;
        shareUrl = ['http://api.bshare.cn/share/', site, '?url=', urlText, '&title=', titleText].join('') + '&publisherUuid=379a13ae-cd33-4bc3-bf60-34305ae74fc7';
        if (this.video != '' && this.video.length > 0) {
            shareUrl = shareUrl + ['&pic=', encodeURIComponent(this.pic), '&video=', encodeURIComponent(this.video)].join('');
        }
        if (obj) {
            obj.href = shareUrl;
            obj.target = this.linkTarget == '' ? '_target' : this.linkTarget;
        }
        return shareUrl;
    }
};
var header = {
    topUserInit: function () {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            $("#btnlogin").remove();
            $("#topwelinfo").after("<input type=\"button\" id=\"btnlogin\" class=\"int_lbt\" name=\"int_lbt\" onclick=\"header.loginout();\" value=\"退出\" />");
            $("#toplogin")[0].style.display = 'none';
            var nickname = userinfo.split("&")[1].split("=")[1];
            var username = userinfo.split("&")[2].split("=")[1];
            var uid = userinfo.split("&")[0].split("=")[1];
            $("#topwelinfo").html(" 欢迎你，<a href=\"http://forum.roadcost.com/userinfo-" + uid + ".aspx\">" + (nickname == "" ? username : nickname) + "</a>");
            $("#topwelinfo")[0].style.display = 'inline-block';
        }
        else {
            $("#btnlogin").remove();
            $("#topwelinfo").after("<input type=\"button\" id=\"btnlogin\" class=\"int_lbt\" name=\"int_lbt\" onclick=\"header.toplogin();\" value=\"登陆\" />");
            $("#toplogin")[0].style.display = 'inline-block';
            $("#topwelinfo")[0].style.display = 'none';
        };
        header.menuInit();
    },
    toplogin: function () {
        var username = $.trim($("#topname").val());
        var password = $.trim($("#toppassword").val());
        if (username == "" || password == "") {
            jsprint("#top_login", "用户名密码不能为空!", "", "Error");
        }
        else {
            var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
            common.readyHander(common.createScript(url), header.toploginlater);
        }
    },
    loginout: function () {
        common.delCookie("dnt");
        window.location.reload();
    },
    toploginlater: function () {
        if (userid > 0) {
            header.topUserInit();
            if (law.lawid > 0)
                law.askUserInit();
            if (qualify.qualifyid > 0)
                qualify.qualifyUserInit();
            if (exams.examid > 0)
                exams.examInit();
            if (exams.eid > 0)
                window.location.reload();
            if (train.trainID > 0)
                window.location.reload();
        }
        else
            jsprint("#top_login", "用户名密码错误!", "", "Error");
    },
    search: function () {
        var keyword = $.trim($("#txtkeyword").val());
        if (keyword != "") {
            window.location.href = "http://so.roadcost.com/Search.aspx?c=ALL&k=" + encodeURI(keyword);
        }
    },
    menuInit: function () {
        var cururl = window.location.pathname.toLowerCase();
        $("#nav a").each(function (i) {
            var menlink = $(this).attr("href").toLowerCase();
            menlink = menlink.replace("http://www.roadcost.com", "");
            if (cururl == "/" || cururl == "http://www.roadcost.com/") {
                $("#nav a")[0].className = 'mcur';
                return false;
            }
            else if (menlink != "/" && cururl.indexOf(menlink) > -1) {
                $(this)[0].className = 'mcur';
                return false;
            }
        })
    }
};
var user = {
    openLogin: function (login) {
        var html = '<div id="loginContain" class="login" >';
        html += '<p><a href=\"javascript:$(\'#loginContain\').closeDragwindow(false);\"> <img src="../Images/close.gif" /></a></p>';
        html += '<img src="../Images/hy_login.png" /><form>';
        html += '<span><label>用户名:</label>';
        html += '<input type="text" class="user" name="txtLoginName" id="txtLoginName"/></span>';
        html += '<span>';
        html += '<label>密码:</label>';
        html += '<input type="password" class="psw" name="txtpasswords" id="txtpasswords"  /></span>';
        html += '<span>';
        html += '<input type="checkbox" class="zd" id="chbstatus" name="chbstatus" checked="checked"/>记住我的登录状态';
        html += '</span>';
        html += '<span><input type="button" class="lg"  name="lg" value="登 录"  onclick="' + login + '" /> <a href="http://forum.roadcost.com/getpassword.aspx">忘记密码?</a> <a href="http://forum.roadcost.com/register.aspx">新用户注册';
        html += '</a></span>';
        html += '</form>';
        html += '</div>';
        $("body").append(html);
        $("#loginContain").dragwindow({ coverSelect: false, dragZone: "" });
    },
    login: function () {
        var username = $.trim($("#txtLoginName").val());
        var password = $.trim($("#txtpasswords").val());
        if ($("#chbstatus").attr("checked") == false && (username == "" || password == "")) {
            alert("用户名和密码不能为空");
            return false;
        }
        var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
        common.readyHander(common.createScript(url), user.dialogin);
    },
    dialogin: function () {
        if (userid > 0) {
            $("#loginContain").closeDragwindow(false);

        } else {
            alert("用户名和密码错误！");
        }
    }, Integral: function () {
        var html = '<div id="loginContain" class="points">';
        html += '<div class="point_top"><h4>如何获取积分<span>您可以通过以下途径获取积分:</span></h4></div>';
        html += '<div class="pitcont">';
        html += '<h2>1.上传文档</h2>';
        html += '<h3>立即上传文档文档每被下载一次<em>+文档标价</em>的积分励10个积分</h3>';
        html += '<p>标记为零的文档，每被下载一次，系统奖励 1 积分。每被下载一次，可获得文档标价积分 。被推荐为精品的额外奖</p>';
        html += '<h2>2.每次评论+2个积分</h2>';
        html += '<h3>每天最多 6 个积分。</h3>';
        html += '<p>可在文档下载详细页面相关评论板块发表对文档的评论，每评论一次奖励<em>+2</em>个积分。</p>';
        html += '<h2>3.造价答疑提问回答问题</h2>';
        html += '<p>每天最多12个积分，造价答疑频道每提问一条可以获取<em>+4</em>个积分；';
        html += '每回答一次问题并被采纳系统<em>+10</em>分并奖励问题悬赏的积分。采纳为最佳答案<em>+10</em>个积分。</p>';
        html += '<h2>4.造价论坛发帖回帖</h2>';
        html += '<p>在造价论坛积极发帖回帖也会相应有积分奖励，具体规则可以参考造价论坛的帮助。</p>';
        html += '<p style="text-align:center;"><input type="button" value="关闭窗口" onclick=\"javascript:$(\'#loginContain\').closeDragwindow(false);\" /></p>';
        html += '</div>';
        html += '<div><img src="/images/s_jf_b.gif" /></div>';
        html += '</div>';
        $("body").append(html);
        $("#loginContain").dragwindow({ coverSelect: false, dragZone: "" });
    }
};

var law = {
    lawid: 0,
    askpid: 0,
    askUserInit: function () {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            $("#logininput")[0].style.display = 'none';
            var nickname = userinfo.split("&")[1].split("=")[1];
            var username = userinfo.split("&")[2].split("=")[1];
            $("#welinfo").html("欢迎您，" + (nickname == "" ? username : nickname));
            $("#welinfo")[0].style.display = 'inline-block';
        }
        else {
            $("#logininput")[0].style.display = 'inline-block';
            $("#welinfo")[0].style.display = 'none';
        }
    },
    addAsk: function (pid) {
        var username = $.trim($("#txtusername").val());
        var password = $.trim($("#txtpassword").val());
        var txtcomment = $.trim($("#txtAsk").val());
        if (common.getCookie_decode("dnt") != null) {
            if (txtcomment == "" || txtcomment == "我有疑问（限500字）" || txtcomment == "请文明上网、理性发言！") {
                jsprint(".release", "问题不能为空!", "", "Error");
                jsprint("#sns-state", "问题不能为空!", "", "Error");
            }
            else {
                userid = common.getCookie_decode("dnt").split("&")[0].split("=")[1];
                law.postAsk(law.askpid);
            }
        }
        else if ($("#ckbnameless").attr("checked") == false && (username == "" || password == ""))
            jsprint("#logininput", "用户名密码不能为空!", "", "Error");
        else if (txtcomment == "" || txtcomment == "我有疑问（限500字）" || txtcomment == "请文明上网、理性发言！")
            jsprint("#logininput", "问题不能为空!", "", "Error");
        else if ($("#ckbnameless").attr("checked") == false) {
            var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
            common.readyHander(common.createScript(url), law.loginlater);
        }
        else {
            userid = 0;
            law.postAsk(law.askpid);
        }
    },
    loginlater: function () {
        if (userid > 0) {
            law.postAsk(law.askpid);
        }
        else
            jsprint("#logininput", "用户名密码错误!", "", "Error");
    },
    postAsk: function (pid) {
        var txtcomment = $.trim($("#txtAsk").val());
        var postUrl = "/Ashx/AjaxHandler.ashx?reqmethod=AddAsk&lid=" + law.lawid + "&userid=" + userid + "&pid=" + pid + "&comment=" + encodeURIComponent(txtcomment);
        $.post(postUrl, function (msg) {
            if (msg != "") {
                jsprint("#welinfo", "发表问题成功!", "", "Success");
            }
            window.location.href = "/Law/comment/" + law.lawid+".html";
            //window.location.href = "/Law/Ask.aspx?id=" + law.lawid;
        });
    },
    questionInit: function () {
        law.askUserInit();
        if (common.getCookie_decode("dnt") != null) {
            adminid = common.getCookie_decode("dnt").split("&")[3].split("=")[1];
            if (adminid == "1") {
                $(".pc h4 span a").css("display", "inline-block");
                $(".u_text em span a").css("display", "inline-block");
            }
            else {
                $(".pc h4 span a").css("display", "none");
                $(".u_text em span a").css("display", "none");
            }
        }
        else {
            $(".pc h4 span a").css("display", "none");
            $(".u_text em span a").css("display", "none");
        }
    },
    openQuestion: function (pid) {
        $("#askform" + pid).css("display", "block");
    },
    addQuestion: function (pid) {
        var userid = common.getCookie_decode("dnt").split("&")[0].split("=")[1];
        var txtquestion = $.trim($("#askform" + pid + " .txtarea").val());
        if (txtquestion != "" && txtquestion != "请输入回复，限500字") {
            var postUrl = "/Ashx/AjaxHandler.ashx?reqmethod=AddAsk&lid=" + law.lawid + "&userid=" + userid + "&pid=" + pid + "&comment=" + encodeURIComponent(txtquestion);
            $.post(postUrl, function (msg) {
                if (msg != "") {
                    jsprint(".chil_form", "发表问题成功!", "", "Success");
                }
                window.location.reload();
            });
        }
        else
            jsprint("#askform" + pid, "回复不能空!", "", "Error");

    },
    treeDisplay: function (obj) {
        $(".subtree").css("color", "#333333");
        $("#cate" + curcate).children("a").css("color", "#333333");
        $(obj).css("color", "#FF6200");
        if ($(obj).next(".child_tree").css("display") == "none") {
            $(obj).next(".child_tree").css("display", "block");
            $(obj).children("img").attr("src", "http://www.roadcost.com/images/bg10.gif")
        }
        else {
            $(obj).next(".child_tree").css("display", "none");
            $(obj).children("img").attr("src", "http://www.roadcost.com/images/bg09.gif")
        }
    },
    indexInit: function () {
        $("#cate" + curcate).children("a").css("color", "#FF6200");
        $(".curbg")[0].className = '';
        $("#order" + curorder)[0].className = 'curbg';
        $(".subtree").children("a").hover(
            function () {
                $(this).css("color", "#FF6200");
            },
            function () {
                $(this).css("color", "#333333");
            });
        $(".subtree").hover(
            function () {
                $(this).css("color", "#FF6200");
            },
            function () {
                $(this).css("color", "#333333");
            });
        $(".child_tree a").hover(
            function () {
                $(this).css("color", "#FF6200");
            },
            function () {
                $(this).css("color", "#333333");
            });
        $(".price_cb a").each(function (i) {
            if ($(this).attr("href").indexOf("p=" + province + "&") > -1) {
                $(this)[0].className = 'pcur';
            }
        });
    },
    lawsearch: function () {
        var keyword = $.trim($("#txtlaw").val());
        if (keyword != "" && keyword != "法律名称/内容")
            window.location = "http://so.roadcost.com/search.aspx?c=law&k=" + encodeURI(keyword);
    },
    lawInit: function (id) {
        if (id > 0) {
            document.getElementById("catet" + id).style.display = "block";
            $("#cate" + id).children("img").attr("src", "http://www.roadcost.com/images/bg10.gif");
        }
    }
};
var qualify = {
    qualifyid: 0,
    qualifyUserInit: function () {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            $("#logininput")[0].style.display = 'none';
            var nickname = userinfo.split("&")[1].split("=")[1];
            var username = userinfo.split("&")[2].split("=")[1];
            $("#welinfo").html("欢迎您，" + (nickname == "" ? username : nickname));
            $("#welinfo")[0].style.display = 'inline-block';
        } else {
            $("#logininput")[0].style.display = 'inline-block';
            $("#welinfo")[0].style.display = 'none';
        }
    },
    addqualify: function () {
        var username = $.trim($("#txtuser").val());
        var password = $.trim($("#txtpwd").val());
        var content = escape($.trim($("#txtcontent").val()));
        var star = $("#hnstar").val();
        if (common.getCookie_decode("dnt") != null) {
            userid = common.getCookie_decode("dnt").split("&")[0].split("=")[1];
            qualify.postComment();
        }
        else if ($("#savelogin").attr("checked") == false && (username == "" || password == "")) {
            jsprint(".usercomments", "用户名和密码不能为空", "", "Error");
        } else if (content == "") {
            jsprint(".usercomments", "内容不能为空", "", "Error");
        } else if (star == "") {
            jsprint(".usercomments", "对不起，您还没有给评分！", "", "Error");
        }
        else if ($("#savelogin").attr("checked") == false) {
            var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
            common.readyHander(common.createScript(url), qualify.loginlater);
        } else {
            userid = 0;
            qualify.postComment();
        }
    }, loginlater: function () {
        if (userid > 0) {
            qualify.qualifyUserInit();
            qualify.postComment();
        } else {
            jsprint(".usercomments", "用户名和密码不正确！", "", "Error");
        }
    },
    postComment: function () {
        var content = escape($.trim($("#txtcontent").val()));
        var NumberID = $("#hndid").val();
        var star = $("#hnstar").val();
        if (star == "") {
            jsprint(".usercomments", "对不起，您还没有给评分！", "", "Error");
        }
        if (content == "") {
            jsprint(".usercomments", "内容不能为空", "", "Error");
        }
        var url = "/Ashx/AjaxHandler.ashx?reqmethod=AddComment&n=" + NumberID + "&u=" + userid + "&s=" + star + "&c=" + content;
        $.post(url, function (data) {
            if (data != "") {
                jsprint(".usercomments", "发表评论成功！", "", "Success");
                $("#txtcontent").attr("value", '');
                window.location.reload();

            }
        });
    }, postQaulify: function () {
        var qaulifyname = $("#txtname").val();
        var level = $("#sltlevel").val();
        var type = $("#slttype").val();
        var areacode = $("#sltarecode").val();
        var areacode2 = $("#sltareacode2").val();
        if (qaulifyname == "输入关键字,如:企业和个人名称、资质编号" && level == "" && type == "" && areacode == "") {
            jsprint(".qc_right", "请填写好查询条件", "", "Error");
            return false;
        }
        var qulifyform = document.getElementById("qaulifyform");
        if (type == 1) {

            qulifyform.action = "http://www.roadcost.com/qualify/clist.aspx?k=" + encodeURI(qaulifyname) + "&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areacode2);
        }
        else {

            qulifyform.action = "http://www.roadcost.com/qualify/list.aspx?k=" + encodeURI(qaulifyname) + "&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areacode);
        }
        qulifyform.submit();
        return true;

    }, showSelect: function () {
        var selectNum = $("#slttype").val();
        if (selectNum == 1) {
            document.getElementById("sltarecode").style.display = "none";
            document.getElementById("sltareacode2").style.display = "";

        }
        else {
            document.getElementById("sltarecode").style.display = "";
            document.getElementById("sltareacode2").style.display = "none";

        }
    }, searchQaulify: function () {
        var name = $("#txtname").val();
        var level = $("#hlevel").val();
        var type = $("#htype").val();
        var areacode = $("#hareacode").val();
        var areaen = $("#hareaen").val();
        if (name == "输入关键字,如:企业和个人名称、资质编号" && level == "" && type == "" && areacode == "") {
            jsprint(".qc_right", "请填写好查询条件", "", "Error");
            return false;
        }
        var qaulifysearchform = document.getElementById("qaulifysearchform");
        if (type == 1) {
            qaulifysearchform.action = "http://www.roadcost.com/qualify/clist.aspx?k=" + encodeURI(name) + "&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areacode);
        }
        else {
            qaulifysearchform.action = "http://www.roadcost.com/qualify/list.aspx?k=" + encodeURI(name) + "&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areaen);
        }
        qaulifysearchform.submit();
        return true;
    }
};
var exams = {
    curid: 1,
    result: "",
    curnum: "",
    gotoKey: function (id) { //答案
        var hndid = $("#hndid_" + exams.curid).val();
        var typeid = $("#exam_" + exams.curid).text();
        var youkey = $('#YouKey').text();
        if (typeid == "多选题") {
            var num;
            if (youkey == '') {
                num = id;
            } else {
                var oldanswer = hndid + "_" + youkey + "|"; //清空原有未答完的答案值
                if (exams.result.indexOf(oldanswer) > -1)
                    exams.result = exams.result.replace(oldanswer, "");
                if (youkey.indexOf(id) == -1)//处理重复答案选项
                    num = youkey + ',' + id;
                else
                    num = youkey;
                exams.result += hndid + "_" + num + "|";
                exams.curnum += exams.curid + "=" + num + "|";
            }
            $('#YouKey').text(num);
        } else {
            $('#YouKey').text(id);
            var oldanswer = hndid + "_" + youkey + "|"; //清空原有未答完的答案值
            if (exams.result.indexOf(oldanswer) > -1)
                exams.result = exams.result.replace(oldanswer, "");
            exams.result += hndid + "_" + id + "|";
            exams.curnum += exams.curid + "=" + id + "|";
        }
        $("#div_" + exams.curid).attr("class", "ExamOrderViewVisited");
    },
    gotoValue: function (obj) { //跳至
        var num = $('#emcouont').text();
        if (obj != "" && obj <= parseInt(num) && obj >= 1) {
            if (exams.curnum.indexOf(exams.curid) == -1)
                $("#div_" + exams.curid).attr("class", "ExamOrderViewWait");
            else
                $("#div_" + exams.curid).attr("class", "ExamOrderViewVisited");

            exams.curid = parseInt(obj);
            $("#txtNum").val(obj);
            var typeid = $("#exam_" + obj).text();
            if (typeid == "判断题") {
                $("#TX2").css("display", "block");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "none");
            }
            if (typeid == "单选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "block");
                $("#TX3").css("display", "none");
            }
            if (typeid == "多选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "block");
            }

            if (exams.result.indexOf(obj) == -1)
                $('#YouKey').text('');
            else {
                var tempresult = exams.curnum.split("|");
                for (var i = 0; i < tempresult.length; i++) {
                    if (tempresult[i].indexOf(obj) > -1) {
                        var key = $('#YouKey').text(tempresult[i].split('=')[1]);
                    }
                }
            }
            var curti = $("#top_" + obj);
            $("#WinContent div").css("display", "none");
            curti.css('display', 'block');
            $("#div_" + obj).attr("class", "ExamOrderViewHover");
        }
    },
    gotoExam: function (isnext) {
        if (exams.result.indexOf(exams.curid) == -1)
            $("#div_" + exams.curid).attr("class", "ExamOrderViewWait");
        else
            $("#div_" + exams.curid).attr("class", "ExamOrderViewVisited");

        if (isnext && exams.curid != $("#WinContent div").length) {
            exams.curid += 1;
            $("#txtNum").val(exams.curid);
            var typeid = $("#exam_" + exams.curid).text();
            if (typeid == "判断题") {
                $("#TX2").css("display", "block");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "none");
            }
            if (typeid == "单选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "block");
                $("#TX3").css("display", "none");
            }
            if (typeid == "多选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "block");
            }

            if (exams.result.indexOf(exams.curid) == -1)
                $('#YouKey').text('');
            else {
                var tempresult = exams.curnum.split("|");
                for (var i = 0; i < tempresult.length; i++) {
                    if (tempresult[i].indexOf(exams.curid) > -1) {
                        $('#YouKey').text(tempresult[i].split('=')[1]);
                    }
                }
            }
        }
        if (!isnext && exams.curid != 1) {
            exams.curid -= 1;
            $("#txtNum").val(exams.curid);
            var typeid = $("#exam_" + exams.curid).text();
            if (typeid == "判断题") {
                $("#TX2").css("display", "block");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "none");
            }
            if (typeid == "单选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "block");
                $("#TX3").css("display", "none");
            }
            if (typeid == "多选题") {
                $("#TX2").css("display", "none");
                $("#TX1").css("display", "none");
                $("#TX3").css("display", "block");
            }
            if (exams.result.indexOf(exams.curid) != -1) {
                var tempresult = exams.curnum.split("|");
                for (var i = 0; i < tempresult.length; i++) {
                    if (tempresult[i].indexOf(exams.curid) > -1) {
                        $('#YouKey').text(tempresult[i].split('=')[1]);
                    }
                }
            }
            else {
                $('#YouKey').text('');
            }
        }
        var curti = $("#top_" + exams.curid);
        $("#WinContent div").css("display", "none");
        curti.css('display', 'block');
        $("#div_" + exams.curid).attr("class", "ExamOrderViewHover");
    },
    gotoText: function (id) {
        if (exams.curnum.indexOf(exams.curid) == -1)
            $("#div_" + exams.curid).attr("class", "ExamOrderViewWait");
        else
            $("#div_" + exams.curid).attr("class", "ExamOrderViewVisited");
        exams.curid = id;
        $("#div_" + id).attr("class", "ExamOrderViewHover");

        $("#txtNum").val(id);
        var typeid = $("#exam_" + id).text();
        if (typeid == "判断题") {
            $("#TX2").css("display", "block");
            $("#TX1").css("display", "none");
            $("#TX3").css("display", "none");
        }
        if (typeid == "单选题") {
            $("#TX2").css("display", "none");
            $("#TX1").css("display", "block");
            $("#TX3").css("display", "none");
        }
        if (typeid == "多选题") {
            $("#TX2").css("display", "none");
            $("#TX1").css("display", "none");
            $("#TX3").css("display", "block");
        }
        if (exams.result.indexOf(id) == -1)
            $('#YouKey').text('');
        else {
            var tempresult = exams.curnum.split("|");
            for (var i = 0; i < tempresult.length; i++) {
                if (tempresult[i].indexOf(id) > -1) {
                    $('#YouKey').text(tempresult[i].split('=')[1]);
                    $("#div_" + id).attr("class", "ExamOrderViewHover");
                }
            }
        }
        var curti = $("#top_" + id);
        $("#WinContent div").css("display", "none");
        curti.css('display', 'block');
    },
    exampost: function () {
        if (window.confirm("确认交卷吗？")) {
            parent.document.location.href = "answer.aspx?id=" + $("#hid").val() + "&an=" + exams.result;
            ///alert("测试" + exams.result);
        }
    },
    examid: 0,
    eid: 0,
    examInit: function () {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            for (var i = 0; i < exams.examid + 1; i++) {
                $("#yesadd" + i).css("display", "none");
                $("#noadd" + i).css("display", "block");
            }
        }
    },
    login: function () {
        var username = $.trim($("#txtLoginName").val());
        var password = $.trim($("#txtpasswords").val());
        if ($("#chbstatus").attr("checked") == false && (username == "" || password == "")) {
            alert("用户名和密码不能为空");
            return false;
        }
        if (username == "" && password == "") {
            alert("用户名和密码不能为空");
            return false;
        }
        var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
        common.readyHander(common.createScript(url), exams.dialogin);
    },
    dialogin: function () {
        if (userid > 0) {
            header.topUserInit();
            $("#loginContain").closeDragwindow(false);
            window.location.reload();
        } else {
            alert("用户名和密码错误！");
        }
    },
    examUser: function () {
        if (common.getCookie_decode("dnt") == null) {
            user.openLogin('javascript:exams.login();');
        }
    },
    postExam: function () {
        var name = $("#txtname").val();
        var adminid = $("#txtadmission").val();
        if (name == "" || adminid == "") {
            alert("姓名和准考证号必须填写！");
            return false;
        }
        var examform = document.getElementById("examform");
        examform.action = "examresul.aspx?n=" + encodeURI(name) + "&i=" + encodeURI(adminid);
        examform.submit();
        return true;
    },
    postExaminee: function () {
        var examineetype = $("#sltexamtype").val();
        if (examineetype == "") {
            alert("请选择好报考的级别！");
            return false;
        }
        var examineeform = document.getElementById("examineeform");
        var exmaurl = "";
        if (examineetype == "1") {
            exmaurl = "http://ostc.jtzyzg.org.cn/precostrefer/login.do?method=initLog&projectId=275";
            examineeform.action = exmaurl;
            examineeform.submit();
            return true;
        }
        if (examineetype == "2") {
            var nameEn = $("#sltareacode").val();
            if (nameEn == "") {
                alert("请选择好所要报名的省份！");
                return false;
            }
            exmaurl = "http://" + nameEn + ".roadcost.com/Office/ExamineePost.aspx?fid=8003";
            examineeform.action = exmaurl;
            examineeform.submit();
            return true;
        }
    },
    childAreaBind: function () {
        var cur = $("#sltexamtype").val();
        if (cur == 2) {

        }
    },
    childAreaBind: function () {
        var cur = $("#sltexamtype").val();
        if (cur == 2) {
            $.ajax({
                type: "Get",
                url: "/Ashx/AjaxHandler.ashx",
                data: "reqmethod=GetAreaBind&t=" + cur,
                async: false,
                success: function (msg) {
                    $("#sltareacode").remove();
                    if (msg != "") {
                        $("#spslt").after(msg);
                    }
                }
            })
        } else {
            $("#sltareacode").remove();
            $("#spslt").after("<select id='sltareacode' name='sltareacode' style='width: 100px;'><option value=''>请选择</option></select>");
        }
    }
};

var train = {
    trainID: 0,
    showTrain: function (obj) {
        var trainplay = $(obj).parent().next().css("display");
        if (trainplay == "none")
            $(obj).parent().next().css("display", "block");
        else
            $(obj).parent().next().css("display", "none");
    },
    loginTrain: function (obj) {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            window.location.href = "/Train/post.aspx?t=" + obj;
        } else {
            train.TrainUser();
        }
    },
    TrainUser: function () {
        if (common.getCookie_decode("dnt") == null) {
            user.openLogin('javascript:exams.login();');
        }
    },
    showDoc: function (obj) {
        var docplay = $(obj).next().css("display");
        if (docplay == "none") {
            $(obj).css("background", "url('/images/icon_sq.gif') no-repeat scroll right center transparent");
            $(obj).next().css("display", "block");
        }
        else {
            $(obj).css("background", "url('/images/icon_zk.gif') no-repeat scroll right center transparent");
            $(obj).next().css("display", "none");
        }
    },
    TrainInit: function () {
        var _speed = 30;
        var _slide = $("#slide");
        var _slideli1 = $(".slideli1");
        var _slideli2 = $(".slideli2");
        _slideli2.html(_slideli1.html());
        function Marquee() {
            if (_slide.scrollLeft() >= _slideli1.width())
                _slide.scrollLeft(0);
            else {
                _slide.scrollLeft(_slide.scrollLeft() + 1);
            }
        }
        $(function () {
            //两秒后调用
            var sliding = setInterval(Marquee, _speed)
            _slide.hover(function () {
                //鼠标移动DIV上停止
                clearInterval(sliding);
            }, function () {
                //离开继续调用
                sliding = setInterval(Marquee, _speed);
            });
        });
    },
    TrainSearch: function () {
        var title = $("#txttitle").val();
        var trainform = document.getElementById("frmTrainSearch");
        if ($("#radTrain").attr("checked") == false) {
            trainform.action = "list.aspx?s=" + encodeURI(title);
        } else {
            trainform.action = "list.aspx?s=" + encodeURI(title);
        }
        trainform.submit();
        return true;
    },
    getTime: function () {
        var setday = new Date();
        var Dates = setday.setDate(24);
        var Months = setday.setMonth(2);
        var years = setday.setYear(2012);
        var dayValue = setday.getTime();
        var now = new Date();
        var todayValue = now.getTime();
        var num = dayValue - todayValue;
        if (num < 0) num = 0;
        num = Math.round(num / (24 * 60 * 60 * 1000));
        document.write(num);
    }
};
var price = {
    ShowDialogManage: function (url) {
        var iWidth = 600;
        var iHeight = 320;
        var iTop = (window.screen.availHeight - 20 - iHeight) / 2;
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
        window.showModalDialog(url, window, 'dialogWidth:' + iWidth + 'px;dialogHeight:' + iHeight + 'px;dialogTop: ' + iTop + 'px; dialogLeft: ' + iLeft + 'px;center:yes;scroll:no;status:no;resizable:0;location:no');
    }
    ,
    //    showTree: function (obj) {
    //        if ($(obj).next(".box-list").css("display") == "block") {
    //            $(obj).next(".box-list").css("display", "none");
    //            $(obj).children("img").attr("src", "../images/bg09.gif");
    //        } else {
    //            $(obj).next(".box-list").css("display", "block");
    //            $(obj).children("img").attr("src", "../images/bg10.gif");
    //        }
    //    },
    //    chileShowTree: function (chile) {
    //        alert(chile);
    //        if ($(chile).next(".three_child").css("display") == "block") {
    //            $(chile).next(".three_child").css("display", "none");
    //            $(chile).children("img").attr("src", "../images/bg09.gif");
    //        } else {
    //            $(chile).next(".three_child").css("display", "block");
    //            $(chile).children("img").attr("src", "../images/bg10.gif");
    //        }
    //    },
    priceInit: function (id, pid, itemid) {
        if (id > 0) {
            if (pid > 0) {
                if (itemid > 0) {
                    document.getElementById("cate" + pid + "_chile_ljf").style.display = "block";
                    document.getElementById("cate" + itemid + "_ljf").style.display = "block";

                    $("#cate" + itemid).children("img").attr("src", "../images/bg10.gif");
                    $("#cate" + pid + "_chile").children("img").attr("src", "../images/bg10.gif");

                } else {
                    document.getElementById("cate" + pid + "_ljf").style.display = "block";

                    $("#cate" + pid).children("img").attr("src", "../images/bg10.gif");

                }
            } else {
                document.getElementById("cate" + id + "_ljf").style.display = "block";
            }
        }
    }
};
var index = {
    QLevel: function (curindex) {
        if (curindex == 1) {
            var menu1 = document.getElementById("rdrLevel1");
            var menu2 = document.getElementById("rdrLevel2");

            menu1.className = "hRadio hRadio_Checked";
            menu2.className = "hRadio";
        }
        if (curindex == 2) {
            var menu1 = document.getElementById("rdrLevel1");
            var menu2 = document.getElementById("rdrLevel2");

            menu2.className = "hRadio hRadio_Checked";
            menu1.className = "hRadio";
        }
        if (curindex == 3) {
            var menu3 = document.getElementById("rdrtype1");
            var menu4 = document.getElementById("rdrtype2");
            var select1 = document.getElementById("sltareacode");
            var select2 = document.getElementById("sltareacode2");
            select1.style.display = "none";
            select2.style.display = "";
            menu3.className = "hRadio hRadio_Checked";
            menu4.className = "hRadio";
        }
        if (curindex == 4) {
            var menu3 = document.getElementById("rdrtype1");
            var menu4 = document.getElementById("rdrtype2");
            var select1 = document.getElementById("sltareacode");
            var select2 = document.getElementById("sltareacode2");
            select1.style.display = "";
            select2.style.display = "none";
            menu4.className = "hRadio hRadio_Checked";
            menu3.className = "hRadio";
        }
    }, IndexsearchQaulify: function () {
        var level = 0;
        var rdrLevel1 = document.getElementById("rdrLevel1");
        var rdrLevel2 = document.getElementById("rdrLevel2");
        if (rdrLevel1.className == "hRadio hRadio_Checked") {
            level = 1;
        }
        if (rdrLevel2.className == "hRadio hRadio_Checked") {
            level = 2;
        }
        var type = 1;
        var type1 = document.getElementById("rdrtype1");
        var type2 = document.getElementById("rdrtype2");
        var areacode = $("#sltareacode2").val();
        var qualifyfrm = document.getElementById("qualifyfrm");
        if (type1.className == "hRadio hRadio_Checked") {
            type = 1;
            areacode = $("#sltareacode2").val();

        }
        if (type2.className == "hRadio hRadio_Checked") {
            type = 2;
            areacode = $("#sltareacode").val();

        }
        if (document.getElementById("sltareacode").style.display == "none") {
            qualifyfrm.action = "http://www.roadcost.com/qualify/clist.aspx?k=&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areacode);
        }
        else {
            qualifyfrm.action = "http://www.roadcost.com/qualify/list.aspx?k=&l=" + encodeURI(level) + "&t=" + encodeURI(type) + "&code=" + encodeURI(areacode);
        }
        qualifyfrm.submit();
        return true;

    },
    setTab: function (strDivIdBlock, strListIdBlock, strDivStyleBlock, displayNumber, allNumber) {
        for (var i = 1; i <= allNumber; i++) {
            document.getElementById(strDivIdBlock + i).className = "";
            document.getElementById(strListIdBlock + i).style.display = "none";
        }
        document.getElementById(strDivIdBlock + displayNumber).className = strDivStyleBlock;
        document.getElementById(strListIdBlock + displayNumber).style.display = "block";
    },
    marginTop: function () {
        var _wrap = $('ul.line');
        var _interval = 2000;
        var _moving;
        _wrap.hover(function () {
            clearInterval(_moving);
        }, function () {
            _moving = setInterval(function () {
                var _field = _wrap.find('li:first');
                var _h = _field.height();
                _field.animate({ marginTop: -_h + 'px' }, 600, function () {
                    _field.css('marginTop', 0).appendTo(_wrap);
                })
            }, _interval)
        }).trigger('mouseleave');
    }
};

var Video = {
    Speed: 0.01, //速度(毫秒)
    Space: 5, //每次移动(px)
    PageWidth: 150, //翻页宽度
    fill: 0, //整体移位
    MoveLock: false,
    MoveTimeObj: null,
    Comp: 0,
    AutoPlayObj: null,
    VideoInit: function () {
        Video.GetObj("List2").innerHTML = Video.GetObj("List1").innerHTML;
        Video.GetObj('ISL_Cont').scrollLeft = Video.fill;
        Video.GetObj("ISL_Cont").onmouseover = function () { clearInterval(Video.AutoPlayObj); }
    },
    GetObj: function (objName) {//上翻开始
        if (document.getElementById) { return eval('document.getElementById("' + objName + '")') } else { return eval('document.all.' + objName) }
    },
    ISL_GoUp: function () {
        if (Video.MoveLock) return;
        Video.MoveLock = true;
        Video.MoveTimeObj = setInterval('Video.ISL_ScrUp();', Video.Speed);
    },
    ISL_StopUp: function () {//上翻停止
        clearInterval(Video.MoveTimeObj);
        if (Video.GetObj('ISL_Cont').scrollLeft % Video.PageWidth - Video.fill != 0) {
            Video.Comp = Video.fill - (Video.GetObj('ISL_Cont').scrollLeft % Video.PageWidth);
            Video.CompScr();
        } else {
            Video.MoveLock = false;
        }
    },
    ISL_ScrUp: function () {  //上翻动作
        if (Video.GetObj('ISL_Cont').scrollLeft <= 0) { Video.GetObj('ISL_Cont').scrollLeft = Video.GetObj('ISL_Cont').scrollLeft + Video.GetObj('List1').offsetWidth }
        Video.GetObj('ISL_Cont').scrollLeft -= Video.Space;
    },
    ISL_GoDown: function () { //下翻
        clearInterval(Video.MoveTimeObj);
        if (Video.MoveLock) return;
        Video.MoveLock = true;
        Video.ISL_ScrDown();
        Video.MoveTimeObj = setInterval('Video.ISL_ScrDown()', Video.Speed);
    },
    ISL_StopDown: function () { //下翻停止
        clearInterval(Video.MoveTimeObj);
        if (Video.GetObj('ISL_Cont').scrollLeft % Video.PageWidth - Video.fill != 0) {
            Video.Comp = Video.PageWidth - Video.GetObj('ISL_Cont').scrollLeft % Video.PageWidth + Video.fill;
            Video.CompScr();
        } else {
            Video.MoveLock = false;
        }
    },
    ISL_ScrDown: function () { //下翻动作
        if (Video.GetObj('ISL_Cont').scrollLeft >= Video.GetObj('List1').scrollWidth) { Video.GetObj('ISL_Cont').scrollLeft = Video.GetObj('ISL_Cont').scrollLeft - Video.GetObj('List1').scrollWidth; }
        Video.GetObj('ISL_Cont').scrollLeft += Video.Space;
    },
    CompScr: function () {
        var num;
        if (Video.Comp == 0) { Video.MoveLock = false; return; }
        if (Video.Comp < 0) { //上翻
            if (Video.Comp < -Video.Space) {
                Video.Comp += Video.Space;
                num = Video.Space;
            } else {
                num = -Video.Comp;
                Video.Comp = 0;
            }
            Video.GetObj('ISL_Cont').scrollLeft -= num;
            setTimeout('Video.CompScr()', Video.Speed);
        } else { //下翻
            if (Video.Comp > Video.Space) {
                Video.Comp -= Video.Space;
                num = Video.Space;
            } else {
                num = Video.Comp;
                Video.Comp = 0;
            }
            Video.GetObj('ISL_Cont').scrollLeft += num;
            setTimeout('Video.CompScr()', Video.Speed);
        }
    },
    commentUserInIt: function () {
        var userinfo = common.getCookie_decode("dnt");
        if (userinfo != null) {
            $("#logininput")[0].style.display = 'none';
            var nickname = userinfo.split("&")[1].split("=")[1];
            var username = userinfo.split("&")[2].split("=")[1];
            var uid = userinfo.split("&")[0].split("=")[1];
            $("#welinfo").html(" 欢迎您，<a href=\"http://forum.roadcost.com/userinfo-" + uid + ".aspx\">" + (nickname == "" ? username : nickname) + "</a>");
            $("#welinfo")[0].style.display = 'inline-block';
        } else {
            $("#logininput")[0].style.display = 'inline-block';
            $("#welinfo")[0].style.display = 'none';
        }
    },
    addComment: function () {
        var username = $("#txtname").val();
        var password = $("#txtpwd").val();
        var content = $.trim($("#txtcontent").val());
        if (common.getCookie_decode("dnt") != null) {
            if (content == "请文明上网、理性发言！" || content == "" || content == "我有疑问（限500字）") {
                jsprint(".release", "咨询内容不能为空", "", "Error");
            } else {
                userid = common.getCookie_decode("dnt").split("&")[0].split("=")[1];
                Video.postComment();
            }
        } else if ($("#savelogin").attr("checked") == false && (username == "" || password == "")) {
            jsprint(".release", "用户名和密码不能为空", "", "Error");
        } else if (content == "请文明上网、理性发言！" || content == "" || content == "我有疑问（限500字）") {
            jsprint(".release", "咨询内容不能为空", "", "Error");
        } else if ($("#savelogin").attr("checked") == false) {
            var url = "http://forum.roadcost.com/ajax/login.ashx?username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password);
            common.readyHander(common.createScript(url), Video.loginlater);
        } else {
            userid = 0;
            Video.postComment();
        }
    },
    loginlater: function () {
        if (userid > 0) {
            header.topUserInit();
            Video.commentUserInIt();
            Video.postComment();
        } else {
            jsprint(".release", "用户名和密码不正确！", "", "Error");
        }
    },
    postComment: function () {
        var content = $.trim($("#txtcontent").val());
        var CategoryID = $("#hndcid").val();
        var number = $("#hndnumber").val();
        if (content == "请文明上网、理性发言！" || content == "" || content == "我有疑问（限500字）") {
            jsprint(".release", "咨询内容不能为空", "", "Error");
        }
        var url = "/Ashx/AjaxHandler.ashx?reqmethod=AddQuestion&u=" + userid + "&t=" + CategoryID + "&c=" + content + "&n=" + number;
        $.post(url, function (msg) {
            if (msg != "") {
                jsprint(".release", "发表咨询成功！", "", "Success");
            }
        });
    },
    addDocPaly: function (obj) {
        var docplay = $("#relexist" + obj).css("display");
        if (docplay == "none") {
            $("#relexist" + obj).css("display", "block");
        }
        else {
            $("#relexist" + obj).css("display", "none");
        }
    },
    addAnswer: function () {
        var content = $.trim($("#txtanswer").val());
        if (common.getCookie_decode("dnt") != null) {
            if (content == "请文明上网、理性发言！" || content == "" || content == "我有疑问（限500字）") {
                alert("回复内容不能为空！");
                return false;
            } else {
                userid = common.getCookie_decode("dnt").split("&")[0].split("=")[1];
                Video.postAnswer();
            }
        }
    },
    postAnswer: function () {
        var answer = $.trim($("#txtanswer").val());
        var QuestionID = $("#hndQuestion").val();
        if (answer == "请文明上网、理性发言！" || answer == "" || answer == "我有疑问（限500字）") {
            alert("回复内容不能为空！");
            return false;
        }
        var url = "/Ashx/AjaxHandler.ashx?reqmethod=AddAnswer&u=" + userid + "&c=" + answer + "&q=" + QuestionID;
        $.post(url, function (msg) {
            if (msg != "") {
                alert("回复成功！");
            }
        });
    }
};

var fixd = {
    showList: function (div_id) {
        var obj = document.getElementById(div_id + "_ljf");
        if (obj.style.display == "none") {
            obj.style.display = "block";
            $("#" + div_id).children("img").attr("src", "../images/bg10.gif");
        }
        else {
            obj.style.display = "none";
            $("#" + div_id).children("img").attr("src", "../images/bg09.gif");
        }
    },
    search: function () {
        var keyword = $.trim($("#txttitle").val());
        if (keyword != "") {
            window.location.href = "http://so.roadcost.com/Search.aspx?c=ALL&k=" + encodeURI(keyword);
        }
    },
    fixdInit: function (obj, id, itemid, fixdID) {
        if (obj > 0) {
            if (itemid > 0) {
                document.getElementById("pNode" + itemid + "_ljf").style.display = "block";
            } else {
                document.getElementById("pNode" + obj + "_ljf").style.display = "block";
            }
        }
        if (id > 0) {
            if (itemid > 0) {
                if (itemid != obj) {
                    document.getElementById("pNode" + obj + "_sub2_ljf").style.display = "block";

                    $("#pNode" + itemid).children("img").attr("src", "../images/bg10.gif");
                    $("#pNode" + obj + "_sub2").children("img").attr("src", "../images/bg10.gif");
                } else {
                    document.getElementById("pNode" + id + "_sub2_ljf").style.display = "block";
                    document.getElementById("pNode" + fixdID + "_sub3_ljf").style.display = "block";

                    $("#pNode" + itemid).children("img").attr("src", "../images/bg10.gif");
                    $("#pNode" + id + "_sub2").children("img").attr("src", "../images/bg10.gif");
                }
            } else {
                if (itemid == 0) {
                    if (obj == id)
                        $("#pNode" + obj).children("img").attr("src", "../images/bg10.gif");
                    else {
                        document.getElementById("pNode" + id + "_sub2_ljf").style.display = "block";
                        $("#pNode" + id + "_sub2").children("img").attr("src", "../images/bg10.gif");
                    }


                } else {
                    document.getElementById("pNode" + id + "_sub2_ljf").style.display = "block";

                    $("#pNode" + id + "_sub2").children("img").attr("src", "../images/bg10.gif");
                    $("#pNode" + obj).children("img").attr("src", "../images/bg10.gif");
                }
            }
        }
        if (itemid > 0) {
            if (id > 0) {
                if (obj != itemid)
                    document.getElementById("pNode" + id + "_sub3_ljf").style.display = "block";
                $("#pNode" + id + "_sub3").children("img").attr("src", "../images/bg10.gif");
            } else {
                document.getElementById("pNode" + itemid + "_sub3_ljf").style.display = "block";
                $("#pNode" + id + "_sub3").children("img").attr("src", "../images/bg10.gif");
            }
        } else {
            $("#pNode" + obj).children("img").attr("src", "../images/bg10.gif");
        }
    }
};
