function changeText(num)
{
  var obj = document.getElementsByName("key")[0];
  if(num == 0)
  {
    if(obj.value == '请输入：财务总监 或 销售总监 或 总经理  等')
    {
      obj.value = '';
    }
   }
   if(num == 1)
   {
   if(obj.value == '')
     {
       obj.value = '请输入：财务总监 或 销售总监 或 总经理  等';
     }
   }
}

function doSearch(){
  var strkey = document.getElementsByName('key')[0].value;
  if(strkey == "请输入：财务总监 或 销售总监 或 总经理  等"){
    document.getElementsByName('key')[0].value = "";
    strkey = "";
  }
  var strdq = "";
  if(document.getElementsByName('dq').length > 0){
    strdq = document.getElementsByName('dq')[0].value;
  }
  var ocxsalary = document.getElementsByName('salary')[0];
  var strsalary = "";
  if(ocxsalary != null){
    for(var i = 0; i < ocxsalary.options.length; i++){
      if(ocxsalary.options[i].selected == true){
        strsalary = ocxsalary.options[i].value;
        break;
      }
    }
  }
  if(strkey == "" && strdq == "" && strsalary == ""){
    alert("您至少要选择一个搜索条件");
    return;
  }
  document.forms["frmSearch"].submit();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeDiv(index)
{
  for (var i=1;i<=2 ;i++)
  {
    var descDiv = "descDiv_" + i;
    var descList = "descList_" + i;
    
    if(document.getElementById(descDiv) == null) continue;
    if (i == index)
    {
      document.getElementById(descDiv).className = "postbj";
      document.getElementById(descList).style.display = "block";
    }
    else
    {
      document.getElementById(descDiv).className = "conbj";
      document.getElementById(descList).style.display = "none";
    }
  }
}

function leaveMsg(toUserId){
    var userLogin = GetCK('user_login');
    if(userLogin == null || userLogin == "")
    {
        if (!parent.document.getElementById("frmMsgSignUp").src) {
            parent.document.getElementById("frmMsgSignUp").src = "/user/regc/showbox/";
        }
        showMsgBox('frmMsgSignUp', '', 'window.parent.leaveMsg(' + toUserId + ')');
        return;
    }else{
//        window.location.href = "http://www.lietou.com/message/sendmsg.do?user_toid=" + toUserId + "&message_kind=0";
//        $.ajax({ 
//        type:'get',
//        cache:false,
//        url:'/message/msgflag.do',
//        dataType:'json',
//        success:function(data){
//            if(typeof(data.msg) != 'undefined' && data.msg != ''){
//            alert(data.err);
//          }else{
//            if(data.flag == "0" || data.flag == "2")
//            {
//              //window.location.href = "http://www.lietou.com/message/sendmsg.do?user_toid=" + toUserId + "&message_kind=0";
//          //var str_url = "http://www.lietou.com/message/sendmsg.do?user_toid=" + toUserId + "&message_kind=0";
//          //document.getElementById("leaveMsgForm").action = str_url;
//          //document.getElementById("leaveMsgForm").submit();
//                    window.location.href = "http://www.lietou.com/message/sendmsg.do?user_toid=" + toUserId + "&message_kind=0";
//            }
//            else if(data.flag == "1")
//            {
//              if(confirm("普通会员只有3次留言机会，您目前已经留言了3次，马上升级为金卡会员，给更多猎头留言？"))
//              {
//                window.location.href = "http://www.lietou.com/goldcard/";
//              }
//            }
//            else if(data.flag == "3")
//            {
//              if(confirm("您的金卡会员已到期，需要续费后才能给更多猎头留言，了解更多详情？"))
//              {
//                window.location.href = "http://c.lietou.com/goldcard/refee.jsp";
//              }
//            }
//          }
//        },
//        error:function(){
//          alert("系统错误请稍候再试！");
//        }
//    }); 
        parent.document.getElementById("leaveMessage").src = "/message/leavemessage/?user_toid=" + toUserId + "&message_kind=0";
        showMsgBox('leaveMessage', '', '');
        parent.document.getElementById("leaveMessage").style.height = "450px";
        parent.document.getElementById("leaveMessage").style.height = "450";
    }
}

function appEJobMsg(toEJobId){
    var userLogin = GetCK('user_login');
    var nextUrl = "/apply/appejob/?job_id=" + toEJobId;
    if(userLogin == null || userLogin == "")
    {
        if (!parent.document.getElementById("frmMsgSignUp").src) {
            parent.document.getElementById("frmMsgSignUp").src = "/user/regc/showbox/";
        }
        showMsgBox('frmMsgSignUp', nextUrl, '');
        return;
    }else{
        window.location.href = nextUrl;
    }
}

function emailFriendMsg(eJobId, eCompName, eJobDq, eJobTitle, eJobSalary){
    var userLogin = GetCK('user_login');
    var nextUrl = "/job/emailfriend/?job_kind=2&job_id=" + eJobId + "&comp_name=" + eCompName + "&job_dq_name=" + eJobDq + "&job_title=" + eJobTitle + "&job_salary=" + eJobSalary;
    if(userLogin == null || userLogin == "")
    {
        if (!parent.document.getElementById("frmMsgSignUp").src) {
            parent.document.getElementById("frmMsgSignUp").src = "/user/regc/showbox/";
        }
        showMsgBox('frmMsgSignUp', nextUrl, '');
        return;
    }else{
        window.location.href = nextUrl;
    }
}
/****lxk,add,新老www兼容******/
function emailToFriendMsg(eJobId, eCompName, eJobDq, eJobTitle, eJobSalary){
    var userLogin = GetCK('user_login');
    var nextUrl = "/job/emailfriend/?job_kind=2&job_id=" + eJobId + "&comp_name=" + eCompName + "&job_dq_name=" + eJobDq + "&job_title=" + eJobTitle + "&job_salary=" + eJobSalary;
    if(userLogin == null || userLogin == "")
    {
        if (!parent.document.getElementById("frmMsgSignUp").src) {
            parent.document.getElementById("frmMsgSignUp").src = "/user/regc/showbox/";
        }
        showMsgBox('frmMsgSignUp', nextUrl, '');
        return;
    }else{
        window.location.href = nextUrl;
    }
}
function jobFavorites(job_createuser, job_id, job_kind, comp_industry_code, job_dq_code, job_title, comp_name)
{
  var userLogin = GetCK('user_login');
  var userkind = GetCK('user_kind');
  if(userLogin == null || userLogin == "")
  {
    //alert('请登录后收藏该职位！');
		if (!parent.document.getElementById("frmMsgSignUp").src) {
        parent.document.getElementById("frmMsgSignUp").src = "/user/regc/showbox/";
    }
		showMsgBox('frmMsgSignUp', '', 'window.parent.jobFavorites('+job_createuser+', '+job_id+', '+ job_kind+', '+comp_industry_code+', '+job_dq_code+', '+job_title+', '+comp_name+')');
    return;
  }
  else
  {
    if(userkind != '0')
    {
      alert("抱歉，只有经理人才能收藏该职位！");
      return;
    }
    $.ajax({ 
          type:'get',
          cache:false,
          url:'http://www.lietou.com/job/savejobjavorites/?job_createuser='+job_createuser+'&job_id=' + job_id +"&job_kind=" + job_kind + "&comp_industry_code=" + comp_industry_code + "&job_dq_code=" + job_dq_code + "&job_title=" + job_title + "&comp_name=" + comp_name,
          dataType:'json',
          success:function(data){
              if(typeof(data.err) != 'undefined' && data.err != ''){
              alert(data.err);
            }else{
              if(data.flag == "0")
              {
                alert("该职位已成功收藏到您的“职位收藏夹”中！");
                window.location.reload();
              }
              else if(data.flag == "1")
              {
                alert("您已收藏过该职位!");
                return;
              }
                
            }
          },
          error:function(){
            alert("系统错误请稍候再试！");
      return;
          }
      });     
  }
  closeMsgBox('frmMsgSignUp');  
}
