// Core Page Functions
// The following functions may (or may not) be used on one or more pages.

$(document).ready(function(){

	// CAPTCHA Refresh
	
	$('#refresh_captcha').click(function() {
		var start = new Date();
		$('#captcha').attr('src','/includes/captcha/securimage_show.php?sid='+start.getTime());
		return false;
	});
	
	
	// AK - Since hiding the tooltips is buggy, hide them whenever we are over input/select boxes to be sure
	$('input, select').hover(function() {
		$('.jTip_content').hide();								  
	});

	setupTooltips();
});

	function setupTooltips() {
		//jTip hover functions
		$('.jTip').hover(function(e) {
			var tooltip = $(this).siblings('.jTip_content');
			tooltipHeight = tooltip.outerHeight();
			var height = $(this).outerHeight();
			var offset = $(this).offset();
			var yPos = offset.top - (tooltipHeight / 2) + 10;
			var xPos = offset.left + 28;

			tooltip.clone().appendTo('body').addClass('current_tooltip').css({
				'top'		:		yPos + 'px',
				'left'		:		xPos + 'px',
				'height'	:		'auto',
				'z-index'	:		99999999
			}).show();
			/*$(this).siblings('.jTip_content').css({
				left: ($(this).outerWidth() - $(this).siblings('.jTip_content'))/2
			})*/
		},
		function() {
			$('.current_tooltip').remove();
			//$(this).siblings('.jTip_content').hide();
		});
	}
