﻿function Marquee() {
    this.ID = document.getElementById(arguments[0]);
    if (!this.ID) {
        alert("您要设置的\"" + arguments[0] + "\"初始化错误\r\n请检查标签ID设置是否正确!");
        this.ID = -1;
        return;
    }
    this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.Correct = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
    this.Step = 1;
    this.Timer = 30;
    this.DirectionArray = { "top": 0, "bottom": 1, "left": 2, "right": 3 };
    if (typeof arguments[1] == "number") this.Direction = arguments[1];
    if (typeof arguments[2] == "number") this.Step = arguments[2];
    if (typeof arguments[3] == "number") this.Width = arguments[3];
    if (typeof arguments[4] == "number") this.Height = arguments[4];
    if (typeof arguments[5] == "number") this.Timer = arguments[5];
    if (typeof arguments[6] == "number") this.DelayTime = arguments[6];
    if (typeof arguments[7] == "number") this.WaitTime = arguments[7];
    if (typeof arguments[8] == "number") this.ScrollStep = arguments[8]
    this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
    this.ID.noWrap = true;
    this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
    if (arguments.length >= 7) this.Start();
}


Marquee.prototype.Start = function() {
    if (this.ID == -1) return;
    if (this.WaitTime < 800) this.WaitTime = 800;
    if (this.Timer < 20) this.Timer = 20;
    if (this.Width == 0) this.Width = parseInt(this.ID.style.width);
    if (this.Height == 0) this.Height = parseInt(this.ID.style.height);
    if (typeof this.Direction == "string") this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
    this.HalfWidth = Math.round(this.Width / 2);
    this.BakStep = this.Step;
    this.ID.style.width = this.Width;
    this.ID.style.height = this.Height;
    if (typeof this.ScrollStep != "number") this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
    var msobj = this;
    var timer = this.Timer;
    var delaytime = this.DelayTime;
    var waittime = this.WaitTime;
    msobj.StartID = function() { msobj.Scroll() }
    msobj.Continue = function() {
        if (msobj.MouseOver == 1) {
            setTimeout(msobj.Continue, delaytime);
        }
        else {
            clearInterval(msobj.TimerID);
            msobj.CTL = msobj.Stop = 0;
            msobj.TimerID = setInterval(msobj.StartID, timer);
        }
    }

    msobj.Pause = function() {
        msobj.Stop = 1;
        clearInterval(msobj.TimerID);
        setTimeout(msobj.Continue, delaytime);
    }

    msobj.Begin = function() {
        msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth : msobj.ID.scrollHeight;
        if ((msobj.Direction <= 1 && msobj.ClientScroll < msobj.Height) || (msobj.Direction > 1 && msobj.ClientScroll < msobj.Width)) return;
        msobj.ID.innerHTML += msobj.ID.innerHTML;
        msobj.TimerID = setInterval(msobj.StartID, timer);
        if (msobj.ScrollStep < 0) return;
        msobj.ID.onmousemove = function(event) {
            if (msobj.ScrollStep == 0 && msobj.Direction > 1) {
                var event = event || window.event;
                if (window.event) {
                    if (msobj.IsNotOpera) {
                        msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;
                    }
                    else {
                        msobj.ScrollStep = null;
                        return;
                    }
                }
                else {
                    msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;
                }
                msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
                msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
                msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep * 2) / msobj.HalfWidth);
            }
        }
        msobj.ID.onmouseover = function() {
            if (msobj.ScrollStep == 0) return;
            msobj.MouseOver = 1;
            clearInterval(msobj.TimerID);
        }
        msobj.ID.onmouseout = function() {
            if (msobj.ScrollStep == 0) {
                if (msobj.Step == 0) msobj.Step = 1;
                return;
            }
            msobj.MouseOver = 0;
            if (msobj.Stop == 0) {
                clearInterval(msobj.TimerID);
                msobj.TimerID = setInterval(msobj.StartID, timer);
            }
        }
    }
    setTimeout(msobj.Begin, waittime);
}

Marquee.prototype.Scroll = function() {
    switch (this.Direction) {
        case 0:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.DelayTime > 0) {
                this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
                this.Pause();
                return;
            }
            else {
                if (this.ID.scrollTop >= this.ClientScroll) {
                    this.ID.scrollTop -= this.ClientScroll;
                }
                this.ID.scrollTop += this.Step;
            }
            break;

        case 1:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.DelayTime > 0) {
                this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
                this.Pause();
                return;
            }
            else {
                if (this.ID.scrollTop <= 0) {
                    this.ID.scrollTop += this.ClientScroll;
                }
                this.ID.scrollTop -= this.Step;
            }
            break;

        case 2:

            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.DelayTime > 0) {
                this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
                this.Pause();
                return;
            }
            else {
                if (this.ID.scrollLeft >= this.ClientScroll) {
                    this.ID.scrollLeft -= this.ClientScroll;
                }
                this.ID.scrollLeft += this.Step;
            }
            break;

        case 3:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.DelayTime > 0) {
                this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
                this.Pause();
                return;
            }
            else {
                if (this.ID.scrollLeft <= 0) {
                    this.ID.scrollLeft += this.ClientScroll;
                }
                this.ID.scrollLeft -= this.Step;
            }
            break;
    }
}

function ResumeError() {
    return true;
}
window.onerror = ResumeError;

//元素名称：m_n; tab_m_n
//count:交换的个数
function showtab(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("td_" + m + "_" + i).className = "sybox31on";
            getObject("tab_" + m + "_" + i).className = "show";
        }
        else {
            getObject("td_" + m + "_" + i).className = "";
            getObject("tab_" + m + "_" + i).className = "hidden";
        }
    }
}
function showtab2(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("td2_" + m + "_" + i).className = "syxyboxon";
            getObject("tab2_" + m + "_" + i).className = "show";
        }
        else {
            getObject("td2_" + m + "_" + i).className = "syxyboxoff";
            getObject("tab2_" + m + "_" + i).className = "hidden";
        }
    }
}
function sshowtab(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("tdd_" + m + "_" + i).className = "sybox31on";
            getObject("tabb_" + m + "_" + i).className = "show";
        }
        else {
            getObject("tdd_" + m + "_" + i).className = "";
            getObject("tabb_" + m + "_" + i).className = "hidden";
        }
    }
}
function showtabdq(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("tddq1_" + m + "_" + i).className = "dqbox2on";
            getObject("tabdq1_" + m + "_" + i).className = "show";
        }
        else {
            getObject("tddq1_" + m + "_" + i).className = "";
            getObject("tabdq1_" + m + "_" + i).className = "hidden";
        }
    }
}
function showtabdq2(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("tddq_" + m + "_" + i).className = "dqleftqyon";
            getObject("tabdq_" + m + "_" + i).className = "show";
        }
        else {
            getObject("tddq_" + m + "_" + i).className = "";
            getObject("tabdq_" + m + "_" + i).className = "hidden";
        }
    }
}
function showtabdq3(m, n, count, id) {
    for (var i = 0; i <= count; i++) {
        if (i == n) {
            getObject("td" + id + "_" + m + "_" + i).className = "dqleftqyon";
            getObject("tab" + id + "_" + m + "_" + i).className = "show";
        }
        else {
            getObject("td" + id + "_" + m + "_" + i).className = "";
            getObject("tab" + id + "_" + m + "_" + i).className = "hidden";
        }
    }
}
function getObject(objectId) {
    if (document.getElementById && document.getElementById(objectId)) {
        // W3C DOM
        return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
        // MSIE 4 DOM
        return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
        // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    } else {
        return false;
    }
}

function show1tab2(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("td2_" + m + "_" + i).className = "showrelateon";
            getObject("tab2_" + m + "_" + i).className = "show";
        }
        else {
            getObject("td2_" + m + "_" + i).className = "";
            getObject("tab2_" + m + "_" + i).className = "hidden";
        }
    }
}
function show1tab3(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            getObject("td3_" + m + "_" + i).className = "showbox2on";
            getObject("tab3_" + m + "_" + i).className = "show";
        }
        else {
            getObject("td3_" + m + "_" + i).className = "";
            getObject("tab3_" + m + "_" + i).className = "hidden";
        }
    }
}

function switchSearchType(keyType) {
    $("#searchType").val(keyType);
}

function checkIsMy(check) {
    if (check)
        $("#isMy").val("1");
    else
        $("#isMy").val("0");
}


function ShowHidSearch() {
    var IsShow = document.getElementById("searchShow").value;
    if (IsShow == "1") {
        document.getElementById('moretj').className = 'jobsc2'
        document.getElementById('spshow').innerHTML = '<img src=images2011/job_32.jpg vspace=7 align=absmiddle> 隐藏更多搜索条件'
    }
    else {
        document.getElementById('moretj').className = 'hidden'
        document.getElementById('spshow').innerHTML = '<img src=images2011/job_32b.jpg vspace=7 align=absmiddle> 显示更多搜索条件'
    }
}

function SetIsShow() {
    var IsShow = document.getElementById("searchShow").value;
    if (IsShow == "1") {
        $("#searchShow").val("0");
    }
    else {
        $("#searchShow").val("1");
    }
}

function RefreshWholeMessage1() {
    var url = "http://my.bjx.com.cn/ReadApplicationJson.aspx?from=dqjob&callback=?";
    $.getJSON(url, function(data) {
        $("#otherSeeJob").html(data.message);
        setTimeout('RefreshWholeMessage1();', 10000);
    });
}

function PersonLogin() {
    var logStr = "";
    var LoginMember = $.cookie("HR.LoginMember");
    if (LoginMember == null || LoginMember == "") {
        logStr += "<ul><form name='loginform' method='post' action='http://www.dqjob.com.cn/login.aspx' onsubmit=\"if (loginform.username1.value=='请输入用户名')return false; if (!loginform.username1.value || !loginform.password.value) return false;loginform.username.value=escape(loginform.username1.value);return true;\">";
        logStr += "<input type='text' class=\"sylogsr\" value=\"用户名\" onfocus=\"if(this.value=='用户名')this.value=''\"  name='username1' id='username1' /><input type='hidden' name='username'/>";
        logStr += "<input type='password' class=\"sylogpass\" name='password' id='password' />";
        logStr += "<div class=\"clear\"></div>";
        logStr += "<input type=\"submit\" value=\"&nbsp;&nbsp;\" align=\"absmiddle\" class=\"sylogdl\" />";
        logStr += "<a href=\"http://www.dqjob.com.cn/my/BackPassword.aspx\" target=\"_blank\" class=\"fl\">忘记密码</a>";
        logStr += "<div class=\"clear\"></div>"
        logStr += "<a href=\"http://www.dqjob.com.cn/register.aspx\" class=\"syreg\"></a>";
        logStr += "</form></ul>";
    } else {
        var CookieArr = LoginMember.split("&");
        var LogId = CookieArr[1].split("=")[1];
        LogId = DecodeURI(LogId);
        if (LogId.indexOf("%") >= 0) LogId = DecodeURI(LogId);

        logStr += "<div class=\"grloginon\">";
        logStr += LogId + "<br />";
        logStr += "<div class='clear'></div>";
        logStr += "您好，好工作源于认真选择和不懈追求，每天申请20个以上的职位，才能获得足够的面试机会。<br />";
        logStr += "<a target='_blank' class='bluea' href='http://www.dqjob.com.cn/my/index.aspx'>[进入管理]</a> <br/><a target='_blank' class='bluea' href='http://www.dqjob.com.cn/my/ModifyPWD.aspx'>[修改密码]</a> <a class='bluea' href='http://www.dqjob.com.cn/loginout.aspx?backurl=" + location.href + "'>[退出]</a>";
        logStr += "</div>";
    }
    document.write(logStr);
}

var EncodeURI = function(unzipStr, isCusEncode) {
    if (isCusEncode) {
        var zipArray = new Array();
        var zipstr = "";
        var lens = new Array();
        for (var i = 0; i < unzipStr.length; i++) {
            var ac = unzipStr.charCodeAt(i);
            zipstr += ac;
            lens = lens.concat(ac.toString().length);
        }
        zipArray = zipArray.concat(zipstr);
        zipArray = zipArray.concat(lens.join("O"));
        return zipArray.join("N");
    } else {
        //return encodeURI(unzipStr);
        var zipstr = "";
        var strSpecial = "!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
        var tt = "";

        for (var i = 0; i < unzipStr.length; i++) {
            var chr = unzipStr.charAt(i);
            var c = StringToAscii(chr);
            tt += chr + ":" + c + "n";
            if (parseInt("0x" + c) > 0x7f) {
                zipstr += encodeURI(unzipStr.substr(i, 1));
            } else {
                if (chr == " ")
                    zipstr += "+";
                else if (strSpecial.indexOf(chr) != -1)
                    zipstr += "%" + c.toString(16);
                else
                    zipstr += chr;
            }
        }
        return zipstr;
    }
}

var DecodeURI = function(zipStr, isCusEncode) {
    if (isCusEncode) {
        var zipArray = zipStr.split("N");
        var zipSrcStr = zipArray[0];
        var zipLens;
        if (zipArray[1]) {
            zipLens = zipArray[1].split("O");
        } else {
            zipLens.length = 0;
        }

        var uzipStr = "";

        for (var j = 0; j < zipLens.length; j++) {
            var charLen = parseInt(zipLens[j]);
            uzipStr += String.fromCharCode(zipSrcStr.substr(0, charLen));
            zipSrcStr = zipSrcStr.slice(charLen, zipSrcStr.length);
        }
        return uzipStr;
    } else {
        //return decodeURI(zipStr);
        var uzipStr = "";

        for (var i = 0; i < zipStr.length; i++) {
            var chr = zipStr.charAt(i);
            if (chr == "+") {
                uzipStr += " ";
            } else if (chr == "%") {
                var asc = zipStr.substring(i + 1, i + 3);
                if (parseInt("0x" + asc) > 0x7f) {
                    uzipStr += decodeURI("%" + asc.toString() + zipStr.substring(i + 3, i + 9).toString()); ;
                    i += 8;
                } else {
                    uzipStr += AsciiToString(parseInt("0x" + asc));
                    i += 2;
                }
            } else {
                uzipStr += chr;
            }
        }
        return uzipStr;
    }
}

var StringToAscii = function(str) {
    return str.charCodeAt(0).toString(16);
}

var AsciiToString = function(asccode) {
    return String.fromCharCode(asccode);
}

function Select(obj, v) {
    var p = obj.parentNode.getElementsByTagName("p");
    for (var i = 0; i < p.length; i++) {
        if (i < 3) {
            p[i].className = "s_b";
        }
    }
    obj.className = "s_a";
    document.getElementById("keytype").value = v;
}

function OpenWindow() {
    var url = "http://www.dqjob.com.cn/SearchResult.aspx";
    var keywordtype = document.getElementById("keytype").value;
    var keyword = document.getElementById("tbKey").value;

    url += "?searchType=" + keywordtype + "&keyWord=" + escape(keyword);

    window.open(url, "_blank");
}

function OpenWindowNews() {
    var select = document.getElementById("selectSc").value;
    var keyword = document.getElementById("tbKeyNews").value;
    if (keyword == "请输入关键词") {
        keyword = "";
    }
    if (select == "2") {
        window.open("http://www.dqjob.com.cn/SearchResult.aspx?searchType=1&keyWord=" + escape(keyword), "_blank");
    }
    else {
        window.open("http://www.dqjob.com.cn/NewsResult.aspx?keyWord=" + escape(keyword), "_blank");
    }
}
function OpenWindowNewsType() {
    var select = document.getElementById("searchNewsType").value;
    var keyword = document.getElementById("searchNews").value;
    if (keyword == "请输入关键词") {
        keyword = "";
    }
    window.open("http://www.dqjob.com.cn/NewsResult.aspx?keyWord=" + escape(keyword)+"&NewsType="+select, "_blank");
}
function ClearTips() {
    if (document.getElementById("tbKey").value == "请输入搜索条件 如：电气工程师") {
        obj.value = "";
    }
}

function SetTips() {
    if (document.getElementById("tbKey").value == "") {
        obj.value = "请输入搜索条件 如：电气工程师";
    }
}

$(document).ready(function() {
    $("#mysee").hover(function() { $("#other").addClass('navothertop'); $("#othersite").removeClass('hidden') },
						function() { $("#other").removeClass('navothertop'); $("#othersite").addClass('hidden') });
    $("#mysee2").hover(function() { $("#other2").addClass('navothertop'); $("#othersite2").removeClass('hidden') },
						function() { $("#other2").removeClass('navothertop'); $("#othersite2").addClass('hidden') });
    $("#mysee3").hover(function() { $("#other3").addClass('navothertop'); $("#othersite3").removeClass('hidden') },
						function() { $("#other3").removeClass('navothertop'); $("#othersite3").addClass('hidden') });
    $("#othersite2").css({ "left": "-103px" }, { "_left": "-113px" });
    $("#othersite3").css("left", "-181px");
    $(".sylogdl").hover(function() { $(".sylogdl").css("backgroundImage", "url(images2011/sydlon.gif)") },
						function() { $(".sylogdl").css("backgroundImage", "url(images2011/sydl.gif)") })
})

function toClipBoard() {
    var clipBoardContent = "";
    clipBoardContent += document.title;     //获取页面标题
    clipBoardContent += "\n";
    clipBoardContent += this.location.href; //获取页面地址 
    //将拷贝内容存放到剪贴板中
    window.clipboardData.setData("Text", clipBoardContent);
    alert("复制成功，可以粘贴到你的QQ/MSN上，推荐给你的好友！");
}

function getNewsOnclick(newsID) {
    $.ajax({
        url: "/NewsOther.aspx?type=onclick&id=" + newsID,
        type: "get",
        cache: false,
        dataType: "html",
        success: function(message) {
            if (message != "") $("#hits").html(message);
        }
    });
}

function getNewsDCount(newsID) {
    $.ajax({
        url: "/NewsOther.aspx?type=countd&id=" + newsID,
        type: "get",
        cache: false,
        dataType: "html",
        success: function(message) {
            if (message != "") $("#d").html(message);
        }
    });
}

function getNewsCCount(newsID) {
    $.ajax({
        url: "/NewsOther.aspx?type=countc&id=" + newsID,
        type: "get",
        cache: false,
        dataType: "html",
        success: function(message) {
            if (message != "") $("#c").html(message);
        }
    });
}

function dcclick(obj, type, id) {
    if ($("#hidSend").val() == "0") {
        $("#hidSend").val("1");
        $.ajax({
            url: "/NewsOther.aspx?type=" + type + "&id=" + id,
            type: "get",
            cache: false,
            dataType: "html",
            success: function(message) {
                if (message != "") {
                    if (type == "dcount") {
                        $("#d").html(message);
                    }
                    else {
                        $("#c").html(message);
                    }
                }
            }
        });
    }
}



function ClickType()
{
    var ddl = document.getElementById("droplist");
    var index = ddl.selectedIndex;
    var value = ddl.options[index].value;
    var typevalues = document.getElementById("txttype").value;
    var url="http://www.dqjob.com.cn/list.aspx?title="+typevalues+"&id="+value+"&submit.x=1&submit.y=2";
    window.open(url);
}

function GetRequest() {
   var url = location.search; //获取url中"?"符后的字串
   var theRequest = new Object();
 
   if (url.indexOf("?") != -1) {
 
      var str = url.substr(1);
 
      strs = str.split("&");
 
      for(var i = 0; i < strs.length; i ++) {
 
         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
  		}
   }
   return theRequest;
}
	 
function SetValue()
{
	var Request = new Object(); 
	Request = GetRequest();
	document.getElementById("id").value = Request['id'];
}


//头部北极星电力网
function staion()
{
document.getElementById("a").innerHTML="  <a href='http://hr.bjx.com.cn/' title='北极星电力招聘网' target='_blank'>北极星电力招聘网</a><a href='http://hdjob.bjx.com.cn/' title='北极星火电招聘网' target='_blank'>北极星火电招聘网</a><a href='http://fdjob.bjx.com.cn/' title='北极星风电招聘网' target='_blank'>北极星风电招聘网</a><a href='http://gfjob.bjx.com.cn/' title='北极星光伏招聘网' target='_blank'>北极星光伏招聘网</a><a href='http://www.dqjob.com.cn/' title='北极星电气招聘网' target='_blank'>北极星电气招聘网</a><a href='http://gcjob.bjx.com.cn/' title='北极星工程招聘网' target='_blank'>北极星工程招聘网</a><a href='http://hbjob.bjx.com.cn/' title='北极星环保招聘网' target='_blank'>北极星环保招聘网</a><a href='http://sdjob.bjx.com.cn/' title='北极星水电招聘网' target='_blank'>北极星水电招聘网</a><a href='http://mtjob.bjx.com.cn/' title='北极星煤炭招聘网' target='_blank'>北极星煤炭招聘网</a><a href='http://xy.bjx.com.cn/' title='北极星校园招聘网' target='_blank'>北极星校园招聘网</a>";
}

