//This library uses jquery!
if (typeof SIDesign === "undefined") {
	SIDesign = {};
}

SIDesign.InfoPopUps = function() {
	var popUpMap = {},
		offsetFromNoteParent = 5,
		noteShowTime = 500,
		noteHideTime = 500;
	
	this.addInfoPopUp = function(noteParent, note) {
		popUpMap[noteParent] = {noteParentID: "#" + noteParent, noteID: "#" + note};
		wirePopUp(noteParent);
	};
	
	function wirePopUp(noteParent) {
		var noteParentObj;

		if (popUpMap[noteParent]) {
			noteParentObj = $(popUpMap[noteParent].noteParentID);
			if (noteParentObj) {
				noteParentObj.hover(showNote, hideNote);
			}
		}
	};
	
	function showNote(eventObj) {
		var noteParentObj, noteObj, pos;

		if (popUpMap[this.id]) {
			noteParentObj = $(popUpMap[this.id].noteParentID);
			noteObj = $(popUpMap[this.id].noteID);

			if (noteParentObj && noteObj) {
				pos = noteParentObj.offset();
				noteObj.css({"left": (pos.left + noteParentObj.width() + offsetFromNoteParent) + "px", "top": pos.top + "px"});
				noteObj.show(noteShowTime);
			}
		}
	};
	
	function hideNote(eventObj) {
		var noteObj;
		
		if (popUpMap[this.id]) {
			noteObj = $(popUpMap[this.id].noteID);

			if (noteObj) {
				noteObj.hide(noteHideTime);
			}
		}
	};
};