﻿
var downfileID="";

DriverDownLoadCount();

//显示下载次数
function DriverDownLoadCount()
{
    if(document.getElementById("download")!= null)
    {        
        //获取下载文件的列表ID数组                
        var downloadcount = document.getElementById("download").getElementsByTagName("div");
        //alert(downloadcount.length);
        for(var i=0; i <downloadcount.length;i++)
        {
            downfileID +=downloadcount[i].id+",";                                     
        }        
        
       // alert("/pager/DriverDownLoad.Aspx?fileID="+downfileID);
        dealActDownLoad("/pager/DriverDownLoad.Aspx?fileID="+downfileID+"&"+Math.random());
    }
}
//AJAX 获取远程数据
var xmlHttpDownLoad;
function createXMLHttpRequestDownLoad()
{ //创建一个xmlHttpRequest对象
    
    try{ xmlHttpDownLoad = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
        try{ xmlHttpDownLoad = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch(e){ xmlHttpDownLoad = null; }    
    }
    if( !xmlHttpDownLoad && (typeof XMLHttpRequest != "undefined") )
        xmlHttpDownLoad = new XMLHttpRequest();   
    
}
function dealActDownLoad(url)
{   
    createXMLHttpRequestDownLoad();    
    xmlHttpDownLoad.onreadystatechange = handleStateChangeDownLoad; //请求状态改变事件触发handleStateChangeDownLoad功能
    xmlHttpDownLoad.open("GET",url); //采用get方法提交数据
    xmlHttpDownLoad.send(null);       
}
function handleStateChangeDownLoad()
{    
    if(xmlHttpDownLoad.readyState == 4)
    {   //表示请求状态 4为完成
        if(xmlHttpDownLoad.status == 200)
        {
            var returnResult = xmlHttpDownLoad.responseText;
            if(downfileID != "")
            {
                var divDC = returnResult.split('|');
                for(var i=0; i< divDC.length;i++)                                                                
                {
                    if(document.getElementById(divDC[i].split(',')[0])!= null)
                    {                        
                        document.getElementById(divDC[i].split(',')[0]).innerHTML = divDC[i].split(',')[1] ;                      
                    }
                }
            }
        }
    }        
}