﻿//定义移动对象和移动坐标
var Mouse_Obj = "none", _x, _y;
//拖动对象函数(自动)
document.onmousemove = function() {
    if (Mouse_Obj !== "none") {
        document.getElementById(Mouse_Obj).style.left = _x + event.x;
        document.getElementById(Mouse_Obj).style.top = _y + event.y;
        event.returnValue = false;
    }
}
//停止拖动函数(自动)
document.onmouseup = function() {
    Mouse_Obj = "none";
}
//确定被拖动对象函数 o为被拖动对象
function m(o) {
    Mouse_Obj = o;
    _x = parseInt(document.getElementById(Mouse_Obj).style.left) - event.x;
    _y = parseInt(document.getElementById(Mouse_Obj).style.top) - event.y;
}
var lastScrollY = 0;
function heartBeat() {
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop
    else
    { /*Netscape stuff*/ }

    //alert(diffY);
    percent = .1 * (diffY - lastScrollY);
    if (percent > 0) percent = Math.ceil(percent);
    else percent = Math.floor(percent);
    document.getElementById("darea").style.top = parseInt(document.getElementById("darea").style.top) + percent + "px";
    lastScrollY = lastScrollY + percent;
    //alert(lastScrollY);
}
window.setInterval("heartBeat()", 1);
function goRegister() {
    window.location.href = "http://www.ypw.com.cn/Enterprise/EnterpriseRegister.aspx";
}
function goLogin() {
    window.location.href = "http://www.ypw.com.cn/Enterprise/EnterpriseLogin.aspx";
}
function GetErro() {
    ymPrompt.errorInfo({ message: $("#divtext").html(), width: 360, height: 200, title: "操作提示", handler: null });
}

function handler2(tp) {
    if (tp == 'ok') {
        window.location.href = "/";
    }

}
$(function() {
    $("#slt_job").html(showALLJobtype());
    for (var i = 1; i <= $("#joblist>li").length; i++) {
        if ($("#job" + i).attr("title") != "" && $("#job_" + i).attr("title") != undefined) {
            var job1 = $("#slt_job option[value='" + $("#job_" + i).attr("title") + "']").text().length > 3 ? $("#slt_job option[value='" + $("#job_" + i).attr("title") + "']").text().substring(0, 2) + "..." : $("#slt_job option[value='" + $("#job_" + i).attr("title") + "']").text();
            $("#job_" + i).text(job1);
            $("#job_" + i).attr("title", $("#slt_job option[value='" + $("#job_" + i).attr("title") + "']").text());
        }
        else {
            $("#job_" + i).text("不详");
        }

    }
    $("#ctl00_ContentPlaceHolderMain_loginPwd").keydown(function(e) {
        if (e.keyCode == 13) {
            $("#ctl00_ContentPlaceHolderMain_defUserlogin").click();
        }
    });


    $("#txt_name").click(function() {
        $("#txt_name").val("");
    })

    $("#link_index").click(function() {
    if ($("#link_index").attr("rel") == "0") { ymPrompt.errorInfo("请登录先！！", null, null, "操作提示", null); return false; }

        ymPrompt.confirmInfo('你确定要出现在这里吗？该项会扣除你100积分！', null, null, null, handler3)
        function handler3(tp) {
            if (tp == "ok") {
                $.ajax({
                    url: " /modify/resume.ashx?" + Math.random(),
                    type: "get",
                    data: { id: "toRecommend" },
                    error: function() {
                        alert("有错误");
                    },
                    success: function(data, status) {
                        if (data == 0) {
                            ymPrompt.errorInfo("你已经出现在这里了哦！！", null, null, "操作提示", null);
                        } else
                            if (data == 1) {
                            GetErro();
                        }
                        else
                            if (data == 2) {
                            ymPrompt.succeedInfo("推荐成功!!<br>你已被扣除100积分!!<br><a href=\"/home/Integral.aspx\" style=\"color:#ff0000;\">查看我的积分!!>>></a>", null, null, "操作提示", handler2);
                        }

                    }
                });
            }
        }
    })
    $("#btn_search").click(function() {
        var area = "", name = "";
        if ($("#btn_area").text() != "地区") {
            area = "&area=" + escape($("#btn_area").text());
        }
        if ($("#txt_name").val() != "输入您想去应聘的单位和职位" && $("#txt_name").val() != "") {
            name = "&name=" + escape($("#txt_name").val());
        }
        var url = "http://www.ypw.com.cn/search/?" + area + name;
        window.location.href = url;
    })
    $("#recommend li a").click(function() {
        var mycomid = $(this).attr("id");
        $.ajax({
            url: " /modify/Enterprise.ashx?" + Math.random(),
            type: "get",
            data: { id: "comclick", val: mycomid },
            error: function() {
                alert("有错误");
            },
            success: function(data, status) {
            }
        });
    })
    $("#recommend li span a").click(function() {
        var myjobid = $(this).attr("id");
        $.ajax({
            url: " /modify/Enterprise.ashx?" + Math.random(),
            type: "get",
            data: { id: "jobclick", val: myjobid },
            error: function() {
                alert("有错误");
            },
            success: function(data, status) {
            }
        });
    })
});

