var uploadStatusWin = null;


function bodyUnload() {
   if (uploadStatusWin != null) {
       uploadStatusWin.close();
   }
}

function openUploadStatus() {

   var wWidth = 350;
   var wHeight = 200;
   var wLeft = (screen.width - wWidth ) /2;
   var wTop = (screen.height - wHeight ) /2;

   uploadStatusWin = window.open('/upload_status.php', 'uploadStatusWin','toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=no, width=' + wWidth + ', height=' + wHeight + ', left=' + wLeft + ', top=' + wTop);
    	
   uploadStatusWin.focus();
   return true;
}




var screenWidth = 0, screenHeight = 0;

function  getScreenDimention() {
  // heavily based from
  // http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16
  //
   
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    screenWidth = window.innerWidth;
    screenHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    screenWidth = document.documentElement.clientWidth;
    screenHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    screenWidth = document.body.clientWidth;
    screenHeight = document.body.clientHeight;
  }
 }


  function updateProgressBarCoord() {
    var Xcursor = (document.layers) ? e.pageX : event.x
    var Ycursor = (document.layers) ? e.pageY : event.y
    alert(Xcursor + ' ' + Ycursor);
    document.getElementById('progressbar').style.left = Xcursor;     
    document.getElementById('progressbar').style.top = Ycursor;         
  }
  
  var pbtableWidth=0;
  var updateRate=85;
    
  function updateProgressBar() {

	pbtableWidth += 10;
	if (pbtableWidth > 350) {
	  pbtableWidth = 0;
     }
        
     document.getElementById('pbtable').style.width = pbtableWidth + 'px';
     setTimeout('updateProgressBar()', updateRate);
  }	
 
  function setProgressBarVisibility(visible) {

      if (visible) {
  	     setTimeout('updateProgressBar()', updateRate);
         document.getElementById('progressbar').style.visibility = 'visible';
         getScreenDimention();
         document.getElementById('progressbar').style.width = screenWidth;         
      } else {
	     setTimeout('updateProgressBar()', 0);
         document.getElementById('progressbar').style.visibility = 'hidden';
      }

  }
  
  

