var hideWikiPopup = false;

function wikiPopup(wikiid, e) {
	setZIndexes(e);
	if(hideWikiPopup) {
		hideWikiPopup = false;
		return;
	}

	// Position bubble to not to hang out from the screen
	var offset = $(e).offset();
	var bodyWidth = $('body').width();
	if(bodyWidth / 2 < offset.left) {
		$(e).addClass('wikibubble-right');
	} else {
		$(e).removeClass('wikibubble-right');
	}

	$('.wikibubble').hide();
	$(e).blur().css('position', 'relative');
	var wikipopup = $('#wikipopup-' + wikiid);
	var bubble = $('.wikibubble', e);
	if(!bubble.length) {
		$(e).append(wikipopup.html());
		bubble = $('.wikibubble', e);
	}
	bubble.show();
	if($.browser.msie) {
		bubble.css('top', 3 - bubble.height() + 'px').css('bottom', 'auto');
	}
}

function wikiClose(e) {
	$(e).parent().parent().hide();
	hideWikiPopup = true;
}

function resizeToSameHeight(selector1, selector2) {
	var height1 = $(selector1).height();
	var height2 = $(selector2).height();
	if(height1 < height2) {
		$(selector1).height(height2);
		$(selector2).height(height2);
	} else {
		$(selector1).height(height1);
		$(selector2).height(height1);
	}
}
