// -----------------------------------------------------------------------------
//   customizable open window command

// r = resizable, s = scrollbars, t = toolbar, l = location, d = directories
// the order for rstld doesn't matter
// resizable default is yes, scrollbars,toolbar,location,directories defaults are no

// usage examples:

// openWindow('mylink.html,300,300,s,popWindowName'); -- pops a 300x300 window 
// with scrollbars named "popWindowName"

// openWindow('mylink.html'); -- pops a default size (hardwired to 640,400) 
// window to mylink.html

// openWindow('mylink.html',,,tlr'); -- pops a default size window to mylink.html 
// with tool and location bar that is NOT resizable
// NOTE: notice that in the example above there are two commas after the URL
// they're required in this case because we're adding the 'tlr' options
// commas without values will just pick up the default 640x400 values, or you 
// can change them to whatever. The rule is only the URL is required, but if you
// change a value downstream, then you need to fill in the values between the 
// URL and the value you're changing (even if it's only with a comma).
// -----------------------------------------------------------------------------

function openWindow(options) {

// URL,[width],[height],[rstld],[windowName]

	args=options.split(",");

	url = args[0];

	if (args.length > 1) {
		if (args[1].length > 0) {
			W="width=" + args[1] + ","; 
		} else {
			W="width=640,"; 
		}
	} else { 
		W="width=640,"; 
	}

	if (args.length > 2) {
		if (args[2].length > 0) {
			H="height=" + args[2] + ","; 
		} else {
			H="height=400,"; 
		}
	} else { 
			H="height=400,"; 
	}

	if (args.length > 3) {
		prams= args[3]; 
	} else { 
		prams=""; 
	}

	if (args.length > 4) {
		windowname= args[4]; 
	} else { 
		windowname=""; 
	}

	if (prams.indexOf('l')!=-1) { loc="location=yes,"; } else { loc="location=no,"; }
	if (prams.indexOf('t')!=-1) { tbar="toolbar=yes,"; } else { tbar="toolbar=no,"; }
	if (prams.indexOf('s')!=-1) { sbars="scrollbars=yes,"; } else { sbars="scrollbars=no,"; }
	if (prams.indexOf('d')!=-1) { directories="directories=yes,"; } else { directories="directories=no,"; }
	if (prams.indexOf('r')!=-1) { resizable="resizable=yes"; } else { resizable="resizable=no"; }

	
	str=loc+tbar+sbars+directories+W+H+resizable;

	newWindow=window.open(url,windowname,str);
	if (newWindow !=null && newWindow.opener==null) { newWindow.opener=window; }

	newWindow.focus();
}



