jQuery(document).ready(function() {
	$('.help-bubble').addClass('help-bubble-js').hide();
});

jQuery(window).load(function () {
		 /* Init help links in forms */
		 
		 $('.help-bubble').each(function() {
		 		 var toggleLink = $('<a />').attr('href','#').addClass('help-toggle').html('<img src="http://www.goteborg.se/wps/wcm/connect/ceeb6e8040010ff5a89abd5582afb8c2/icn-help.gif?MOD=AJPERES&cache=non" alt="Hj&auml;lp" />').click 
(function() {
		 		 		 if($(this).parent().is('legend')) {
		 		 		 		 var box = $(this).parent().parent().find('.help-bubble');
		 		 		 } else {
		 		 		 		 var box = $(this).parent().find('.help-bubble');
		 		 		 }
		 		 		 if($(box).hasClass('active')) {
		 		 		 		 $('.help-bubble').hide().removeClass('active');
		 		 		 		 $('body').unbind('click');
		 		 		 } else {
		 		 		 		 $('.help-bubble').hide().removeClass('active');
		 		 		 		 $(box).show().addClass('active');
		 		 		 		 $('body').click(function() {
		 		 		 		 		 $('.help-bubble').hide().removeClass('active');
		 		 		 		 });
		 		 		 }
		 		 		 return false;
		 		 });
		 		 if($(this).parent().is('fieldset')) {
		 		 		 $(this).parent().find('legend').append(toggleLink);
		 		 } else {
		 		 		 $(this).before(toggleLink);
		 		 }
		 		 var position = $(toggleLink).find('img').position();
		 		 position.top = position.top - 5;
		 		 $(this).css('position','absolute').css('width','20em').css 
('margin','0').css('left',position.left+'px').css('top',position.top 
+'px');
		 });
});