/*
//
// APUS JS package, last modified $Date: 2005/11/25 14:26:03 $ by $Author: stamina $
//
// This script contains the logic for creating popup windows.
//
*/

// default values
// var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=600,height=300,scrollbars=1,resizable';
var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=100,height=100,scrollbars=1,resizable';

/*
// 	Function:		raw_popup
// 	Arguments:		-
// 	Description:	This function will be used by the
//					link_popup function. It's a nice wrapper
//					around the standard window.open functionality.
//	Returns:		-
// 	Historie
// 	Who			When		What
// 	BasB		24/03/2004	Creation
*/

function raw_popup(aUrl,iWidth,iHeight,aTarget,aFeatures) {
	if (isUndefined(aFeatures)) {
		aFeatures = _POPUP_FEATURES;
	}
	if (isUndefined(aTarget)) {
		aTarget = '_blank';
	}
	var theWindow = window.open(aUrl, aTarget, aFeatures);	
	theWindow.focus(); // nicely focus windows left behind
	
	// Adjust the width and height for NN and IE
	/*if (navigator.appName=="Netscape") {
		iWidth += 22;
		iHeight += 42;
	} else {
		iWidth += 52;
		iHeight += 85;
	}*/
	
	iWidth += 52;
	iHeight += 75;
	
	theWindow.resizeTo(iWidth, iHeight);
	return theWindow;
}

/*
// 	Function:		link_popup
// 	Arguments:		-
// 	Description:	This function gets fired from direct
//					<a> onclick handlers
//	Returns:		-
// 	Historie
// 	Who		When		What
// 	BasB	24/03/2004	Creation
*/

function link_popup(aSrc,iWidth,iHeight,aFeatures) {
	return raw_popup(aSrc.getAttribute('href'),iWidth,iHeight,aSrc.getAttribute('target') || '_blank',aFeatures);
}

// helper func
function isUndefined(v) {
    var undef;
    return v===undef;
}
