var Export=new Object();
Export.width=500;

Export.Start=function(url, count) {
        this.started=false;
        this.forward='';
        this.url=url;
        this.pos=0;
        this.count=count;
        this.Next();
}

Export.Next=function() {
        if (this.pos<=this.count) this.Send();
        else window.location.href=this.forward;
}

Export.Send=function() {
        this.started=true;
        if (window.XMLHttpRequest) http=new XMLHttpRequest();
        else http=new ActiveXObject("Microsoft.XMLHTTP");
        http.open("GET", this.url+'?l='+this.pos, true);
        http.onreadystatechange=function() {
                if (http.readyState==4 & Export.started) {
                        Export.started=false;
                        Export.pos++;
                        p=document.getElementById('progress');
                        p.width=Math.round(Export.width*Export.pos/(Export.count+1));
                        p=document.getElementById('progress_percent');
                        p.innerHTML=Math.round(100*Export.pos/(Export.count+1))+'%';
                        Export.forward=http.responseText;
                        Export.Next();
                }
        }
        http.send(null);
}