﻿<!-- 
function changePosition() {
		var position = $("#tooltip").position();
		var stageWidth = $(window).width();
		var totalWidth = 295 + position.left;
		if(totalWidth > stageWidth) {
			
			var newLeft = totalWidth - stageWidth;
			
			newLeft = position.left - newLeft;
			newLeft = newLeft - 40;
			newLeft = newLeft + "px";
			$("#tooltip").css({"left":newLeft});
		}
	}
$(document).ready(function() {
	// add tooltip element
	$("body").append("<div id='tooltip'><p>&nbsp;</p></div>");
	
	// activate tooltip function
	$("a.gloss_begrip[title]").tooltip({ 
        tip: '#tooltip',
		position: 'bottom center',
		offset: [3, 40],
		delay: '500',
		predelay: '400',
		onShow: function() { 
			var thisItem = this.getTrigger();
			var thisHref = this.getTrigger().attr("href");
			var thisName = this.getTrigger().html();
			$("#tooltip").prepend("<h4>"+ thisName +"</h4>");
			
			if(thisHref != '#')
			{
			    $("#tooltip").append("<p><a href='"+thisHref+"'>Lees verder...</a></p>");
			}
			
			// if the tooltip is bigger than the screen, position it back
			changePosition();
		} 
	}); 
	$(".gloss_begrip").click(function(){
		return false;
	});
});
//-->

