/**
	HINTS v.2 ( author Alex.B. )
	To show hint add following in tag declaration:
	<TAG .... class="hintOnThis" hint="???????" ....  ></TAG>
*/
var hintInstance = null; 

$(document).ready(function(){
	hintInit();
});

function hintInit(){
	var hintIMG = 	jQuery('<img src="/i/hintPointer.png">')
		.css('clear', 'both');
	var hintHTML = 	jQuery('<div></div>')
		.attr('id', "hintContainer");
	
	var hint = 	jQuery('<div></div>')
		.attr('id', "hintInstance")
		.css('display', 'none')
		.append(hintHTML)
		.append(hintIMG);
	
	jQuery(document.body).append(hint);
	hintInstance = jQuery('#hintInstance');
	jQuery('.hintOnThis').live('mousemove', function(e) { 
		showHintContainer(e) 
	});
	jQuery('.hintOnThis').live('mouseout', function(e) { 
		hideHintContainer( ) 
	});
}

function showHintContainer(e){
	if(hintInstance) 
	{
		obj = e.currentTarget;
		if(jQuery(obj).attr('hint'))
		{
			var x = parseInt( jQuery(e.currentTarget).offset().left ); 
			jQuery('#hintContainer',hintInstance).css({ 
				'visibility': 'hidden',
				'background': '#D4EEFC',
				'border'	: '1px solid #DFF7FF',
				'border-bottom'	: '1px solid #4C96D4',
				'border-radius'	: '5px',
				'box-shadow'	: '0 0 4px #334',
				'padding'	: '2px 5px',
				'font-size'	: '11px',
				'color'		: '#000',
				'float'		: 'left'
			});
			jQuery('#hintContainer',hintInstance).html( jQuery(obj).attr('hint') );
			var y = parseInt( jQuery(e.currentTarget).offset().top - hintInstance.height() - 2 );

			if( x + jQuery('#hintContainer',hintInstance).width() + 30 > $('body').width()) { 
				x = x - jQuery('#hintContainer',hintInstance).width(); 
				jQuery('img',hintInstance).css({ 'float':'right'});
			} else {
				x+= 0; 
				jQuery('img',hintInstance).css({ 'float':'left'});
			}
			
			hintInstance.css({ 
				'z-index'	: '20009',
				'position'	: 'absolute',
				'left'		: x+'px', 
				'top'		: y+'px'
			});
			hintInstance.show(
				'',
				jQuery('#hintContainer',hintInstance).css({ 
					'visibility': 'visible'
				})
			);
		}
	}
}

function hideHintContainer() {
	if(hintInstance) {
		jQuery('#hintContainer',hintInstance).html( '' );
		hintInstance.hide();
	}
}

function updateHintEvents(){
	hintInit();
}
