function dorefresh() {
   var div = document.getElementById( "gallerybox" ); 
   var width = document.body.clientWidth-200;
   if ( ""+width == "NaN" ) {
   		width = window.innerWidth-200;
   }
   if ( width < 350 ) {
      width = 350;
   }
   var vpos = 0;
   var hpos = 0;
   var height = 0;
   str = "";
   i=0;
   str += "length: " + div.childNodes.length;
   while( i < div.childNodes.length ) {
  	  extra = 0;
  	  hpos = 0;
  	  jump = false;
  	  for( j=i; j<div.childNodes.length; j++) {
  	     child = div.childNodes[j];
  	  	 if ( (hpos + child.offsetWidth) > width ) {
			extra = (width - hpos)/(j-i);
			break;
  	     }
  	  	 hpos += child.offsetWidth;
  	  }
   	  extra = (width - hpos)/(j-i-1);
  	  k=0;
  	  hpos = 0;
  	  height = 0;
  	  str += " (" + i+"-"+j+")";
  	  
  	  if ( j<=i ) {
  	    break;
  	  }
  	  for( k=i; k<j; k++) {
     	  child = div.childNodes[k];
		  // if ( child == null) {continue;}

     	  if ( height < child.offsetHeight) {
 	     	 height = child.offsetHeight;
 	      }
 	      child.style.position="absolute";
          child.style.left=(hpos+32)+"px";
          child.style.top =(vpos+32)+"px";

  	  	  str+=(" *"+k+" l "+(hpos+32)+"  " + extra + " ");
  	  	//  str+=(" *"+k+" t "+(ypos+32)+"  ");

	      hpos += child.offsetWidth + extra;
	  }
	  vpos += height+16;
	  i=k;
   }
   //vpos+=height;
   div.style.width = width + "px";
   div.style.height = vpos + "px";

}