function wOpen (href, width, height) {
   var max_width=screen.width-10;
   var max_height=screen.height-10;
   var divider=1;

   while(width/divider>max_width || height/divider>max_height) divider++;

   width/=divider;
   height/=divider;

   window.open(href,'image', 'width=' + width + ', height='+ height + ',scrollbars=auto,fullscreen=no,resizable=yes,status=no,toolbar=no,menubar=no,directories=no,top=0,left=0');
};

function preview(what, w, h, scrollbars) {
	if (!what) return;
	if (!w) w = 530;
	if (!h) h = 530;
	scrollbars = scrollbars ? 1 : 0;
	scr_w = screen.width;
	scr_h = screen.height;
	l = (scr_w - w) / 2;
	t = (scr_h - h) / 2;
	popup = window.open(what, "window_id", "width=" + w + "px,height=" + h + "px,left=" + l + "px,top=" + t + "px,scrollbars=" + scrollbars + ",location=0,toolbar=0,resizable=1,menubar=0,status=0,dependent=1");
	popup.focus();
}

function popupPage(w,h,URL) {
var l = 75;
var t = 75;

var windowprops = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes" +
",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
popup = window.open(URL,"MenuPopup",windowprops);
}