﻿// JScript 文件
window.IncludeFile={"header":"head.html","tailer":"tail.html"};
window.JsModule=["system/jqframe.js"]; 
window.EhaiGrid={curPage:1,curRowNum:1,totalRecord:-1,curFun:null,bDiv:null,sc:null,sc2:null};
function WebMain()
{
     $.SetFormat("zh","settypesmall","<p style=\"float:left;width:100px;\"><a href=\"rc_zhaopin.html?{'Sort':'#1#'}\">#0#</a></p>","","");
    /*职位分类列表*/$.SendMessage({callback:setbigtype,bLoading:false,type:"DBSelect",id:"getzhiweitypebig",pm :"<@ehai_typetable%16Id%16eName,Class,Id%16%16%16Class asc%160%16Sort=5 and LENGTH(Class)=2%16@>"});
    if($.PageParam.Sort)
    {
        getCategoryData($.PageParam.Sort); 
    }
    getCategoryRightData($.PageParam.rczw,$.PageParam.rcsf,$.PageParam.rctime); 
    //读取grid列表
    EhaiGrid.grid = jQuery("#list").jqGrid({
        url:'Default.aspx',
        datatype: 'json',
        colNames:['招聘信息'],
        colModel :[ 
        {name:'pubtime',index:'Title', width:80,sortable:true} 
        ],
		
	//分条显示栏	
        pager: jQuery('#pager'),
        rowNum:20,
        rowList:[20,30,40],
        sortname: 'creationtime',
        sortorder: "desc",
        viewrecords: true,
        imgpath: 'plugins/grid/themes/ehai_front1/images',
        caption: "",
        width:440,
        height:600,
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: true,
            cell: "cell",
            id: "id",
            userdata: "userdata"
            }
    });   
    $(".selbox:last").before("<span>&nbsp;每页显示&nbsp;</span>"); 
    $(".selbox:last").after("<span>&nbsp;条&nbsp;&nbsp;&nbsp;共</span>"); 
	
	getAdsInfo(36);
}
//读取职位分类列表
function setbigtype(re)
{
    if(re)
    {
        var h=""
        for(i=0;i<re.length;i++)
        {
            h+="<div  class=\"bantitle\"><a href=\"rc_zhaopin.html?{'Sort':'"+re[i][1]+"'}\"><b>"+re[i][0]+"</b></a></div><div  id=\"bigtypeli"+re[i][1]+"\"></div><div style=\"height:1px;clear:both\"></div>"
           
        }
         $("#rc_left").html(h);
        for(i=0;i<re.length;i++)
        {
            /*职位小类*/$("#bigtypeli"+re[i][1]).SendMessage({bLoading:false,type:"DBSelect",pm :"<@ehai_typetable%16Id%16eName,Class,Id%16%16%16Class asc%160%16Sort=5 and LENGTH(Class)=4 and left(Class,2)='@>"+re[i][1]+"'%16",format:"settypesmall"});
        }
    }
};
    
/*
功能：grid操作，grid内部调用
*/
function getNews(page,rowNum,sortname,sortorder,fun,bd)
{
    EhaiGrid.curPage=page;
    EhaiGrid.curRowNum=rowNum;
    EhaiGrid.curFun=fun;
    EhaiGrid.bDiv=bd;
    EhaiGrid.sort=sortname+' '+sortorder;
    if(EhaiGrid.curPage==1)
    $("div.r_slider").css("left","0px");
    if(EhaiGrid.totalRecord==-1)
       getTotalRecord();
    else
       sendMsg();
 };
/*
功能：grid得到总记录数
*/
function getTotalRecord()//连接数据库
{
    $.SendMessage({bDefCall:false,callback:sendMsg,type:"DBSelect",pm :"<@ehai_jobsupply%16Id%16Count(*)%16%16%16PubDate desc%160%16IsShow=1 and status=1@>"+(EhaiGrid.sc?EhaiGrid.sc:"")+"%16"});
 };
 /*
功能：grid取记录
参数说明：re:记录行数组，msg:消息
*/
function sendMsg(re,msg)
{
    var t={type:"DBSelect",callback:newsCallback,bDefCall:false,id:"ehaipf_news",pm :"<@ehai_jobsupply%16Id%16Id,JobName,DATE_FORMAT(PubDate,'%m-%d'),CompanyName,jobnamemc%16%16%16PubDate desc%160%16IsShow=1 and status=1@>"+(EhaiGrid.sc2?EhaiGrid.sc2:"")+(EhaiGrid.sc?EhaiGrid.sc:"")+"%16",start:EhaiGrid.curRowNum*(EhaiGrid.curPage-1),total:EhaiGrid.curRowNum};

//调用newsCallback    
		
    if(re){
          EhaiGrid.totalRecord=re[0][0];
    }        
    t.bRefresh=true;
    $.SendMessage(t,true);     
 };
 /*
功能：设置grid记录行
参数说明：re:记录行数组，msg:消息
*/
function newsCallback(re,msg)
{
    var records={total:Math.ceil(EhaiGrid.totalRecord/EhaiGrid.curRowNum),page:EhaiGrid.curPage,records:EhaiGrid.totalRecord};
    var rows="[";
    for(var i=msg.start,j=msg.start+msg.total;i<j;i++)
    {
         rows+="{id:'"+re[i][0]+"',cell:['<div style=\"width:440px;height:20px;color:#4B4B4B\"><a style=\"background:none;height:20px;line-height:20px;\" href=\"rc_zhaopindetail.html?{\\\'zpid\\\':\\\'"+re[i][0]+"\\\'}\"><p style=\"color:blue;padding-left:15px;float:left;font-weight:normal\">["+re[i][2]+"]</p><p style=\"margin-left:30px;width:120px;float:left;border:1px #ffffff solid;font-weight:normal\">"+re[i][4]+"</p><p style=\"margin-left:10px;font-weight:normal;float:left;\">"+re[i][3]+"</p></a></div>']},";
    }
    if(rows.lastIndexOf(',')==rows.length-1)
        rows=rows.substring(0,rows.length-1);
    rows+="]";
    records.rows=eval("("+rows+")");
    EhaiGrid.curFun(records,EhaiGrid.bDiv);
    $("table.scroll tr.over td").css("backgroundColor","#FFF"); 
};  
function getCategoryData(classid)  
{
    EhaiGrid.sc2=" and Sort like '"+classid+"%'";
    EhaiGrid.totalRecord=-1;
    jQuery("#list").trigger("reloadGrid");
    
}; 

//图片跳转
function tiaozhuan()
{
    $.SendMessage({type:"Session",callback:getsessiongq,pm :"<@@>"},true);
};
function getsessiongq(re)
{
    if(re[0][0])
        window.location.href="of_bangongshi.html";
    else
        alert("您未登录");
};



//页内搜索
window.tjtype2=1;
function rc_rightsearch()
{
    var aimUrl;
    var rczw=$("#rczw").val();
    var rcsf=$("#rcsf").val();
    var rctime=$("#rctime").val();
    if(tjtype2==1)
    {
        aimUrl="rc_qiuzhi.html?{'rczw':'"+rczw+"','rcsf':'"+rcsf+"','rctime':'"+rctime+"'}";
    }else if(tjtype2==2)
    {
        aimUrl="rc_zhaopin.html?{'rczw':'"+rczw+"','rcsf':'"+rcsf+"','rctime':'"+rctime+"'}";
    }    
    window.location=aimUrl;
};
function settype2(ra)
{
    tjtype2=ra;
};
function getCategoryRightData(zw,sf,t)
{
     EhaiGrid.sc="";
    if(zw){
        EhaiGrid.sc+=" and jobnamemc like '%"+zw+"%'";
    }
    if(sf)
    {
        EhaiGrid.sc+=" and WorkPlace like '%"+sf+"%'";
    }
    if(t)
    {
        EhaiGrid.sc+=" and NOW()<DATE_ADD(PubDate,INTERVAL "+t+" day)";
    }
    EhaiGrid.totalRecord=-1;
    jQuery("#list").trigger("reloadGrid");
}