﻿// JScript 文件
window.IncludeFile={"header":"head.html","zj_right":"zj_right.html","tailer":"tail.html"};
window.JsModule=["system/jqframe.js","js/zj_right.js"];
window.EhaiGrid={curPage:1,curRowNum:1,totalRecord:-1,curFun:null,bDiv:null,sc:null,sort:''};

function WebMain()
{   
    EhaiGrid.grid = jQuery("#list").jqGrid({
        url:'Default.aspx',
        datatype: 'json',
        colNames:['专家名录'],
        colModel :[ 
        {name:'id',index:'id', width:755,sortable:false}
        ],
        pager: jQuery('#pager'),
        rowNum:12,
        rowList:[12,24,36],
        sortname: 'id',
        sortorder: "desc",
        viewrecords: true,
        imgpath: 'Controls/grid/themes/ehai_front1/images',
        caption: "",
        width:720,
        height:520,
        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;</span>"); 
}
var curSid;
var curPage,curRowNum,totalRecord,curFun,bDiv;
function getNews(page,rowNum,sortname,sortorder,fun,bd)
{
    EhaiGrid.curPage=page;
    EhaiGrid.curRowNum=rowNum;
    EhaiGrid.curFun=fun;
    EhaiGrid.bDiv=bd;
    if(EhaiGrid.curPage==1)
    $("div.r_slider").css("left","0px");
    if(EhaiGrid.totalRecord==-1)
        getTotalRecord();
    else
        sendMsg();
};
function getTotalRecord()
{
    
    $.SendMessage({type:"DBSelect",bDefCall:false,callback:sendMsg,pm :"<@ehai_user@>%16Id%16Count(*)%16%16%16%160%16RoleType=3 "+(EhaiGrid.sc?EhaiGrid.sc:"")+"%16"},true);

};
function sendMsg(re,msg)
{
    var t={type:"DBSelect",callback:newsCallback,bDefCall:false,id:"productList",pm :"<@ehai_user%16Id%16Id,Photo,eName,TechPost,Major,Website,UserName%16%16%16orderflag desc@>%160%16RoleType=3 "+(EhaiGrid.sc?EhaiGrid.sc:"")+"%16",start:EhaiGrid.curRowNum*(EhaiGrid.curPage-1),total:EhaiGrid.curRowNum};
    if(re)
    {
        EhaiGrid.totalRecord=re[0][0];
        t.bRefresh=true;
    }
    $.SendMessage(t,true);
};
function newsCallback(re,msg)
{
    var records={total:Math.ceil(EhaiGrid.totalRecord/EhaiGrid.curRowNum),page:EhaiGrid.curPage,records:EhaiGrid.totalRecord};
    var rows="[";
    rows+="{id:'"+re[0][0]+"',cell:['<div class=\"expertList\">";
    for(var i=msg.start,j=msg.start+msg.total;i<j;i++)
    {
    rows+="<div class=\"expertDiv\"><a target=\"_blank\" href=\"zj_xx.html?{id:"+re[i][0]+"}\"><img class=\"expert_image\" alt=\"图片\" src=\""+re[i][1]+"\" /></a><ul class=\"expert_unit\" ><li style=\"width:120px;overflow:hidden;\">专家："+re[i][2]+"</li><li style=\"width:120px;overflow:hidden;\">职称："+re[i][3]+"</li><li style=\"width:120px;overflow:hidden;\">专业："+re[i][4]+"</li></ul></div>";
    }
    rows+="</div>'";
    rows+="]}";

    if(rows.lastIndexOf(',')==rows.length-1)
        rows=rows.substring(0,rows.length-1);
    rows+="]";
    records.rows=eval("("+rows+")");
    EhaiGrid.curFun(records,EhaiGrid.bDiv);
};
function zxbutton(id)
{
    window.location="specialist_zx.html?{'id':"+id+"}";
}
function zjblog()
{
    window.location="home/";
}