﻿// JScript 文件
var xmlhttp;
function createHttp()
{
    if(window.ActiveXObject)
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
        
    }
    else if(window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
    }
}

function choosePage(page)
{
    createHttp();
    xmlhttp.open("GET","/UserUI/JoinFullyPower/DataPage.aspx?Page="+page,true);
    xmlhttp.onreadystatechange=statechange;
    xmlhttp.setRequestHeader("If-Modified-Since","0");
    xmlhttp.send(null);
}
function statechange()
{
    if(xmlhttp.readystate==1)
    {
        document.body.style.cursor="wait";
    }
    if(xmlhttp.readystate==4)
    {
        document.body.style.cursor="default";
        if(xmlhttp.status==200)
        {
            changePage(xmlhttp.responseText);            
        }
        else
        {
        alert("请求数据错误");
        }
    }
}
function changePage(text)
{
    var rows=text.split("||");
    var table="<table cellspacing='0' cellpadding='0' border='0' style='border-width:0px;width:840px;border-collapse:collapse;'>";
    for(i=1;i<rows.length;i++)
    {
        var cells=rows[i].split("&&");
        table +="<tr><td><div class='List4SLItem'>";
        table +="<table class='List4SItemBody' cellpadding='0' cellspacing='0' border='0'>";
        table +="<tr><td rowspan='6' width='160px' align='left'><a href='ShopInfo.aspx?ID="+cells[0]+"' target='_blank'><img src='"+cells[1]+"' width='150px' height='120px' class='NoBorder' /></a></td><td style='font-size: 13px;'><font color='#ffc40e'>"+cells[2]+"</font></td></tr>";
        table +="<tr><td width='240px' align='left'>电话：<font color='#ababab'>"+cells[3]+"</font></td></tr>";
        table +="<tr><td align='left'>传真：<font color='#ababab'>"+cells[4]+"</font></td></tr>";
        table +="<tr><td align='left'>电邮：<font color='#ababab'>"+cells[5]+"</font></td></tr>";
        table +="<tr><td align='left'>联系：<font color='#ababab'>"+cells[6]+"</font></td></tr>";
        table +="<tr><td align='left'>地址：<font color='#ababab'>"+cells[7]+"</font></td></tr>";
        table +="</table></div></td>";
        i++;
        if(i<rows.length)
        {
            var cells2=rows[i].split("&&");
            table +="<td><div class='List4SRItem'>";
            table +="<table class='List4SItemBody' cellpadding='0' cellspacing='0' border='0'>";
            table +="<tr><td rowspan='6' width='160px' align='left'><a href='ShopInfo.aspx?ID="+cells2[0]+"' target='_blank'><img src='"+cells2[1]+"' width='150px' height='120px' class='NoBorder' /></a></td><td style='font-size: 13px;'><font color='#ffc40e'>"+cells2[2]+"</font></td></tr>";
            table +="<tr><td width='240px' align='left'>电话：<font color='#ababab'>"+cells2[3]+"</font></td></tr>";
            table +="<tr><td align='left'>传真：<font color='#ababab'>"+cells2[4]+"</font></td></tr>";
            table +="<tr><td align='left'>电邮：<font color='#ababab'>"+cells2[5]+"</font></td></tr>";
            table +="<tr><td align='left'>联系：<font color='#ababab'>"+cells2[6]+"</font></td></tr>";
            table +="<tr><td align='left'>地址：<font color='#ababab'>"+cells2[7]+"</font></td></tr>";
            table +="</table></div></td>";
        }
    table +="</tr>";
    }
    table +="</table>";
    document.getElementById("bodyList").innerHTML=table;
    document.getElementById("paginationDiv").innerHTML=Pagination(rows[0]);
}

function Pagination(str)
{
    var data=str.split("&&");
    var pc=parseInt(data[0]);//总页数
    var page=parseInt(data[1]);//当前选中页
    var row=parseInt(data[2]);//每页的记录数
    
    var html = "<div style='float: left;'>共<font color='#ffc208'>" + pc + "</font>页，每页<font color='#ffc208'>" + row + "</font>条</div>";
    html =html + "<div style='float: right;'>";
    if (page > 1)
    {
        html =html+ "<span onclick='choosePage(1)' style='cursor: hand;'>第一页</span>";
        html =html+ " <span onclick='choosePage(" + (page - 1) + ")' style='cursor: hand;'>上一页</span>";
    }
    var sta=1;
    if(page>5)
    {
        sta=page-5;
    }
    var end = page + 5;
    if ((page + 5) > pc)
    {
        end = pc;
    }
    for (i = sta; i <= end; i++)
    {
        if (page == i)
        {
            html =html+ " <span onclick='choosePage(" + i + ")' style='cursor: hand;color:#ffc208;'>" + i + "</span> ";
        }
        else
        {
            html =html+ " <span onclick='choosePage(" + i + ")' style='cursor: hand;'>" + i + "</span> ";
        }
    }
    if (page < pc)
    {
        html =html+ "<span onclick='choosePage(" + (page + 1) + ")' style='cursor: hand;'>下一页</span> ";
        html =html+ "<span onclick='choosePage(" + pc + ")' style='cursor: hand;'>最末页</span>";
    }
    html =html+ "</div>";
    return html
}