﻿var hy = "01,IT业(计算机软硬件/通讯);02,电子技术;03,金融(银行/风险基金);04,贸易;05,食品/饮料/化妆品;06,服装/纺织;07,咨询业;08,生物/制药/保健/医药;09,建筑/设计/装潢;10,旅游业;11,酒店/餐饮;12,广告业;13,媒体/出版;14,加工/制造;15,印刷/包装;16,采掘业/冶炼;17,娱乐/体育;18,法律;19,化工/能源;20,环保;21,交通/运输/物流;22,批发和零售;23,教育/培训;24,学术/科研/艺术;25,保险业;26,房地产及中介;27,服务业;28,非盈利机构/政府;29,农业/渔业/林业;30,其他行业;31,家具/家电/工艺品;";
var zw = "01,IT/通讯;02,销售;03,市场/广告类;04,财务/金融类;05,生产/工程类;06,行政/后勤类;07,高级管理类;08,物流/贸易类;09,文字/设计类;10,科研人员类;11,律师/法务类;12,教师类;13,医疗/护理类;14,咨询/顾问类;15,公务员类;16,在校学生类;17,培训生类;18,服务类;19,其他类;20,翻译类;21,建筑/房产类;22,纺织/服装类;23,客户服务;";
var rq = "1,一天;2,两天;3,三天;7,一周;14,两周;30,一个月;60,两个月;90,三个月;";
var zwdata ={arr:""+zw+"",val:"",txt:"",chk:"",chkNo:"0"};
var hydata ={arr:""+hy+"",val:"",txt:"",chk:""};
var rqdata ={arr:""+rq+"",val:"",txt:"",chk:""};

var isCompany = false;
var thisPage=1;
var StationID="";//新加的，解决登陆后没有职位ID丢失
var thisKeyWordsIndex = 0;
var KeywordsCount =0;
var thisa;
var LashResearchText0="";
var LashResearchValue0="";
var LeftResearchText0="";
var LeftResearchValue0="";
var new_p_data="";
var orderStr ="";


$(document).ready(function(){
        size = 4 ;
        setSelectBoxT( $("#zw"),"请选择职位",zwdata,6,80,3,180,stationSub,3,3);
        setSelectBoxO($("#hy"),"请选择行业",hydata,3,140,true);//请选择行业
        setSelectBoxO($("#rq"),"请选择企业类型",rqdata,4,80,false);//请选择企业类型
        
    myFocus("keyWord","请输入关键字");
    SetKeyWordsResultPosition();
    GetKeyWords();
    InitSetValue();
   $("#myclose").click(function(){
        $("#myselect").hide();
        $("#subMyselect").hide();
        return false;
   });
   $("#kxBody").click(function(){
        $("#myselect").hide();
        $("#subMyselect").hide();
        $("#keyWordsResult").hide();
        //alert( $("#childOrderSelector")[0].style.display);
        //$("#childOrderSelector").hide();
        thisKeyWordsIndex = -1;
   });
   
   $("#kxSelect").click(function(){
        SelectAll("kxSelect");
    });
   $("#kxSelect1").click(function(){
        SelectAll("kxSelect1");
    });
    
      $("#keyWord").keyup(function(){
        var kxKeyWord=event.keyCode;
        if(kxKeyWord == 38){
          thisKeyWordsIndex --;
          thisKeyWordsIndex = (thisKeyWordsIndex< 1)?0:thisKeyWordsIndex;
          
          thisa = $("#kxLi"+thisKeyWordsIndex+"")
          if(thisa != null){
              var previouslyaIndex = thisKeyWordsIndex + 1 ;
              var previouslya = $("#kxLi"+previouslyaIndex+"") 
              if(previouslya != null)
              {
                  previouslya.removeClass("keyWordsResulthover");
                  
              }
              thisa.addClass("keyWordsResulthover");
              $("#keyWord")[0].value = thisa.text();

          }
        }
        else if( kxKeyWord == 40){
          thisKeyWordsIndex ++;
          thisKeyWordsIndex = (thisKeyWordsIndex< 1)?0:thisKeyWordsIndex;
          thisKeyWordsIndex = (thisKeyWordsIndex>KeywordsCount-1)?KeywordsCount-1:thisKeyWordsIndex;
          thisa = $("#kxLi"+thisKeyWordsIndex+"")
          if(thisa != null){
              var previouslyaIndex = thisKeyWordsIndex -1 ;
              var previouslya = $("#kxLi"+previouslyaIndex+"") 
              if(previouslya != null)
              {
                  previouslya.removeClass("keyWordsResulthover");
                  
              }
              thisa.addClass("keyWordsResulthover");
              $("#keyWord")[0].value = thisa.text();
           }
        }
        else if( kxKeyWord == 13)
        {
            KxSearch();
            return false;
            
        }else{
            thisKeyWordsIndex=0;
            KeywordsCount =0;
            ShowKeyWordsResult();
        }
         //$("#tempCount").html(thisKeyWordsIndex);
        //$("#ss").focus();
        return false;
   });
   $("#keyWord").click(function(){
        if($("#keyWord").val() !=""){
            ShowKeyWordsResult();
        }
        return false;
   });
   $("#myselect").click(function(){
       setLod("kxList",10);
       if(!isSelect){
        $("#subMyselect").hide();
       }
       isSelect = !isSelect;
   });
   $("#ss").click(function(){
        KxSearch();
        return false;
   });
    //加载职位
    $("#mlod").html("正在加载职位列表...");
    setLod("kxList",10);
    if(rcount >1){
        getList(strWhere,1);
        if(rcount > 15){
           pageFoot(strWhere);
        }
    }
    else{
        document.getElementById("kxList").innerHTML="<div class='war' style='width:776px;'><img src='/_Images/waring.gif' /> 对不起， 没有找到符合条件的职位！</div>";
    }
    
    
   $("#zwsq").click(function(){
        StationID = GetData().replace("idList=","");
        CheckSession();
   });
   $("#bt_login").click(function(){
        CheckYhmAndMm();
        if(CheckYhmAndMm()){
             CheckLogin();
        }

   });
   
    $("#gjz_zw").click(function(){
        gjz_zwClick();
        return false;
   });
   
   $("#gjz_qy").click(function(){
        gjz_qyClick();
        return false;
   });
   getList(strWhere,1);
   
   SearchDisplay('ss-jy');
   SearchDisplay('ss-xl');
   SearchDisplay('ss-gz');
   SearchDisplay('ss-lx');
   SearchDisplay('ss-dd');
   SearchDisplay('ss-zj');
});

function LinkSearch(keyWords){
    setLod("kxList",10);
    p_data = "zw="+keyWords+"";
    GetListCount(p_data);
}
function NewKxSearch(kxStr,kxText)
{
    LeftResearchText0 = kxText
    LeftResearchValue0 = "&"+kxStr;
        
    setLod("kxList",10);
    leftStr = getWhere();
    if(leftStr !="")
    {
        p_data = leftStr +"&"+kxStr;
    }
    else
    {
        p_data = kxStr
    }
    returnPage("#List");
    //alert(p_data);
    GetListCount(p_data);

    
}
//正在加载
function getList(strWhere,pageIndex){
      $("#kxSelect")[0].checked=false;
      $("#kxSelect1")[0].checked=false;
  $.ajax({
        type: "post",
        url: "Ashx/StationList.ashx",
        data:"StrWhere="+strWhere+orderStr+"&PageIndex="+pageIndex+"",
        beforeSend: function(XMLHttpRequest){
            $("#lod").show();
        },
        success: function(data){
            if(data !=""){
                document.getElementById("kxList").innerHTML=data;
            }
            if(pageIndex != 1){  
                returnPage('#List');
            }
        },
        complete: function(XMLHttpRequest, textStatus){
            $("#lod").hide();
        },
        error: function(){
            //returnPage("../default.aspx");
              //document.getElementById("kxList").innerHTML=strWhere+orderStr;
        }
     });
}
function getWhere(){
    var p_dataText="";
    var p_data="";
    var keyWord = $.trim($("#keyWord")[0].value);
    keyWord = keyWord.replace("请输入关键字","");
    if(keyWord !=""){
        if(isCompany){
            p_data +="&mc="+keyWord+"";
            p_dataText +=keyWord+"＋";
        }
        else{
            p_data +="&zw="+keyWord+"";
            p_dataText +=keyWord+"＋";
        }
    }
    else
    {
        p_dataText = (zwdata.val !="")?$("#zw").val()+"＋":"";
    }
    p_dataText += (hydata.val !="")?$("#hy").val()+"＋":"";
    
    
    p_data = "zw2="+zwdata.val+"&hy="+hydata.val+p_data+"&rq="+rqdata.val+"";
    // alert(keyWord);
    for(i=0;i<15;i++){
        p_data = p_data.replace("=","^");
    }
    //p_dataText ="<a href=javascript:GetListCount('"+p_data+"');>"+p_dataText+"</a>";
    
    LashResearchText0 = p_dataText+LeftResearchText0;
    LashResearchValue0="<a title='"+LashResearchText0+"' href=javascript:GetListCount('"+p_data+LeftResearchValue0+"');><font color='#0179e7'>";

    if(LashResearchText0 !="")
    {
        $("#LashResearch").html(LashResearchValue0+LashResearchText0+"</font></a>");
        $("#ss-zj").show();
        $("#ss-zj-s").show();
    }
    $.cookie("LashResearchValue0", ""+LashResearchValue0+"",{expires: 365, path: '/', secure: false }); 
    $.cookie("LashResearchText0", ""+LashResearchText0+"",{expires: 365, path: '/', secure: false }); 
    return(p_data)
     
}

function GetListCount(p_data){
        
        for(i=0;i<15;i++){
            p_data = p_data.replace("^","=");
        }
        $.ajax({
        type: "post",
        url: "Ashx/GetListCount.ashx",
        data:""+p_data+"",
        dataType: "json",
        success: function(data){
            rcount = data.count;
            strWhere = data.strWhere;
            pageFoot(data.strWhere,data.count)
            if(data.count == 0){
               document.getElementById("kxList").innerHTML="<div class='war' style='width:776px;'><img src='/_Images/waring.gif' />  对不起，没有查询到相关职位！</div>";
               $("#page").hide();
            }
            else if(data.count <= 15)
            {
               $("#page").hide();
               getList(data.strWhere,1);
            }else{
               $("#page").show();
               getList(data.strWhere,1);
            }
                           
        },
        error: function(){
           //returnPage("../Index.aspx");
           alert("错误");
        }
     });
}

function CheckSession()
{
      $.ajax({
        type: "post",
        url: "../p/ashx/CheckSession.ashx",
        async: false,
        success: function(data){
           if(data == "1")
           {
              appStation();  
                
           }
           else if(data == "0")
           {
              returnPage("#login");
              $("#login").show();
              $("#zwsq").hide();
           }
           else
           {
              alert("非法操作！");
           } 
        },
        error: function(){
            returnPage("../p/login.aspx");
        }
     });
}
function CheckLogin()
{
   if(CheckYhmAndMm())
   {
        var check;
        $.ajax({
               type: "post",
               url: "../P/Ashx/CheckLogin.ashx",
               async: false,
               data:"userName="+$.trim($("#yhm").val())+"&passWord="+$.trim($("#mm").val())+"",
               beforeSend: function(XMLHttpRequest){
		            $("#Warning").html("正在检测用户名和密码...");
		            check = false;
               },
               success: function(data, textStatus){
                  if(data =="0"){
                     $("#Warning").html("用户名或者密码错误！");
                     check = false;
                  }
                  else if(data =="1"){
                     $("#Warning").html("");
                     check = true;
                     $("#login").hide();
                     $("#zwsq").show();
                     CheckSession();
                  }else{
                     $("#Warning").html(data);
                     check = false;
                  }
               },
               error: function(){
                    $("#Warning").html(" 验证失败！");
		            check = false;
               }
        });
    }
}
function CheckYhmAndMm()
{
    if($.trim($("#mm").val()) =="" || $.trim($("#yhm").val()) =="")
    {
        $("#Warning").html("  用户名和密码不能为空！");
        return false;
    }
    else
    {
        return true;
    }
}
//申请职位
function appStation(){
    
    if(StationID == ""){
        alert("请您先选择职位！");
        return false;
    }
    //J.dialog.get({ id: 'SelectResume', title: '申请职位', page: '../P/SelectResume.aspx?StationID='+StationID+'', cover: true,nofoot:true,height:'200' });
    linkurl("ApplyJob.aspx?StationID="+StationID+"");
}
//
function getCheckN0(obj){
    var i = 0;
    $("input:checked").each(function(id){
        select = $("input:checked").get(id);
        i++;
    });
//    if(i > 5)
//    {
//        obj.checked = false;
//        alert("对不起，您一次最多只能申请5个职位");
//    }
}

function changeCss(obj,o_css,n_css){
    $("#div"+obj+"").removeClass("Q1126_list"+o_css+"");
    $("#div"+obj+"").addClass("Q1126_list"+n_css+"");
}
function SearchDisplay(liId){
   $("#"+liId+"").click(function(){
      if($("#"+liId+"-s")[0].style.display !="none"){
            $("#"+liId+"-s").hide();
      }
      else{
            $("#"+liId+"-s").show();
      }
   });
}
//新加的
function KxAppJob(_stationID){
   StationID = _stationID;
   CheckSession();
}

function GetKeyWords()
{
    var mc = Request("mc");
        mc=mc.replace("#List","");
        mc=mc.replace("#login","");
        mc=mc.replace("#","");
    var zw = Request("zw");
        zw=zw.replace("#List","");
        zw=zw.replace("#login","");
        zw=zw.replace("#","");
    if(mc != ""){
        $("#keyWord")[0].value =decodeURI(mc);
        gjz_qyClick();   
    }
    if(zw !=""){
        $("#keyWord")[0].value =decodeURI(zw);
        gjz_zwClick();  
    }
}


function gjz_zwClick(){
    isCompany = false;
    $("#gjz_zw").removeClass("bt_zw2");
    $("#gjz_zw").addClass("bt_zw1");
    
    $("#gjz_qy").removeClass("bt_qy1");
    $("#gjz_qy").addClass("bt_qy2");
}
function gjz_qyClick(){
    isCompany = true;
    $("#gjz_zw").removeClass("bt_zw1");
    $("#gjz_zw").addClass("bt_zw2");
    
    $("#gjz_qy").removeClass("bt_qy2");
    $("#gjz_qy").addClass("bt_qy1");
}





function SetKeyWordsResultPosition(){
     var obj = $("#keyWord");
     var _left = obj.offset().left;
     var _top = obj.offset().top+26;
     $("#keyWordsResult").css({left:""+_left+"",top:""+_top+""});
     //顺便再加一个
     kxOrderSelector
     var kxOrderSelector = $("#kxOrderSelector");
     var _left2 = kxOrderSelector.offset().left;
     var _top2 = kxOrderSelector.offset().top+18;
     $("#childOrderSelector").css({left:""+_left2+"",top:""+_top2+""});
}
function ShowKeyWordsResult(){
      var keyWord = $("#keyWord").val();
      if(keyWord != ""){
          $.ajax({
            type: "post",
            url: "/Index/Ashx/KeyWordsResult.ashx",
            data:"Keyword="+keyWord+"",
            success: function(data){
               $("#keyWordsResult").html(data); 
               KeywordsCount = $("#KeywordsCount").val();              
               if(KeywordsCount > 0){
                   $("#keyWordsResult").show();
                   _height = KeywordsCount*22;
                   $("#keyWordsResult").css({height:""+_height+""});
                   thisKeyWordsIndex=-1;
                    
               }else{
                   thisa = null;
                   $("#keyWordsResult").hide();
               }     
            },
            error: function(){
                alert("错误");
            }
         });
      }
}
function ChangeLiCss(id){
    if(thisa != null)
    {
        thisa.removeClass("keyWordsResulthover");
    }
    $("#kxLi"+id+"").addClass("keyWordsResulthover");
    thisa = $("#kxLi"+id+"");
    $("#keyWord")[0].value = thisa.text();
    thisKeyWordsIndex = id;
}

function KxSearch(){
   $("#keyWordsResult").hide();
   thisKeyWordsIndex = -1;
   setLod("kxList",10);
   GetListCount(getWhere());
   return false;
}

function InitSetValue()
{
    var newLashResearchValue = $.cookie("LashResearchValue0");
    var newLashResearchText0 = $.cookie("LashResearchText0");
    if(newLashResearchValue != undefined && newLashResearchText0 != undefined)
    {
        LashResearchValue0 = newLashResearchValue;
        LashResearchText0 = newLashResearchText0
        if(LashResearchText0 !="")
        {
            $("#LashResearch").html(LashResearchValue0+LashResearchText0+"</font></a>");
            $("#ss-zj").show();
            $("#ss-zj-s").show();  
        }
        else{
            $("#ss-zj").hide();
            $("#ss-zj-s").hide();
        }
    }
    else{
        $("#ss-zj").hide();
        $("#ss-zj-s").hide();       
    }
}

function KxOrder(kxOrder,obj){
    $("#kxOrderSelector").html(obj.innerHTML);
    $("#childOrderSelector").hide();

    pageFoot(strWhere);
    orderStr = kxOrder;
    getList(strWhere,1)
    return false;
}

