// helper tooltips
jQuery(function() {

	// get each tooltip image
	jQuery('.helpMeOut').each(function() {
	
		// create the tooltip after the image, populate with image's title, and hide it
		jQuery('<div class="helpMeText"></div>').html(jQuery(this).attr('title')).insertAfter(jQuery(this)).hide();
		
		// if ie6, create an iframe after the tooltip and hide it
		// prevents form elements from showing through
		if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
			jQuery('<iframe src="/assets/js/iframe.html" frameborder="0" scrolling="no" class="fixTip"></iframe>').insertAfter(jQuery(this).next('.helpMeText')).hide();
		}
		
		// set blank title on the image, so we don't get the browser-default tooltip
		jQuery(this).attr('title', '');
		
		// when you hover over the image
		jQuery(this).bind('mouseenter', function() {
		
			// fade out visible tooltips and iframes
			jQuery('div.helpMeText:visible, .fixTip').fadeOut("fast");
			
			// get the position of the image, and position the tooltip accordingly
			var theOffset = jQuery(this).position();
			jQuery(this).next('div.helpMeText').css({ "left": (theOffset.left - 30) + 'px', "top": (theOffset.top - 10) + 'px' }).fadeIn("fast");
			
			// if ie6, position the iframe so it sits perfectly behind the tooltip
			if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
				var theWidth = jQuery(this).siblings('.helpMeText:animated').outerWidth();
				var theHeight = jQuery(this).siblings('.helpMeText:animated').outerHeight();
				var thePosition = jQuery(this).siblings('.helpMeText:animated').position();
				
				jQuery(this).siblings('.helpMeText:animated').next('.fixTip').width(theWidth).height(theHeight).css({ "left": thePosition.left + 'px', "top": thePosition.top + 'px' }).fadeIn("fast");
			}
		});
	});
	
	// when you move away from the tooltip
	jQuery('div.helpMeText').bind('mouseleave', function() {
	
		// fade out the current tooltip and iframe
		jQuery(this).next('.fixTip').andSelf().fadeOut();
	});
});