/************************************************************************************************
@atuhor:常亮
@date: 2009-01-23
scriptfile:common files
function:用javaScript显示分页标签
************************************************************************************************/

//分页所用JavaScript类 
/**
*@Url:分页连接地址,比如说第一页所指向的页面
*@nums:记录总数
*@size:每一页显示的记录数
*@page:当前所在页
*@para:用户的
*/

var GetPageStrUseFunc=function(total,pagesize,pageindex,func,_5,_6)
{   if(total==null || total==""){total=0;};if(pagesize==null || pagesize==""){pagesize=10;};if(_5==null || _5==""){ _5="true";};if(_6==null){_6="";};if(pageindex==null || pageindex==""){pageindex=1;}; total=parseInt(total); pagesize=parseInt(pagesize);pageindex=parseInt(pageindex); if(total<0){total=0;};if(pagesize<1){pagesize=10;};if(pageindex<1){pageindex=1;};var str="";if(_5!="false"){};if(total<=pagesize){}else{var pagetotal=Math.ceil(total/pagesize);if(pagetotal<1)pagetotal=1;var end=pagetotal;if(pagetotal<=6){for(var i=1;i<=pagetotal;i++){if(_6!=""){(pageindex==i)?str+='<span class="active"><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>';}else{(pageindex==i)?str+='<span class="active"><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>';}}}
        else
        {
            if(pageindex<=3)
            {
                end=(pagetotal>=6)?6:pagetotal;
                for(var i=1;i<=end;i++)
                {
                    if(_6!=""){(pageindex==i)?str+='<span class="active"><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>';}else{(pageindex==i)?str+='<span span class="active"><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>'; }
                }
                
                if(end+1<pagetotal)
                {
                    if(_6!=""){str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+','+_6+')">...'+pagetotal+'</a></span>';}else{str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+')">...'+pagetotal+'</a></span>';}
                }
                else
                { 
                    if(_6!="")
                    {
                        str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+','+_6+')">'+pagetotal+'</a></span>';
                    }
                    else
                    {
                        str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+')">'+pagetotal+'</a></span>';
                    }
                }
               
            }
            else
            {
                var start=(pageindex-3>=1)?pageindex-3:1;
                var end=(pageindex+3<=pagetotal)?pageindex+3:pagetotal;
                if(start>1)
                {
                     if(start-1>1)
                     {
                         if(_6!="")
                         {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'(1,'+_6+')">1...</a></span>';
                         }
                         else
                         {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'(1)">1...</a></span>';
                         }
                     }
                     else
                     {
                        if(_6!="")
                        {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'(1,'+_6+')">1</a></span>';
                        }
                        else
                        {
                             str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'(1)">1</a></span>';
                        }
                     }
                }
                for(var i=start;i<=end;i++)
                {
                    if(_6!="")
                    {
                        (pageindex==i)? str+='<span class="active"><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+','+_6+')">'+i+'</a></span>'; 
                    }
                    else
                    {
                        (pageindex==i)? str+='<span class="active"><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>':str+='<span><a href="javascript:void(0)" onclick="Javascript:'+func+'('+i+')">'+i+'</a></span>'; 
                    }
                }
                if(end<pagetotal)
                {
                    if(end+1<pagetotal)
                    {
                        if(_6!="")
                        {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+','+_6+')">...'+pagetotal+'</a></span>'; 
                        }
                        else
                        {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+')">...'+pagetotal+'</a></span>';
                        }
                    }
                    else
                    {
                        if(_6!="")
                        {
                            str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+','+_6+')">'+pagetotal+'</a></span>'; 
                        }
                        else
                        {
                             str+='<span><a href="javascript:void(0)"  onclick="Javascript:'+func+'('+pagetotal+')">'+pagetotal+'</a></span>'; 
                        }
                    }
                }
                
            }
        }    
    }
    //alert(str);
    return str;
};


//下一页
function NextPage(fun)
{
    if(PageIndex < PageTotal)
    {
      PageIndex++;
      window.setTimeout(fun+"("+PageIndex+")",1);
    }
    
}

//上一页
function BackPage(fun)
{
    if(PageIndex > 1)
    {
      PageIndex--;
      window.setTimeout(fun+"("+PageIndex+")",1);
    }
    
}

//首页
function FirstPage(fun)
{
    window.setTimeout(fun+"(1)",1);  
}

//尾页
function LastPage(fun)
{
   window.setTimeout(fun+"("+PageTotal+")",1);
}




//显示分页角本
//<param name="name">将被付值的div的id</param>
//<param name="funname">分页函数的名称</param>
//<param name="total">总条数</param>
//<param name="pageTotal">总页数</param>
//<param name="pagesize">每页条数</param>
//<param name="pageindex">当前页值</param>
function ShowPage(name,funname,total,pageTotal,pagesize,pageindex)
{
    var str = "";
    str += ' <div class="new_link">';
    str += '     <div style="float:left; padding:0 0 0 10px;">共 '+total+'条记录, '+pageTotal +'页,每页'+pagesize+'条,当前第'+pageindex+'页</div>';
    str += '     <div style="float:right; padding:0 10px 0 0;"><span>';
    if(PageTotal>1)
    {
      str +='    &nbsp;<a href="javascript:void(0)" onclick="FirstPage(\''+funname+'\')">首页</a>';
      str +='    &nbsp;<a href="javascript:void(0)" onclick="BackPage(\''+funname+'\')">上一页</a>';
      str +='    &nbsp;<a href="javascript:void(0)" onclick="NextPage(\''+funname+'\')">下一页</a>';
      str +='    &nbsp;<a href="javascript:void(0)" onclick="LastPage(\''+funname+'\')">尾页</a></span>　　';
    }
    str +=   　　GetPageStrUseFunc(Total,PageSize,PageIndex,"SearchAllOrders");
    str += '     </div>';
    str += '     <div style="clear:both"></div>';
    str += ' </div>';
    $(name).innerHTML = str;
}

function Back()
{
   history.back();
}


//排序
function sort(index)
{
    var Arr = new Array();
    var k=0;
    if(SJSort_Type == 0)
    {
        SJSort_Type = 1;
        for(var i=0;i<ArrList.length;i++)
        {
            for(var j=i+1;j<ArrList.length;j++)
            {
                switch(index)
                {
                    case 1:
                   
                    if(ArrList[i].SQR.localeCompare(ArrList[j].SQR)>0)
                    { 
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 2:
                    if(ArrList[i].BSQR.localeCompare(ArrList[j].BSQR)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 3:
                    if(ArrList[i].FYJG.localeCompare(ArrList[j].FYJG)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 4:
                    if(ArrList[i].XZFY.localeCompare(ArrList[j].XZFY)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 5:
                    if(ArrList[i].JAFS.localeCompare(ArrList[j].JAFS)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 6:
                    if(ArrList[i].AJSJ.localeCompare(ArrList[j].AJSJ)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 7:
                    if(ArrList[i].JASJ.localeCompare(ArrList[j].JASJ)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 8:
                    if(ArrList[i].Zrr.localeCompare(ArrList[j].Zrr)>0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                }  
            }       
        }
    }
    else
    {
         SJSort_Type = 0;
        for(var i=0;i<ArrList.length;i++)
        {
            for(var j=i;j<ArrList.length;j++)
            {
                
                switch(index)
                {
                   case 1:
                   
                    if(ArrList[i].SQR.localeCompare(ArrList[j].SQR)<0)
                    { 
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 2:
                    if(ArrList[i].BSQR.localeCompare(ArrList[j].BSQR)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 3:
                    if(ArrList[i].FYJG.localeCompare(ArrList[j].FYJG)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 4:
                    if(ArrList[i].XZFY.localeCompare(ArrList[j].XZFY)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 5:
                    if(ArrList[i].JAFS.localeCompare(ArrList[j].JAFS)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 6:
                    if(ArrList[i].AJSJ.localeCompare(ArrList[j].AJSJ)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 7:
                    if(ArrList[i].JASJ.localeCompare(ArrList[j].JASJ)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                    case 8:
                    if(ArrList[i].Zrr.localeCompare(ArrList[j].Zrr)<0)
                    {
                        var obj = new Object();
                        obj=ArrList[i];
                        ArrList[i] = ArrList[j];
                        ArrList[j] = obj;
                        
                    }
                    break;
                }  
                
            }       
        }
    }
}

