function openWindow(url, width, height) {

    var newWidth = width + 50;
    var newHeight = height + 50;

    var leftPos = window.screenLeft + (window.document.body.clientWidth - newWidth) / 2;
    var topPos = window.screenTop + (window.document.body.clientHeight - newHeight) / 2;

    var newWindow = window.open(url, 'popup_window', 'toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=yes,width=' + newWidth + ',height=' + newHeight + ',left=' + leftPos + ',top=' + topPos);
    newWindow.focus();

}

function confirm_delete(itemName)
{
	if (confirm('Are you sure you want to delete this ' + itemName + '?'))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function getElementsByClass(searchClass, node, tag) {
	var classElements = new Array();
	if (node == null) {
		node = document;
	}
	if (tag == null) {
		tag = '*';
	}
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var  pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if (pattern.test(els[i].className)) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		EventCache.add(elm, evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}
