// popup.js $Folder$$Date:1/22/02 11:34:52 PM$$Revision$
// Creates a popup browser window
//
// No chrome, Centered over parent browser window
// Returns: 		window object
// Parameters:		name, width and height, resizable, scrollbars
// Compatibility:	any browser with javascript (centering only works on NS4+)
// Requires: 		browser.js

function popup(name,url,width,height,scroll,resize,offset,noreplace) {

	features = ((scroll)?('scrollbars=yes,'):('')) + ((resize)?('resizeable,'):(''));

	//for offsetting second level popups
	offset = ((offset)?(50):(0));


	bReplace = !noreplace;

	// able to center over current browser window
	if (is_nav4up) {
		xpos = window.screenX + (window.innerWidth / 2) - (width / 2 ) + offset;
		ypos = window.screenY + (window.innerHeight / 2) - (height / 2) + offset;
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height + ',screenX=' + xpos + ',screenY=' + ypos, bReplace);
	}
	else
	// centered on screen
	if (is_js >= 1.1) {
		xpos = (screen.width / 2) - (width / 2) + offset;
		ypos = (screen.height / 2) - (height / 2) + offset;
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height + ',left=' + xpos + ',top=' + ypos, bReplace);
	}
	// not able to position
	else {
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height);
	}

	if (hwnd) {
		hwnd.location.href = url;
		hwnd.opener = window.self;
		hwnd.name = name;
		hwnd.focus();
		return hwnd;
	}
	else {
		return null;
	}
}

function popup_toolbar(name,url,width,height,scroll,resize,offset,noreplace) {

	features = ((scroll)?('scrollbars=yes,'):('')) + ((resize)?('resizeable,'):(''));

	//for offsetting second level popups
	offset = ((offset)?(50):(0));


	bReplace = ((noreplace)?(false):(true));

	// able to center over current browser window
	if (is_nav4up) {
		xpos = window.screenX + (window.innerWidth / 2) - (width / 2 ) + offset;
		ypos = window.screenY + (window.innerHeight / 2) - (height / 2) + offset;
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height + ',screenX=' + xpos + ',screenY=' + ypos + ',toolbar', false);
	}
	else
	// centered on screen
	if (is_js >= 1.1) {
		xpos = (screen.width / 2) - (width / 2) + offset;
		ypos = (screen.height / 2) - (height / 2) + offset;
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height + ',left=' + xpos + ',top=' + ypos + ',toolbar', false);
	}
	// not able to position
	else {
		var hwnd = window.open('', name, features + 'width=' + width + ',height=' + height +',toolbar', false);
	}

	if (hwnd) {
		hwnd.location.href = url;
		hwnd.opener = window.self;
		hwnd.name = name;
		return hwnd;
	}
	else {
		return null;
	}
}

// end of popup.js
