var totalWindowWidth = 0;
var totalWindowHeight = 0;

//brings up all popup-windows - and check if any other window with same name exists.

var myPopupArray = new Array();

//Depricated 230407
function katjPopup(uri,id,scrollbar) {
	return CMSPopup(uri,id,scrollbar);
}

function CMSPopup(uri,id,scrollbar) {
	if(id==null || myPopupArray[id]==null || myPopupArray[id].closed ) {
		if(scrollbar==null) {
			scrollbar="no";
		}
		widthDim=1;
		heightDim=1;
		topDim=50;
		leftDim=50;
		title='CMS';
		if(id==null) {
			date = new Date();
			title+=date.getMilliseconds();
		} else {
			title+=id;
		}
		resizable='yes';
		var myPopup = window.open(uri,title,"resizable=yes,toolbar=0,scrollbars="+scrollbar+",location=0,statusbar=0,menubar=0,width="+widthDim+",height="+heightDim+",left="+leftDim+",top="+topDim);
		if(id!=null) {
			 myPopupArray[id] = myPopup;
		}
	} else {
		myPopupArray[id].focus();
	}
}

function CMSLogin() {
	CMSPopup( getCMSURI("management/login.php"));
}

function trim(str) {
    return str.replace(/^\s+/, '').replace(/\s+$/, '');
}

function incrementWidth(deltaWidth) {
	if(typeof deltaWidth != 'number') {
		return;
	}
	
	totalWindowWidth+=deltaWidth;
}

function incrementHeight(deltaHeight) {
	if(typeof deltaHeight != 'number') {
		return;
	}
	
	totalWindowHeight+=deltaHeight;
}

function getWindowWidth() {
	return totalWindowWidth;
}

function getWindowHeight() {
	return totalWindowHeight;
}

function resizeWindow() {
	window.resizeTo(getWindowWidth(),getWindowHeight());
}

