﻿window.onload = function () {
    //createFlaotAd(); //不用则屏蔽
    // createPostionTable();
    checkLoginState();
    var url = document.location.href.toLocaleLowerCase();
    if (url.indexOf("default2.aspx") != -1) { //红豆网合作
        setTimeout("document.getElementById(\"if_Enterprise\").setAttribute(\"src\", \"/DS/GuiLin/NewEnterprise.aspx?hongdou=1\")", 2000);
    }
    else {//默认
        setTimeout("document.getElementById(\"if_Enterprise\").setAttribute(\"src\", \"/DS/GuiLin/NewEnterprise.aspx\")", 2000);
    }
}

var path = "/";
function getIndustry() {
    makePopup(popType.Industry, path, 'maxCount=1&focus=true&tid=txtIndustry&hid=Industry', 'IndustrySelectWin');
}
function getExpectCareer() {
    makePopup(popType.Position, path, 'maxCount=1&focus=true&tid=txtPosition&hid=PosType', 'PositionSelectWin');
}
function getWorkDistrict() {
    makePopup(popType.DistrictOld, path, 'maxCount=1&focus=true&tid=txtDistrict&hid=District', 'DistrictNew');
}
function getExpectCareer1() {
    makePopup(popType.Position, path, 'maxCount=1&focus=true&tid=txtPos1&hid=hidPos1', 'PositionSelectWin');
}
function getSpecial() {
    makePopup(popType.Specialty, path, 'maxCount=1&focus=true&tid=txtSpecial&hid=hidSpecial', 'Special');
}
function showpos(para) {
    var seldiv1 = document.getElementById("pos1");
    var seldiv2 = document.getElementById("pos2");
    var div1 = document.getElementById("position_NewPublish");
    var div2 = document.getElementById("Ent_NewPublish");
    if (para == 1) {
        seldiv1.style.display = "block";
        seldiv2.style.display = "none";
        div1.style.display = "block";
        div2.style.display = "none";
    }
    else {
        seldiv1.style.display = "none";
        seldiv2.style.display = "block";
        div1.style.display = "none";
        div2.style.display = "block";
    }
}
function turnForm(para) {
    var seldiv1 = document.getElementById("turn1");
    var seldiv2 = document.getElementById("turn2");
    var otb1 = document.getElementById("tb1");
    var otb2 = document.getElementById("tb2");
    var a1 = document.getElementById("a_findPosition");
    if (para == 1) {
        seldiv1.style.display = "block";
        seldiv2.style.display = "none";
        otb1.style.display = "block";
        otb2.style.display = "none";
        a1.href = "/ds/positionSearch/PositionSearchResult.aspx?DS=1";
    }
    else {
        seldiv1.style.display = "none";
        seldiv2.style.display = "block";
        otb1.style.display = "none";
        otb2.style.display = "block";
        a1.href = "FindJobseeker.aspx";
    }
}
function formnew(p_id, p_title, p_aTitle, p_length, p_isRed, p_url) {
    var v_newtitle = "";
    if (p_title.length >= p_length)
        v_newtitle = p_title.substring(0, p_length) + "...";
    else
        v_newtitle = p_title;

    document.write("<a style='float:left;" + (p_isRed == "True" ? "color:red;'" : "'") + " target='_blank' href='/ds/guilin/webpage/gxrcnews.aspx?ArticleID=" + p_id + "' title=" + p_aTitle + " >" + v_newtitle + "</a>");
}

function formbiglogo(p_type, p_href, p_src) {
    var str = "";
    if (p_type == "pic") {
        str = "<a href='" + p_href + "' target='_blank'><img src='" + p_src + "' /></a>";
        document.write(str);
    }
    else {
        AC_FL_RunContent('codebase', ' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0', 'width', '396', 'height', '75', 'wmode', 'opaque', 'src', 'Images/企业后台-2009中高级人才交流大会002', 'quality', 'high', 'pluginspage', ' http://www.macromedia.com/go/getflashplayer', 'movie', p_src); //end AC code
    }
    // document.write("<a target='_blank' href='webpage/gxrcnews.aspx?ArticleID=" + p_id + "' title=" + p_aTitle + " >" + v_newtitle + "</a>");

}
function makeSearch() {
    if (document.getElementById("tb2").style.display == "none") {
        var District = document.getElementById("District").value;
        var DistrictName = document.getElementById("txtDistrict").value;
        var PosType = document.getElementById("PosType").value;
        var PosTypeName = document.getElementById("txtPosition").value;
        var PublicTime = document.getElementById("ddlPublicTime").value;
        var Industry = document.getElementById("txtIndustry").value;
        var keyword = document.getElementById("txtEntName").value;
        var schTypeVal = 1; //1按职位名称搜索，2是按职位名称搜索
        if (Industry > 0 || District > 0 || PosType > 0 || PublicTime > 0 || keyword.length > 0) {
            var tempA = document.getElementById("APosSearch");
            tempA.href = "/ds/positionSearch/PositionSearchResult.aspx?Industry=" + Industry + "&District=" + District + "&PosType=" + PosType + "&DistrictName=" + escape(DistrictName) + "&PublicTime=" + PublicTime + "&PosTypeName=" + escape(PosTypeName) + "&keyword=" + escape(keyword) + "&schTypeVal=" + schTypeVal + "&DS=1";
            tempA.click();
        }
        else {
            alert("请指定有效的搜索条件...");
        }
        return false;
    }
    else {
        var url = "/ds/guilin/FindJobSeeker.aspx?EducationDegree=" + document.getElementById("ddl_EduDegree").value;
        if (document.getElementById("hidPos1").value != "") {
            url += "&ExpectCareer=" + document.getElementById("hidPos1").value + "&ExpectCareerName=" + document.getElementById("txtPos1").value;
        }
        if (document.getElementById("hidSpecial").value != "") {
            url += "&HighestEducationSpecialty=" + document.getElementById("hidSpecial").value + "&HighestEducationSpecialtyName=" + document.getElementById("txtSpecial").value;
        }
        url += "&JobSeekerTalentDegree=" + document.getElementById("ddl_TalentDegree").value;
        document.location.href = url;
        //window.open(url, "_blank", "height=768,width=1024");
    }
}

//浮动广告
function createFlaotAd() {
    if ((floatAd_s == "") || (floatAd_s == null)) {
        return;
    }
    var ad = document.createElement("div");
    ad.appendChild(createAd(floatAd_s, floatAd_t, floatAd_l, ""));
    ad.setAttribute("id", "div_FloatAd")
    //document.body.appendChild(ad);
    document.getElementById("tmpFloat").appendChild(ad);

    var delay = 20; //层移动的时间间隔,单位为毫秒，值越小移动速度越快

    //如果需要显示漂浮广告，请注释掉下面这行代码，然后回复下面那三条已经注释掉的代码
    //document.getElementById("fudongand").style.display="none";
    var itl = setInterval("floatAD()", delay);
    ad.onmouseover = function () { clearInterval(itl) }
    ad.onmouseout = function () { itl = setInterval("floatAD()", delay) }
}
var fAd_x = 50, fAd_y = 60;
var xin = true, yin = true;

//包含广告图片的a标签
function createAd(p_Src, p_Tilte, p_Link, p_ClassName) {
    var v_img = document.createElement("img");
    v_img.setAttribute("src", p_Src);
    v_img.setAttribute("title", p_Tilte);
    v_img.className = p_ClassName;
    var v_a = document.createElement("a");
    v_a.setAttribute("href", p_Link);
    v_a.setAttribute("target", "_blank");
    v_a.appendChild(v_img);

    return v_a;
}

function floatAD() {
    var ad = document.getElementById("div_FloatAd");
    var step = 1; //层移动的步长，值越大移动速度越快
    var L = T = 0;
    var R = document.documentElement.clientWidth - ad.offsetWidth;
    var B = document.documentElement.clientHeight - ad.offsetHeight;
    ad.style.left = fAd_x + document.documentElement.scrollLeft + "px";
    ad.style.top = fAd_y + document.documentElement.scrollTop + "px";
    fAd_x = fAd_x + step * (xin ? 1 : -1);
    if (fAd_x < L) { xin = true; fAd_x = L; }
    if (fAd_x > R) { xin = false; fAd_x = R; }
    fAd_y = fAd_y + step * (yin ? 1 : -1)
    if (fAd_y < T) { yin = true; fAd_y = T; }
    if (fAd_y > B) { yin = false; fAd_y = B; }
}

//显示企业最新的职位
function showPNames(event, objID) {
    var x, y;
    if (document.all) {//  IE
        x = window.event.x + document.documentElement.scrollLeft;
        y = window.event.y + document.documentElement.scrollTop;
    } else if (document.layers || document.getElementById) {    //  Netscape
        x = event.pageX;
        y = event.pageY;
    }
    var obj = document.getElementById(objID);
    obj.style.display = "block";
    obj.style.left = (x) + "px";
    obj.style.top = (y + 20) + "px";
}
function hidPNames(objID) {
    document.getElementById(objID).style.display = "none";
}


function $(o) { return (typeof o == "object") ? o : document.getElementById(o); }
var UI = {
    undefined: undefined,
    setDisplay: function (dType, args) {
        var display = (dType === 0 ? "none" : "block");
        var arg;
        while (arg = args.pop()) {
            arg.style.display = display;
        }
    },
    show: function () {
        UI.setDisplay(1, [].slice.call(arguments, 0));
    },
    hide: function () {
        UI.setDisplay(0, [].slice.call(arguments, 0));
    },
    replaceClass: function (obj, oldClassName, newClassName) {
        obj.className = obj.className.replace(oldClassName, newClassName);
    },
    addClass: function (obj, className) {
        obj.className += " " + className;
    }
};
//职位列表的浮动层
function showPos(p_srcElement, p_entID, p_PageID) {
    if (!$("entPosLogo" + p_entID)) return;
    $("entPosLogo" + p_entID).src = p_srcElement.getAttribute("src");
    var obj = $("entPos" + p_entID);
    obj.onclick = function () { AddLogoCLick(p_PageID); }
    if (obj) {
        var x = -6, y = -5;
        //        while (p_srcElement.offsetParent) {
        //            x += p_srcElement.offsetLeft;
        //            y += p_srcElement.offsetTop;
        //            p_srcElement = p_srcElement.offsetParent;
        //        }
        //直接使用getBoundingClientRect来获取目标元素的位置
        var oRect = p_srcElement.getBoundingClientRect();
        x += oRect.left; //+ Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);
        y += oRect.top + Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        obj.style.left = x + "px";
        obj.style.top = y + "px";
        UI.show(obj);
        //阴影
        var shadow = $(obj.id + "shadow");
        if (!shadow) {
            shadow = document.createElement("div");
            shadow.setAttribute("id", obj.id + "shadow")
            shadow.className = "popupPos-shadow";
            shadow.style.height = (obj.clientHeight + 4) + "px"; //边框为2
            document.body.appendChild(shadow);
        }
        shadow.style.left = x + 2 + "px";
        shadow.style.top = y + 2 + "px";

        UI.show(shadow);
    }
}

function hidPos(p_entID) {
    if (!$("entPosLogo" + p_entID)) return;
    UI.hide($("entPos" + p_entID), $("entPos" + p_entID + "shadow"));
}
function showPosSelf(obj) {
    UI.show(obj, $(obj.id + "shadow"));
}
function hidPosSelf(obj) {
    UI.hide(obj, $(obj.id + "shadow"));
}

function AddLogoCLick(LogoUrl, purl) {

    var url = "/Enterprise/AjaxLogo.aspx?LogoUrl=" + escape(LogoUrl) + "&Pic=1"; //定义网址参数
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function () { BackAddLogoClick(); };
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
    if (arguments.length == 2) {
        if (arguments[1] == "#") return false;
        window.open(purl);
    }
    return false;
}

function BackAddLogoClick(result) {
    if (xmlHttp.readyState == 4) {// 收到完整的服务器响应 
        if (xmlHttp.status == 200) {//HTTP服务器响应的值OK
            var str = xmlHttp.responseText; //将服务器返回的字符串写到页面中ID为message的区域 
            //alert(str);
        }
        else {
            //alert(http_request.status); 
        }
    }
}
