    var pageIndex=1
var pageCount=1

jQuery(document).ready(function(){

function Request(strName){
var strHref = location.href;
//http://localhost:29190/template/allPinot.html?action=GetPageData&PageNo=1&type=media&oder=UploadDate 
var intPos = strHref.indexOf("?");  
var strRight = strHref.substr(intPos + 1);  
var arrTmp = strRight.split("&");  
for(var i = 0; i < arrTmp.length; i++) {  
var arrTemp = arrTmp[i].split("=");  
if(arrTemp[0].toUpperCase() == strName.toUpperCase()){
return arrTemp[1];  
}
}
  
}
//-----------------------------------------------------------

function getPageData(pageNo){ //取得某页数据的方法
        
         $.get("/AJaxPage/PageService.ashx",{"action":Request ("action"),"PageNo":Request ("PageNo") ,"oder":Request ("oder")},function(data,status){
       
         pageIndex =Request ("PageNo")
         if(status=="success"){
             $("#Comment").empty();
        
             var json =  jQuery.parseJSON(data);
             $("#pages").empty(); 
             var p=$("<p>"+pageIndex   +"/"+ pageCount +"</p>" );
             $("#pages").append(p); 
               
               //上一页链接
             var shangPage=parseInt(pageNo)-1
             var shang 
        
             if (pageIndex==1){
                 shang=$("<span>上一页</span>")
              
             }else {
                 if (Request ("oder")=="Point"){               
                        shang=$("<a href='allPinot.htm?action=GetPageData&PageNo="+shangPage+"&type=media&oder=Point'> 上一页</a>")
                 }else {         
                       shang=$("<a href='allPinot.htm?action=GetPageData&PageNo="+shangPage+"&type=media&oder=TotalView'> 上一页</a>")                      
                 }
             }
              var shangye
          
             if(pageIndex==1){
                 shangye=$("<span>上一页</span>")
            
             }else{
                 if (Request ("oder")=="Point"){               
                        shangye=$("<a href='allPinot.htm?action=GetPageData&PageNo="+shangPage+"&type=media&oder=Point'> 上一页</a>")
                 }else{         
                       shangye=$("<a href='allPinot.htm?action=GetPageData&PageNo="+shangPage+"&type=media&oder=TotalView'> 上一页</a>")                      
                 }
             }
      
           $("#shang").empty();
           $("#shang").append(shang);
           $("#shangye").empty();
           $("#shangye").append(shangye);
           //下一页链接

             var nextPage=parseInt(pageNo)+1
             var next
             if (pageIndex ==pageCount ){
                next=$("<span>下一页</span>")
             }else{
                 if (Request ("oder")=="Point"){           
                 next=$("<a href='allPinot.htm?action=GetPageData&PageNo="+nextPage+"&type=media&oder=Point'> 下一页</a>")
                   
                 }else {                     
                    next=$("<a href='allPinot.htm?action=GetPageData&PageNo="+nextPage+"&type=media&oder=TotalView'> 下一页</a>")
                 }
              }
              var nextye
   
              if (pageIndex ==pageCount ){
                nextye=$("<span>下一页</span>")
             }else{
                 if (Request ("oder")=="Point"){           
                 nextye=$("<a href='allPinot.htm?action=GetPageData&PageNo="+nextPage+"&type=media&oder=Point'> 下一页</a>")
                   
                 }else {                     
                    nextye=$("<a href='allPinot.htm?action=GetPageData&PageNo="+nextPage+"&type=media&oder=TotalView'> 下一页</a>")
                 }
              }
       
           $("#next").empty();
           $("#next").append(next);
            $("#nextye").empty();
           $("#nextye").append(nextye);
            for(var i=0,l=json.length;i<l;i++){
      
//             var li= $("<li>"+json[i]["Name"]+"</li>");
                if (Request ("type")=="media"){   
                    if (i%4==3){
                     
                      var li= $("<li class='right_none'><p class='img_hover'><a href='"+json[i]["player"]+"' onclick ='window.open("+json[i]["player"]+")'><img src='"+json[i]["ImageUrl"]+"' width='175' height='131' /><span></span></a></p><span class='text'><a href='"+json[i]["player"]+"' onclick ='window.open('"+json[i]["player"]+"')'> "+json[i]["Name"]+"</a><br />发表于"+json[i]["UploadDate"]+"<br /><b>播放："+json[i]["TotalView"]+"</b>评论："+json[i]["PointCount"]+"</span></li>");
                  
                    }else {
                  
                     var li= $("<li><p class='img_hover'><a href='"+json[i]["player"]+"' onclick ='window.open("+json[i]["player"]+")'><img src='"+json[i]["ImageUrl"]+"' width='175' height='131'  /><span></span></a></p><span class='text'><a href='"+json[i]["player"]+"' onclick ='window.open('"+json[i]["player"]+"')'> "+json[i]["Name"]+"</a><br />发表于"+json[i]["UploadDate"]+"<br /><b>播放："+json[i]["TotalView"]+"</b>评论："+json[i]["PointCount"]+"</span></li>");

                    }
                    $("#Comment").append(li);    //每取出一条数据就创建一个li并append到Comment/ul内。
                }else {
                     var li= $("<li><p class='img_hover'><a href='/html/player/20110913/Player_8464.htm' onclick ='window.open("+"/html/player/20110913/Player_8464.htm"+")><img src='kjhig' /><span></span></a></p><span class='text'><a href='#' onclick ='window.open('hvjv')'> "+json[i]["Name"]+"</a><br />发表于"+json[i]["UploadDate"]+"<br /><b>播放："+json[i]["TotalView"]+"</b>评论："+json[i]["PointCount"]+"</span></li>");
                      $("#Comment").append(li); 
                }
            }
      
         }
        });
}
//-------------------------------------------------------------------
getPageData(Request ("pageNo")); //首次进入页面，看到的是第一页的数据
//----------------------------------------------------------------/
//取得所有的页数并且初始化分页按钮
 $.post("/AJaxPage/PageService.ashx",{"action":"GetPageCount"},function(data,status){
 
             if(status=="success"){  
                 var pageNo=parseInt(data);
                 pageCount =pageNo 
                 
    
             }     
          });
//----------------------------------------------------------------------------
});