// STYLE HANDLING

// Enable or disable a standard site button.
function enableButton(btn, enabled, classRoot) {
	if (!classRoot) classRoot = 'Button';
	btn.disabled = !enabled;
	btn.className = btn.disabled ? classRoot + '_disabled' : classRoot;
}

// UTILITIES

function displayPopup(url, name, width, height, left, top, extra) {
	// center the window if we're asked for it
	var nLeft;
	var nTop;

	if(browserName == "IE") {
		nLeft = (left == null ? (screen.availWidth - width)/2 : left);
		nTop = (top == null ? (screen.availHeight - height)/2 : top);
	}
	else {
		nLeft = (left == null ? (screen.width - width)/2 : left);
		nTop = (top == null ? (screen.height - height)/2 : top);
	}
	
	var properties =	"height=" + height + ",width=" + width +
	    		        	",left=" + nLeft + ",top=" + nTop + 
	             		(extra ? ',' + extra : '');
	// window.open first navigates to an empty page in order to prevent issues with XSS when 
	// attempting to resize a window containing a link to an external page. The idea here is that
	// we create the window, resize it and move it to the appropriate position, then navigate 
	// to the url that was passed in.
	var winRef = window.open('', name, properties);
	
	if(winRef.location.href == "about:blank") {
		winRef.resizeTo(width, height);
		winRef.moveTo(nLeft, nTop);
		winRef.document.location.href = url;
		
		if (winRef && winRef.open && !winRef.closed) winRef.focus();
	}
	
}

function getRect(obj) {
	var rect = new Object();
	if(obj.x) {
		rect.left = obj.x;
		rect.top = obj.y;
		rect.bottom = obj.y + 14;
		rect.right = obj.x;
	} else {
		rect.top = rect.left = 0;
		var parentObj = obj;
		while (parentObj != null) {
			rect.top  += parentObj.offsetTop;
			rect.left += parentObj.offsetLeft;
			parentObj = parentObj.offsetParent;
		}
		rect.bottom = rect.top  + obj.offsetHeight;
		rect.right  = rect.left + obj.offsetWidth;
	}
	return rect;
}

