// newWindow.js - Version 1.0
// open new window
// Copyright 2003. Lakonik Studios. All rights reserved.


// To use the function newWindow, you have to use a link like this:
//     <a href="javascript:newWindow('/folder/folder/name.htm');"> 
// with the right URL instead of /folder/folder/name.htm
//
// To change the name of the window and the attributes of the window,
// you can also add those to the link, for instance:
//     <a href="javascript:newWindow('/popup/glossary.htm', 'glossary', '160', \
//        '250', 'no', 'no', 'no', 'no', 'no', 'yes', 'yes', '10', '620');">
//
// Attribute documentation:
//     a = width       [ number in pixels ]
//     b = height      [ number in pixels ]
//     c = menubar     [ yes | no | 1 | 0 | true | false ]
//     d = toolbar     [ yes | no | 1 | 0 | true | false ]
//     e = location    [ yes | no | 1 | 0 | true | false ]
//     f = directories [ yes | no | 1 | 0 | true | false ]
//     g = status      [ yes | no | 1 | 0 | true | false ]
//     h = scrollbars  [ yes | no | 1 | 0 | true | false ]
//     i = resizable   [ yes | no | 1 | 0 | true | false ]
//     j = top         [ number ]
//     k = left        [ number ]
//     l = centered    [ yes | no ]

function newWindow(URL, nameWindow, a, b, c, d, e, f, g, h, i, j, k, l) {

	// set our defaults
	if (typeof URL == 'undefined') URL = "/lib/js/blank.html";
	if (typeof nameWindow == 'undefined') nameWindow = "newWindow";
	if (typeof a == 'undefined') a = "250";
	if (typeof b == 'undefined') b = "250";
	if (typeof c == 'undefined') c = "no";
	if (typeof d == 'undefined') d = "no";
	if (typeof e == 'undefined') e = "no";
	if (typeof f == 'undefined') f = "no";
	if (typeof g == 'undefined') g = "no";
	if (typeof h == 'undefined') h = "yes";
	if (typeof i == 'undefined') i = "yes";
	if (typeof j == 'undefined') j = "10";
	if (typeof k == 'undefined') k = "530";
	if (typeof l == 'undefined') l = "no";
	
	if (l == "no") {
		// window is opened on the right side of the page
		// postition is depending on the monitor resolution, but window should never start beyond 770px to the right. and never to the left of 0px
		
		var a = parseInt (a);
		k = (window.screen.availWidth - a - 20);
		k > 770 ? k = 770 : k = 0;
	} else {
		// window is opened in the center of the page
		var a = parseInt (a);
		var b = parseInt (b);
		y = window.screen.availWidth;
		z = window.screen.availHeight;
		if (a >= y) k = 0;
		if (b >= z) j = 0;
		if (a < y ) k = ((y/2)-(a/2));
		if (b < z ) j = ((z/2)-(b/2));
	}

	var attributes = 'width=' + a +
	                 ',height=' + b +
	                 ',menubar=' + c +
	                 ',toolbar=' + d +
	                 ',location=' + e +
	                 ',directories=' + f +
	                 ',status=' + g +
	                 ',scrollbars=' + h +
	                 ',resizable=' + i +
	                 ',top=' + j +
	                 ',left=' + k;

	window.open(URL, nameWindow, attributes);
}