/*
 *	$Id: lib.CMS.js,v 1.12 2004/02/23 13:07:44 jgauld Exp $
 *	$Name:  $
 *
 *	JavaScript used by the CMS system itself.
 *	Include this in your base templates using:
 *		<script language="JavaScript" src="{$CMS.URL.root}/cms/templates/base/lib.CMS.js"></script>
 */

//-------------------------------
// Global vars
//-------------------------------
//var undefined;

//-------------------------------
// CMS_browser()
// Static Class to help in determining which browser the user has running
//-------------------------------
CMS_browser = function() {
}

CMS_browser.isIE = function(ver) {

	// Vars
	if(ver==undefined) ver = 0;
	var isIE = (navigator.userAgent.indexOf('MSIE')>-1) ? true : false;
	var version = (isIE) ? parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE')+4)) : parseInt(navigator.appVersion);

	// Results
	return (isIE && version>=ver);
}

//-------------------------------
// CMS_popup()
// Create a new popup window
//-------------------------------
function CMS_popup(target, width, height, scroll, resize) {

	// Vars
	resize = (resize==null || resize<1) ? '' : ',resizable';
	scroll = (scroll==null || scroll<1) ? '' : ',scrollbars';

	// Generate coords to place window in centre of screen
	var x = (screen.availWidth - width)/2;
	var y = (screen.availHeight - height)/2;
	var winPos = CMS_browser.isIE() ? 'left='+x+',top='+y : 'screenX='+x+',screenY='+y;

	// Open window
	var w = window.open(target, null, winPos+scroll+resize+',width='+width+',height='+height);
	w.focus();
}