jQuery(document).ready(function($){
	$.each($('.profil-reference'), function (index, el) {
		if ($(el).children('a').length == 0) {
			$(el).hide();
		}
	});

	var idNum = 1;
	var bodyEl = $('body');
	$.each($('span.tip'), function (index, el) {
		var el = $(el);

		if (el.attr('title') != '') {
			var text = el.attr('title');
			var id	 = el.attr('id');

			if( !id || id == '' ) {
				id = 'tooltip-id-'+(idNum++);
				el.attr('id', id);
			}
/*
			el.removeAttr('title');
			el.append('<div class="tooltip" style="display: none; position: absolute; padding: 5px; border: 1px black solid; background-color: white; margin-left: 20px; margin-top: 25px; z-index: 5;">' + text + '<span class="tooltip-fade"></span>"</div>');
			el.hover(
				function () {
					$(this).find('div.tooltip').show();
				},
				function () {
					$(this).find('div.tooltip').hide();
				}
			);
*/
			el.removeAttr('title');
			bodyEl.append('<div id="'+id+'-tip" class="tooltip" style="text-align: left;display: none; position: absolute; padding: 5px; border: 1px black solid; background-color: white; z-index: 999;">' + text + '<span class="tooltip-fade"></span>"</div>');

			el.hover(
				function (e) {
					var element = $(this);
					var tipEl = $('#'+id+'-tip');
					tipEl.css('top', e.pageY+25 );
					tipEl.css('left', e.pageX+15  );
					tipEl.show();
				},
				function () {
					$('#'+id+'-tip').hide();
				}
			);
		}
	});
});
