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

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

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

TSend.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+'&id='+this.id, true);
        http.onreadystatechange=function() {
                if (http.readyState==4 & TSend.started) {
                        TSend.started=false;
                        TSend.pos++;
                        p=document.getElementById('progress');
                        p.width=Math.round(TSend.width*TSend.pos/(TSend.count));
                        p=document.getElementById('progress_percent');
                        p.innerHTML=Math.round(100*TSend.pos/(TSend.count))+'%';
                        TSend.forward=http.responseText;
                        TSend.Next();
                }
        }
        http.send(null);
}