function el(id)
{
  return document.getElementById(id);
}

function contentUtilClass()
{
	function openImagePopup(elA, imageSize)
	{
		var maxImageSize = [770, 550];
		var margins = [120, 90];

		var imageSize = (imageSize ? imageSize : maxImageSize);
		var size = [
			Math.min(imageSize[0] + margins[0], screen.availWidth - 10),
			Math.min(imageSize[1] + margins[1], screen.availHeight - 32)];
		var origin = [
			Math.max((screen.availWidth - size[0]) / 2, 0),
			Math.max((screen.availHeight - size[1]) / 2, 0)];

		var params = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,fullscreen=no';
		params += ',left=' + origin[0] + ',top=' + origin[1] + ',width=' + size[0] + ',height=' + size[1] + '';

		// alert(params);

		var popup = window.open(elA.href, elA.target, params);
		// if (popup.focus)
		//   popup.focus();

		return false;
	}
	this.openImagePopup = openImagePopup;

	function openKeywordTooltip(elKeyword, e)
	{
		var keywordId = elKeyword.id;

		keywordId = this.mapIdToKeyword[keywordId];

		if (!this.thesaurusDocument)
		  return;
		var elTitle = this.thesaurusDocument.getElementById(keywordId + '_title');
		var elBody = this.thesaurusDocument.getElementById(keywordId + '_tooltip');
		if (!elTitle || !elBody)
		  return;

		var markup = "";
		markup += '<div class="title">' + elTitle.innerHTML + '</div>';
		markup += '<div class="body">' + elBody.innerHTML + '</div>';

		tooltip.maxWidth = 300;
		tooltip.showDelayed(e, markup);
		// alert(tooltip.show);
	}
	this.openKeywordTooltip = openKeywordTooltip;

	function linkKeywords(mapIdToKeyword, urlPrefix)
	{
    // Markup thesaurus IFRAME
    document.write('<iframe id="frame_thesaurus" src="' + (urlPrefix ? urlPrefix : "") + 'thesaurus.html" style="width:0px; height:0px" frameborder="0"></iframe>');

		for (var id in mapIdToKeyword) {
	    this.mapIdToKeyword[id] = mapIdToKeyword[id];
	    var el = document.getElementById(id);
			el.onclick = function() {return false;};
			el.onmouseover = function(e) {contentUtil.openKeywordTooltip(this, (e ? e : event)); return false;};
		}
	}
	this.linkKeywords = linkKeywords;

	this.mapIdToKeyword = {};
	this.thesaurusDocument = null;
}

contentUtil = new contentUtilClass();
