﻿// 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,sc3:null};
function WebMain()
{   
 $.SetFormat("zh","newpaper","<li class='linkover'><a style='width:260px;' href=\"paper.html?{'id':#0#}\" target=\"_blank\">#1#</a></li>","","");
/*论文页最新论文*/$("#newpaper").SendMessage({bLoading:false,type:"DBSelect",id:"newpaper",pm :"<@ehai_paper%16Id%16Id,Title%16%16%16CreateTime desc%160%16IsShow=1 and IsCheck=1@>%16",format:"newpaper",start:0,total:11});
getCategoryRightData($.PageParam.ketj,$.PageParam.autj,$.PageParam.titj,$.PageParam.type);
EhaiGrid.grid = jQuery("#list").jqGrid({
    url:'Default.aspx',
    datatype: 'json',
    colNames:['文章标题','作者','发布时间'],
    colModel :[ 
    {name:'Title',index:'Title', width:400,sortable:false},
    {name:'Author',index:'Author', width:220,sortable:false},
    {name:'CreateTime',index:'CreateTime', width:90,align:'left',sortable:false}
    ],
    pager: jQuery('#pager'),
    rowNum:30,
    rowList:[30,60,80],
    sortname: 'id',
    sortorder: "desc",
    viewrecords: true,
    imgpath: 'Controls/grid/themes/ehai_front1/images',
    caption: "",
    width:710,
    height:700,
    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(8);
}
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_paper@>%16Id%16Count(*)%16%16%16CreateTime desc%160%16IsCheck = 1 and IsShow = 1"+(EhaiGrid.sc3?EhaiGrid.sc3:"")+"%16"},true);
};
function sendMsg(re,msg)
{
    var t={type:"DBSelect",callback:newsCallback,bDefCall:false,id:"paper",pm :"<@ehai_paper%16Id%16Id,Title,Author,DATE_FORMAT(CreateTime,'%y-%m-%d')%16%16%16CreateTime desc%160%16 IsCheck = 1 and IsShow = 1"+(EhaiGrid.sc3?EhaiGrid.sc3:"")+"%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="[";
    for(var i=msg.start,j=msg.start+msg.total;i<j;i++)
    {                                      
        rows+="{id:'"+re[i][0]+"',cell:['<a href=\"paper.html?{\\\'id\\\':\\\'"+re[i][0]+"\\\'}\" target=\"_blank\">"+re[i][1]+"</a>','"+re[i][2]+"','"+re[i][3]+"']},";
    }
    if(rows.lastIndexOf(',')==rows.length-1)
        rows=rows.substring(0,rows.length-1);
    rows+="]";
    records.rows=eval("("+rows+")");
    EhaiGrid.curFun(records,EhaiGrid.bDiv);
    if(!$.browser.msie)
        $("table.scroll tbody td").css("paddingLeft","12px");
    else
    $("table.scroll tbody td").css("textIndent","12px");
};  
function getCategoryRightData(ke,au,t,type)
{
    EhaiGrid.sc3="";
    if(type=="1")
    {
        if(ke){
        EhaiGrid.sc3+=" and Title like '%"+ke+"%'";
        }
    }
    if(type=="2")
    {
        if(ke){
        EhaiGrid.sc3+=" and Content like '%"+ke+"%'";
        }
    }
    if(au)
    {
        EhaiGrid.sc3+=" and Author like '%"+au+"%'";
    }
    if(t)
    {
        EhaiGrid.sc3+=" and NOW()<DATE_ADD(CreateTime,INTERVAL "+t+" day)";
    }
    EhaiGrid.totalRecord=-1;
    jQuery("#list").trigger("reloadGrid");
};
//页内搜索
window.tjtype2=1;
function paper_rightsearch()
{
    var aimUrl;
    var ketj=$("#keyword").val();
    var autj=$("#Authorname").val();
    var titj=$("#stime").val();
    aimUrl="paperlist.html?{'ketj':'"+ketj+"','autj':'"+autj+"','titj':'"+titj+"','type':'"+tjtype2+"'}";
    window.location=aimUrl;
};
function settype2(ra)
{
    tjtype2=ra;
};
