// names of div classes
var UPPER_LEFT = "idm-upperLeft";
var UPPER_RIGHT = "idm-upperRight";
var LOWER_LEFT = "idm-lowerLeft";
var LOWER_RIGHT = "idm-lowerRight";
var BUBBLE_CLASS = "idm-helpBubble";

// orientations
var ORIENT_LEFT = "left";
var ORIENT_RIGHT = "right";
var ORIENT_TOP = "top";
var ORIENT_BOTTOM  = "bottom";

// preferred widths of the bubbles in px
var SMALL_BUBBLE_WIDTH = 277;
var MEDIUM_BUBBLE_WIDTH = 300;
var LARGE_BUBBLE_WIDTH = 320;

// several position hacks

// upper left bubble
var UPPERLEFT = new Array();
UPPERLEFT['BUBBLEMIDDLE_DIFF'] = 13;
UPPERLEFT['TEXT_VERT_OFFSET_DIFF'] = 25; 	// postion text within bubble
UPPERLEFT['TEXT_MARGIN_TOP'] = 10; 			// upper margin
UPPERLEFT['TEXT_MARGIN_BOTTOM'] = 0; 		// lower margin
UPPERLEFT['BUBBLE_MARGIN_TOP'] = 0;
UPPERLEFT['BUBBLE_MARGIN_LEFT'] = 0; 		// distance to anchor
// upper right bubble
var UPPERRIGHT = new Array();
UPPERRIGHT['BUBBLEMIDDLE_DIFF'] = 13;
UPPERRIGHT['TEXT_VERT_OFFSET_DIFF'] = 45; 	// postion text within bubble
UPPERRIGHT['TEXT_MARGIN_TOP'] = 10; 		// upper margin
UPPERRIGHT['TEXT_MARGIN_BOTTOM'] = 0; 		// lower margin
UPPERRIGHT['BUBBLE_MARGIN_TOP'] = 0;
UPPERRIGHT['BUBBLE_MARGIN_LEFT'] = 0;
// bottom left bubble
var LOWERLEFT = new Array();
LOWERLEFT['BUBBLEMIDDLE_DIFF'] = 13;
LOWERLEFT['TEXT_VERT_OFFSET_DIFF'] = 25; 	// postion text within bubble
LOWERLEFT['TEXT_MARGIN_TOP'] = 10; 			// upper margin
LOWERLEFT['TEXT_MARGIN_BOTTOM'] = 0; 		// lower margin
LOWERLEFT['BUBBLE_MARGIN_TOP'] = 30;
LOWERLEFT['BUBBLE_MARGIN_LEFT'] = 0; 		// distance to anchor
// lower right bubble
var LOWERRIGHT = new Array();
LOWERRIGHT['BUBBLEMIDDLE_DIFF'] = 13;
LOWERRIGHT['TEXT_VERT_OFFSET_DIFF'] = 45; 	// postion text within bubble
LOWERRIGHT['TEXT_MARGIN_TOP'] = 10; 		// upper margin
LOWERRIGHT['TEXT_MARGIN_BOTTOM'] = 0; 		// lower margin
LOWERRIGHT['BUBBLE_MARGIN_TOP'] = 30;
LOWERRIGHT['BUBBLE_MARGIN_LEFT'] = 0;
// general bubble: DO NOT CHANGE!!!
var GENERALBUBBLE = new Array();
GENERALBUBBLE['BUBBLEMIDDLE_DIFF'] = 0;
GENERALBUBBLE['TEXT_VERT_OFFSET_DIFF'] = 0; // postion text within bubble
GENERALBUBBLE['TEXT_MARGIN_TOP'] = 0; 		// upper margin
GENERALBUBBLE['TEXT_MARGIN_BOTTOM'] = 0; 	// lower margin
GENERALBUBBLE['BUBBLE_MARGIN_TOP'] = 0;
GENERALBUBBLE['BUBBLE_MARGIN_LEFT'] = 0;

var DEBUG = true; // verbose?
//var helpBubbles = new Array();



var helpBubble = {

	helpTextId : "",
	helpTextAnchorDiv : "",
	helpTextAnchorDivWidth : "",
	helpTextAnchorDivHeight : "",
	helpTextAnchorDivXOffset : "",
	helpTextAnchorDivYOffset : "",

	helpTextContainerDiv : "",
	helpTextContainerDivWidth : "",
	helpTextContainerDivHeight : "",
	helpTextContainerDivClasses : "",
	helpTextTextDiv : "",
	helpTextMessageDiv : "",
	helpTextResponse : "",
	textWidth : 0,
	textHeight : 0,
	viewport : 0,
	scrollPosition : 0,
	verticalOrientation : "",
	horizontalOrientation : "",
	flipped : false,
	browser : "",
	messageKey : "",


	initialize: function(helpTextId, preferredPosition, messageKey, dontHideOtherElements) {
		this.resetAllValues();
		this.helpTextId = helpTextId;
		this.helpTextAnchorDiv = "idm-" + helpTextId + "-anchor";
		this.helpTextContainerDiv = "idm-" + helpTextId + "-container";
		this.helpTextTextDiv = "idm-" + helpTextId + "-text";
		this.helpTextMessageDiv = "idm-" + helpTextId + "-message";

		this.messageKey = messageKey;

		this.viewPort = this.getViewportDimension();
		this.scrollPosition = this.getScrollPosition();

		if ($(this.helpTextContainerDiv)){
			if ($(this.helpTextContainerDiv).style.visibility == "visible") {
				newViz = "hidden";
			} else {
				newViz = "visible";
			}
			helpBubble.switchOffAllBubbles("inside obj - toggling viz");
			$(this.helpTextContainerDiv).style.visibility = newViz;
		} else {
			helpBubble.switchOffAllBubbles();
			var containerHtml = "<div id='" + this.helpTextContainerDiv
								+ "' style='visibility:hidden; position:absolute;' class='idm-helpBubble "
								+ preferredPosition + "' onClick='helpBubble.switchOffAllBubbles();'></div>";

			new Insertion.After(this.helpTextAnchorDiv, containerHtml);//$$("body")[0] doesnt work in ie!

			this.helpTextResponse = $(this.helpTextMessageDiv).innerHTML;
			this.renderBubble();
		}

		// IE only: Show/Hide <select>'s if they're within bubble space
		this.selectboxes = $$("select");
		this.isIE = (getUserAgentName() == "msie" && getUserAgentVersion().indexOf("6") != -1) ? true : false;

		if (this.isIE && dontHideOtherElements != "true") {
			if ($(this.helpTextContainerDiv).style.visibility == "visible") {
				this.selectboxes.each(function(element) {
					var offset = Position.cumulativeOffset(element);
					//if (Element.visible(element) && Position.within($(this.helpTextContainerDiv), offset[0]+40, offset[1]+5))
						Element.hide(element)
				}.bind(this));
			} else {
				this.selectboxes.each(function(element) {
					Element.show(element)
				}.bind(this));
			}
		}
	},

	renderBubble: function() {

		// reset positioning values just in case
		$(this.helpTextContainerDiv).style.top = 0;
		$(this.helpTextContainerDiv).style.left = 0;

		// put together bubble
		var bubbleHtml = "<div class='idm-bubbleContainer'> \n" +
			"<div id='idm-" + this.helpTextId + "-upperLeft' class='idm-upperLeft'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-upperCenter' class='idm-upperCenter'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-upperRight' class='idm-upperRight'></div> \n" +
			" \n" +
			"<div id='idm-" + this.helpTextId + "-centerLeft' class='idm-centerLeft'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-centerCenter' class='idm-centerCenter'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-centerRight' class='idm-centerRight'></div> \n" +
			" \n" +
			"<div id='idm-" + this.helpTextId + "-lowerLeft' class='idm-lowerLeft'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-lowerCenter' class='idm-lowerCenter'></div> \n" +
			"<div id='idm-" + this.helpTextId + "-lowerRight' class='idm-lowerRight'></div> \n" +
		"</div> \n" +
		"<div id='" + this.helpTextTextDiv + "' class='idm-helpText' style='overflow:auto'>" + this.helpTextResponse + "</div>";

		$(this.helpTextContainerDiv).innerHTML = bubbleHtml;
		$(this.helpTextContainerDiv).style.visibility = "visible";
		this.helpTextContainerDivClasses = $(this.helpTextContainerDiv).className;

		// check text size
		this.calculatePreferredTextDimensions();

		// readjust bubble size
		this.setBubbleDimensions();

		// get anchor position
		this.getAnchorDimensions();

		// calculate bubble position
		this.positionBubble();

		// check if bubble is visible
		// if not, try different position
		if(this.flipped == false) {
			this.checkBubblePosition();
		}
		//helpBubbles[this.helpTextId]=this;
	},

	checkBubblePosition : function() {
		var bubbleDimensions = new Array();
		bubbleDimensions['bubbleTop']    = Position.page($(this.helpTextContainerDiv))[1];
		bubbleDimensions['bubbleBottom'] = bubbleDimensions['bubbleTop'] + $(this.helpTextContainerDiv).offsetHeight;
		bubbleDimensions['bubbleLeft']   = Position.page($(this.helpTextContainerDiv))[0];
		bubbleDimensions['bubbleRight']  = bubbleDimensions['bubbleLeft'] + $(this.helpTextContainerDiv).offsetWidth;

		var viewportDimensions = new Array();
		viewportDimensions['leftMargin']  = this.scrollPosition[0];
		viewportDimensions['rightMargin'] = this.scrollPosition[0] + this.viewPort[0];
		viewportDimensions['upperMargin'] = this.scrollPosition[1];
		viewportDimensions['lowerMargin'] = this.scrollPosition[1];

		// too far left??
		if(bubbleDimensions['bubbleLeft'] < viewportDimensions['leftMargin']) {
			flipToLeft = this.tryBubbleFlip(bubbleDimensions, viewportDimensions, ORIENT_LEFT);
			if(flipToLeft) {
				// flip to the right
				this.flipBubble(ORIENT_LEFT);
			}
		} else if(bubbleDimensions['bubbleRight'] > viewportDimensions['rightMargin']) {
			// too far right??
			var flipToRight = this.tryBubbleFlip(bubbleDimensions, viewportDimensions, ORIENT_RIGHT);
			if(flipToRight) {
				// flip to the left
				this.flipBubble(ORIENT_RIGHT);
			}
		} else if(bubbleDimensions['bubbleTop'] < 0) {
			// too far up??
			flipToBottom = this.tryBubbleFlip(bubbleDimensions, viewportDimensions, ORIENT_TOP);
			if(flipToBottom) {
				// flip to the bottom
				this.flipBubble(ORIENT_TOP);
			}
		} else if(bubbleDimensions['bubbleBottom'] < viewportDimensions['bottomMargin']) {
			// too far down??
			flipToTop = this.tryBubbleFlip(bubbleDimensions, viewportDimensions, ORIENT_BOTTOM);
			if(flipToTop) {
				// flip to the top
				this.flipBubble(ORIENT_BOTTOM);
			}
		}
	},

	flipBubble : function(newOrientation) {
		$(this.helpTextContainerDiv).innerHTML = "";

		if(newOrientation == ORIENT_RIGHT) {
			this.horizontalOrientation = ORIENT_RIGHT;
		}
		if(newOrientation == ORIENT_LEFT) {
			this.horizontalOrientation = ORIENT_LEFT;
		}
		if(newOrientation == ORIENT_TOP) {
			this.verticalOrientation = ORIENT_TOP;
		}
		if(newOrientation == ORIENT_BOTTOM) {
			this.verticalOrientation = ORIENT_BOTTOM;
		}

		if(this.horizontalOrientation == ORIENT_RIGHT && this.verticalOrientation == ORIENT_TOP) {
			$(this.helpTextContainerDiv).className = BUBBLE_CLASS + " " + UPPER_RIGHT;
		}
		if(this.horizontalOrientation == ORIENT_LEFT && this.verticalOrientation == ORIENT_TOP) {
			$(this.helpTextContainerDiv).className = BUBBLE_CLASS + " " + UPPER_LEFT;
		}
		if(this.horizontalOrientation == ORIENT_RIGHT && this.verticalOrientation == ORIENT_BOTTOM) {
			$(this.helpTextContainerDiv).className = BUBBLE_CLASS + " " + LOWER_RIGHT;
		}
		if(this.horizontalOrientation == ORIENT_LEFT && this.verticalOrientation == ORIENT_BOTTOM) {
			$(this.helpTextContainerDiv).className = BUBBLE_CLASS + " " + LOWER_LEFT;
		}

		this.flipped = true;
		this.renderBubble();
	},

	tryBubbleFlip : function(bubbleDimensionArray, viewportPropertiesArray, newOrientation) {
		var flippingOkay = false;
		var newBubbleDimension = Array();
		newBubbleDimension['bubbleLeft'] = 0;
		newBubbleDimension['bubbleRight'] = 0;
		newBubbleDimension['bubbleTop'] = 0;
		newBubbleDimension['bubbleBottom'] = 0;

		if(newOrientation == ORIENT_LEFT) {
			// flip to left:
			newBubbleDimension['bubbleLeft'] = this.helpTextAnchorDivXOffset
				+ this.helpTextAnchorDivWidth
				+ GENERALBUBBLE['BUBBLE_MARGIN_LEFT']
				+ this.scrollPosition[0];

			if(newBubbleDimension['bubbleLeft'] > viewportPropertiesArray['leftMargin']){
				flippingOkay = true;
			}
		} else if(newOrientation == ORIENT_RIGHT) {
			newBubbleDimension['bubbleRight'] = this.helpTextAnchorDivXOffset
				+ this.helpTextAnchorDivWidth
				+ GENERALBUBBLE['BUBBLE_MARGIN_LEFT'];
			if(newBubbleDimension['bubbleRight'] < viewportPropertiesArray['rightMargin']) {
				flippingOkay = true;
			}
		} else if(newOrientation == ORIENT_BOTTOM) {

		} else if(newOrientation == ORIENT_TOP) {
			// flipping to top
			newBubbleDimension['bubbleTop'] = this.helpTextAnchorDivYOffset + GENERALBUBBLE['BUBBLE_MARGIN_TOP'];
			if(newBubbleDimension['bubbleTop'] > 0) {
				flippingOkay = true;
			}
		}
		return flippingOkay;
	},

	getScrollPosition : function() {
		var x,y;
		if (self.pageYOffset) {
			// all except Explorer
			x = self.pageXOffset;
			y = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			// Explorer 6 Strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		} else if (document.body) {
			// all other Explorers
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		return [x, y];
	},

	getViewportDimension : function() {
		var x,y;
		if (self.innerHeight) {
			// all except Explorer
			this.browser = "non_ie";
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) {
			// other Explorers
			this.browser = "ie";
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		return [x, y];
	},

	switchOffAllBubbles : function(msg) {
		var allBubbles = $$(".idm-helpBubble");
		for(var i=0; i<allBubbles.length; i++){
			$(allBubbles[i].id).style.visibility = "hidden";
		}
		//show all <select>'s if clicked outside bubble
		this._selectboxes = $$("select");
		this._selectboxes.each(function(element) {
			Element.show(element)
		}.bind(this));
	},

	resetAllValues: function () {
		this.helpTextId = "";
		this.helpTextAnchorDiv = "";
		this.helpTextAnchorDivWidth = "";
		this.helpTextAnchorDivHeight = "";
		this.helpTextAnchorDivXOffset = "";
		this.helpTextAnchorDivYOffset = "";

		this.helpTextContainerDiv = "",
		this.helpTextContainerDivWidth = "";
		this.helpTextContainerDivHeight = "";
		this.helpTextContainerDivClasses = "";
		this.helpTextTextDiv = "";
		this.helpTextResponse = "";
		this.textWidth = 0;
		this.textHeight = 0;
		this.viewport = 0;
		this.scrollPosition = 0;
		this.flipped = false;
	},

	positionBubble : function () {

		// Init bubble container or else you'll have fun with Firefox ...
		$$("body").first().appendChild($(this.helpTextContainerDiv));

		var prevTop = Position.page($(this.helpTextContainerDiv))[1];
		var prevLeft = Position.page($(this.helpTextContainerDiv))[0];

		// Exceptions for event calendar
		this.isIE = (getUserAgentName() == "msie" && getUserAgentVersion().indexOf("6") != -1) ? true : false;

		var extra_leftmargin = 0;
		var extra_rightmargin = 0;
		var extra_uppermargin = 0;
		var ff_extra_upper = 0;
		var ie_extra_upper = 0;
		if(!this.isIE) {
			// add some pixels for Firefox
			var ff_extra_upper = 10;
		}

		// is it a left bubble??
		if(this.helpTextContainerDivClasses.indexOf(UPPER_LEFT) != -1 || this.helpTextContainerDivClasses.indexOf(LOWER_LEFT) != -1) {
			var bubbleLeft = this.helpTextAnchorDivXOffset
						   + this.helpTextAnchorDivWidth
						   + GENERALBUBBLE['BUBBLE_MARGIN_LEFT'];
		} else {
			var bubbleLeft = this.helpTextAnchorDivXOffset
						   - $(this.helpTextContainerDiv).offsetWidth
						   + GENERALBUBBLE['BUBBLE_MARGIN_LEFT'];
		}

		// is it a lower bubble??
		if(this.helpTextContainerDivClasses.indexOf(LOWER_RIGHT) != -1 || this.helpTextContainerDivClasses.indexOf(LOWER_LEFT) != -1) {
			var bubbleTop = this.helpTextAnchorDivYOffset
				- $(this.helpTextContainerDiv).offsetHeight
				+ GENERALBUBBLE['BUBBLE_MARGIN_TOP']
				+ extra_uppermargin;
		} else {
			var bubbleTop = this.helpTextAnchorDivYOffset + GENERALBUBBLE['BUBBLE_MARGIN_TOP'];
		}
		$(this.helpTextContainerDiv).style.top = (bubbleTop - prevTop) + 'px';
		$(this.helpTextContainerDiv).style.left = (bubbleLeft - prevLeft) + 'px';
	},

	getAnchorDimensions : function() {
		this.helpTextAnchorDivHeight = $(this.helpTextAnchorDiv).offsetHeight;
		this.helpTextAnchorDivWidth = $(this.helpTextAnchorDiv).offsetWidth;

		this.helpTextAnchorDivXOffset = Position.page($(this.helpTextAnchorDiv))[0];
		this.helpTextAnchorDivYOffset = Position.page($(this.helpTextAnchorDiv))[1];
	},


	setBubbleDimensions: function() {

		this.getOrientationalValues();

		// set text width
		var middleWidth = this.textWidth + GENERALBUBBLE['BUBBLEMIDDLE_DIFF'];
		$('idm-' + this.helpTextId + '-upperCenter').style.width     = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-centerCenter').style.width    = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-lowerCenter').style.width     = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-upperCenter').style.maxWidth  = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-centerCenter').style.maxWidth = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-lowerCenter').style.maxWidth  = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-upperCenter').style.minWidth  = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-centerCenter').style.minWidth = this.addPx(middleWidth);
		$('idm-' + this.helpTextId + '-lowerCenter').style.minWidth  = this.addPx(middleWidth);

		// set text height
		var middleHeight = this.textHeight + GENERALBUBBLE['TEXT_MARGIN_BOTTOM'];
		$('idm-' + this.helpTextId + '-centerLeft').style.height      = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerCenter').style.height    = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerRight').style.height     = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerLeft').style.maxHeight   = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerCenter').style.maxHeight = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerRight').style.maxHeight  = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerLeft').style.minHeight   = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerCenter').style.minHeight = this.addPx(middleHeight);
		$('idm-' + this.helpTextId + '-centerRight').style.minHeight  = this.addPx(middleHeight);

		// set bubble width
		this.helpTextContainerDivWidth = $('idm-' + this.helpTextId + '-upperLeft').offsetWidth
									   + $('idm-' + this.helpTextId + '-upperCenter').offsetWidth
									   + $('idm-' + this.helpTextId + '-upperRight').offsetWidth;
		$(this.helpTextContainerDiv).style.width    = this.addPx(this.helpTextContainerDivWidth);
		$(this.helpTextContainerDiv).style.maxWidth = this.addPx(this.helpTextContainerDivWidth);
		$(this.helpTextContainerDiv).style.minWidth = this.addPx(this.helpTextContainerDivWidth);

		// set bubble height
		this.helpTextContainerDivHeight = $('idm-' + this.helpTextId + '-upperLeft').offsetHeight
										+ $('idm-' + this.helpTextId + '-centerLeft').offsetHeight
										+ $('idm-' + this.helpTextId + '-lowerLeft').offsetHeight;
		$(this.helpTextContainerDiv).style.height    = this.addPx(this.helpTextContainerDivHeight);
		$(this.helpTextContainerDiv).style.maxHeight = this.addPx(this.helpTextContainerDivHeight);
		$(this.helpTextContainerDiv).style.minHeight = this.addPx(this.helpTextContainerDivHeight);

		// position text over bubble
		var textTextVertMargin = this.textWidth + GENERALBUBBLE['TEXT_VERT_OFFSET_DIFF'];
		$(this.helpTextTextDiv).style.margin = GENERALBUBBLE['TEXT_MARGIN_TOP'] + "px 0 "
											 + GENERALBUBBLE['TEXT_MARGIN_BOTTOM'] + "px -"
											 + textTextVertMargin + "px";
	},

	getOrientationalValues : function() {
		if(this.helpTextContainerDivClasses.indexOf(UPPER_LEFT) != -1) {
			GENERALBUBBLE = UPPERLEFT;
			this.verticalOrientation = ORIENT_TOP;
			this.horizontalOrientation = ORIENT_LEFT;
		} else if(this.helpTextContainerDivClasses.indexOf(UPPER_RIGHT) != -1) {
			GENERALBUBBLE = UPPERRIGHT;
			this.verticalOrientation = ORIENT_TOP;
			this.horizontalOrientation = ORIENT_RIGHT;

		} else if(this.helpTextContainerDivClasses.indexOf(LOWER_LEFT) != -1) {
			GENERALBUBBLE = LOWERLEFT;
			this.verticalOrientation = ORIENT_BOTTOM;
			this.horizontalOrientation = ORIENT_LEFT;
		} else if(this.helpTextContainerDivClasses.indexOf(LOWER_RIGHT) != -1) {
			GENERALBUBBLE = LOWERRIGHT;
			this.verticalOrientation = ORIENT_BOTTOM;
			this.horizontalOrientation = ORIENT_RIGHT;
		}
	},

	// selects the smallest possible width where
	// the length / width relation is smaller than the golden ratio
	calculatePreferredTextDimensions : function() {
		// small???
		$(this.helpTextTextDiv).style.width = this.addPx(SMALL_BUBBLE_WIDTH);
		var tempTextHeight = $(this.helpTextTextDiv).offsetHeight;
		var tempTextMean   = SMALL_BUBBLE_WIDTH / 1.62; // golden ratio
		if((tempTextHeight + GENERALBUBBLE['TEXT_MARGIN_TOP']) > tempTextMean) {
			// medium???
			//alert( $(this.helpTextTextDiv).style.width );
			$(this.helpTextTextDiv).style.width = this.addPx(MEDIUM_BUBBLE_WIDTH);
			var tempTextHeight = $(this.helpTextTextDiv).offsetHeight;
			var tempTextMean   = MEDIUM_BUBBLE_WIDTH / 1.62; // golden ratio
			if((tempTextHeight + GENERALBUBBLE['TEXT_MARGIN_TOP']) > tempTextMean) {
				// large???
				$(this.helpTextTextDiv).style.width = this.addPx(LARGE_BUBBLE_WIDTH);
				var tempTextHeight = $(this.helpTextTextDiv).offsetHeight;
				this.textWidth = LARGE_BUBBLE_WIDTH;
				this.textHeight = tempTextHeight;
			} else {
				this.textWidth = MEDIUM_BUBBLE_WIDTH;
				this.textHeight = tempTextHeight;
			}
		} else {
			this.textWidth = SMALL_BUBBLE_WIDTH;
			this.textHeight = tempTextHeight;
		}
	},


	addPx: function(s){
		return s+ "px";
	}
};
