﻿$(function () {

    //设置热门关键字链接
    var url2 = "http://60.211.177.242:86/siteinfo/searchresult?name=" + escape("会计");
    var url3 = "http://60.211.177.242:86/siteinfo/searchresult?name=" + escape("设计");
    var url4 = "http://60.211.177.242:86/siteinfo/searchresult?name=" + escape("计算机");
    var url5 = "http://60.211.177.242:86/siteinfo/searchresult?name=" + escape("经理助理");
    var url6 = "http://60.211.177.242:86/siteinfo/searchresult?name=" + escape("机械");
    $("#url2").attr("href", url2);
    $("#url3").attr("href", url3);
    $("#url4").attr("href", url4);
    $("#url5").attr("href", url5);
    $("#url6").attr("href", url6);

    //输入框样式控制
    $("#jobkeyword").focus(function () {
        $(this).attr("value", "");
    }).blur(function () {
        if ($(this).attr("value") == "") {
            $(this).attr("value", "请输入职位名称关键字");
        }
    });
    $("#unitname").focus(function () {
        $(this).attr("value", "");
    }).blur(function () {
        if ($(this).attr("value") == "") {
            $(this).attr("value", "请输入单位名称关键字");
        }
    });

    //最新职位&最新人才样式控制
    $(".unit_positions").each(function () {
        var pos = $(this);
        var pos_content = 0;
        pos.find("a").each(function () {
            pos_content += $(this).text().length;
        });
        while (pos_content >= 50) {
            var poslasta = pos.find("a:last");
            pos_content -= poslasta.text().length;
            poslasta.remove();
            pos.find("span:last").remove();
        }
        pos.find("span:last").remove();
    });
    $(".newjob_content_tr:even").css("background-color", "#f5f5f5");
    $(".newtalent_content_tr:even").css("background-color", "#f5f5f5");

    //快速搜索提交按钮事件
    $("#search_job_res").click(
        function (e) {
            var p_selected_string = "";
            var p_selected_length = $(".p_selected").length;
            var jobkeyword_sb = $("#jobkeyword_sb");
            var unitname_sb = $("#unitname_sb");
            var positions_sb = $("#positions_sb");
            var jobkeyword = $("#jobkeyword");
            var unitname = $("#unitname");
            if (p_selected_length > 0) {
                $(".p_selected").each(function (index, element) {
                    p_selected_string += $(this).attr("id");
                    if (index + 1 != p_selected_length) p_selected_string += "|";
                });
                positions_sb.val(p_selected_string);
            }
            else positions_sb.val("");
            if (jobkeyword.val() != "请输入职位名称关键字") jobkeyword_sb.val($("#jobkeyword").val());
            else jobkeyword_sb.val("");
            if (unitname.val() != "请输入单位名称关键字") unitname_sb.val($("#unitname").val());
            else unitname_sb.val("");
            if ((jobkeyword_sb.val() != "") | (unitname_sb.val() != "" | positions_sb.val() != "")) {
                $("#SearchPosForm").submit();
            }
            else alert("请确认至少一种搜索条件！");
        }
    );

    //中间区域新闻列表动态标签
    $(".title div").mousemove(function () {
        var id_t = $(this).attr("id") + "_t";
        var id_bac = "main_top_" + $(this).attr("id").substring(10);
        $("#news_content .w480 .title").css("background-image", "url(../Content/Images/" + id_bac + ".gif)");
        $(".w480 .content_mid iframe").hide();
        $("#" + id_t).show();
    });

    //右侧滚动图片广告
    var option = {
        preload: true,
        play: 3500,
        pause: 1000,
        hoverPause: true
    };
    $('#slides').slides(option);

    //固定招聘会最新职位上下滚动控制
    $("#zxzw_gdzph_right_content li:even").addClass("alt");
    $("#zxzw_gdzph_right_content").Scroll({ line: 1, speed: 500, timer: 2000 });
    $("#zxzw_gdzph_right_content li").each(function () {
        var pos = $(this).html();
        var pos_exp = pos.substr(0, pos.length - 2);
        $(this).empty();
        $(this).append(pos_exp);
    });

    //大型招聘会最新职位上下滚动控制
    $("#zxzw_dxzph_right_content li:even").addClass("alt_red");
    $("#zxzw_dxzph_right_content").Scroll({ line: 1, speed: 500, timer: 2000 });
    $("#zxzw_dxzph_right_content li").each(function () {
        var pos = $(this).html();
        var pos_exp = pos.substr(0, pos.length - 2);
        $(this).empty();
        $(this).append(pos_exp);
    });

    //设置滚动广告
    my = setInterval("m()", 30);
});
var x = 0, y = 0, xpos = 0, ypos = 0;
function m() {
    if (x >= $(window).width() - $("#a").width()) { xpos = 1 }
    if (y >= $(window).height() - $("#a").height()) { ypos = 1 }
    if (x < 0) { xpos = 0 }
    if (y < 0) { ypos = 0 }
    if (xpos) { x-- } else { x++ }
    if (ypos) { y-- } else { y++ }
    $("#a").animate({ left: x + "px", top: y + "px" }, 10);
}
