var windowsHOffset=24;
var windowsWOffset=10;
function popup (url, name, width, height, left, top) {
	if(width>(screen.availWidth-windowsWOffset) || height>(screen.availHeight-windowsHOffset)) {
		return(popupWithScroll(url,name,width,height,left,top));
	}
	return (popup_WindowOpen(url, name, width, height, left, top, 'no', 'no', 'yes'));
}  

function popup_WindowOpen (url, name, width, height, left, top, scrollbars, menubar, resizable) {
	if(width>(screen.availWidth-windowsWOffset)){
		width=screen.availWidth-windowsWOffset;
	}
	if(height>(screen.availHeight-windowsHOffset)){
		height=screen.availHeight-windowsHOffset;
	}
	var popupWin = window.open(url, name, 
'personalbar=no,toolbar=no,status=no,scrollbars=' + scrollbars + ',location=no,resizable=' + resizable + ',menubar=' + menubar + 
',width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if(window.focus) {
		popupWin.focus();
	} 
	return(popupWin);
}  

function popupWithScroll (url, name, width, height, left, top) {
	
	return (popup_WindowOpen(url, name, width, height, left, top, 'yes', 'no', 'yes'));
}

function popupWithScrollAndMenu (url, name, width, height, left, top) {
	
	return (popup_WindowOpen(url, name, width, height, left, top, 'yes', 'yes', 'yes'));
}

function popupWithScrollNoresize (url, name, width, height, left, top) {
	return (popup_WindowOpen(url, name, width, height, left, top, 'yes', 'no', 'no'));

}
