     var progressBarValue;
    var progressBarWidth;
     var progressBarFG = '#9999FF';
    var progressBarBG = '#FFFFFF';
     var progressBarBorderColor = '#000000';
     var progressBarBorderWidth = 1;
	 
    /*function sleep(millis) {
    var notifier = new EventNotifier();
    setTimeout(notifier, millis);
    notifier.wait->();
	}*/
	
function PopupRelocate() {
//alert("ds relocate");
 var scrolledX, scrolledY;
 if( self.pageYOffset ) {
   scrolledX = self.pageXOffset;
   scrolledY = self.pageYOffset;
 } else if( document.documentElement && document.documentElement.scrollTop ) {
   scrolledX = document.documentElement.scrollLeft;
   scrolledY = document.documentElement.scrollTop;
 } else if( document.body ) {
   scrolledX = document.body.scrollLeft;
   scrolledY = document.body.scrollTop;
 }

 var centerX, centerY;
 if( self.innerHeight ) {
   centerX = self.innerWidth;
   centerY = self.innerHeight;
 } else if( document.documentElement && document.documentElement.clientHeight ) {
   centerX = document.documentElement.clientWidth;
   centerY = document.documentElement.clientHeight;
 } else if( document.body ) {
   centerX = document.body.clientWidth;
   centerY = document.body.clientHeight;
 }

 //var leftOffset = scrolledX + (centerX) / 2;
 var topOffset = scrolledY + (centerY) / 2;

 document.getElementById("progressBar").style.top = topOffset + "px";
 document.getElementById("progressBar").style.left =  "450px";
}

function firePopup() {
alert("dans firepopup");
 PopupRelocate();
 document.getElementById("progressBar").style.display = "block";
 document.body.onscroll = PopupRelocate;
 window.onscroll = PopupRelocate;
}
     function initProgressBar(width)
     {
     setProgressBar(0);
     progressBarWidth = width;
     document.write('<div id="progressBar" style="padding-left: 15px;padding-top: 15px;padding-bottom: 15px;padding-right:15px;position: absolute; width: 600px; background: #ddd; border: 1px solid #000; right: 0px; top: 300px;">here will be the progress bar</div>');
	//firePopup();
	PopupRelocate();
	document.body.onscroll = PopupRelocate;
    window.onscroll = PopupRelocate;
    dispProgressBar();
    return true;
    }
        function dispProgressBar()
    {
     var html = '';
    var td1 = '';
     var td2 = '';
     var val = getProgressBar();
	 //alert(val);
	// document.getElementById("progressBar").style.top = val + "px";
	//document.getElementById("progressBar").style.left = val + "px";
     if (val == 0) {
     td1 = '';
     td2 = '<td width="100%" align="center">0 %</td>';
     }
     else if (val == 100) {
     td1 = '<td width="100%" bgColor="' + progressBarFG + '" align="center">100&nbsp;%</td>';
     td2 = '';
	 
     }
     else if (val > 50) {
     td1 = '<td width="' + val + '%" bgColor="' + progressBarFG + '" align="center">' + val + '&nbsp;%</td>';
     td2 = '<td width="' + (100-val) + '%">&nbsp;</td>';
     }
     else {
     td1 = '<td width="' + val + '%" bgColor="' + progressBarFG + '">&nbsp;</td>';
     td2 = '<td width="' + (100-val) + '%" align="center">' + val + '&nbsp;%</td>';
     }
     html = '<table border="' + progressBarBorderWidth + '" ';
     html += 'width="' + progressBarWidth + '" ';
     html += 'borderColor="' + progressBarBorderColor + '" ';
     html += 'bgColor="' + progressBarBG + '" ';
     html += 'cellpadding="5" cellspacing="0">';
     html += '<tr>' + td1 + td2 + '</tr></table>';
     writeToLayer('progressBar', html);
	 if(val == 100)
	   document.getElementById('progressBar').className = "cache";
     }
    
     function setProgressBar(value)
     {
     if (value < 0) {
     progressBarValue = 0;
     }
     else if (value > 100) {
	 
      progressBarValue = 100;
     }
     else {
     progressBarValue = value;
     }
     return true;
     }
    
     function getProgressBar()
     {
     return progressBarValue;
     }




