function SetupTooltips(sTooltipType)
{  
    var hideDelay = 500;  
    var currentID;  
    var hideTimer = null;  
    var ajax = null;  
    var hideFunction = function()  
    {  
        if (hideTimer) {
            clearTimeout(hideTimer); }
        hideTimer = setTimeout(function()  
        {  
            currentPosition = { left: '0px', top: '0px' };  
            $('#popupContainer').css('display', 'none');   
        }, hideDelay);  
    };  
  
    var currentPosition = { left: '0px', top: '0px' };  
  
	if($('#popupContainer').length == 0)
	{
		// One instance that's reused to show info for the current person  
		var container = $('<div id="popupContainer"><table border="0" cellspacing="0" cellpadding="0" align="center" class="popupPopup"><tr><td class="corner topLeft"></td><td class="top"></td><td class="corner topRight"></td></tr><tr><td class="left">&nbsp;</td><td><div class="tooltipContent" id="popupContent"></div></td><td class="right">&nbsp;</td></tr><tr><td class="corner bottomLeft">&nbsp;</td><td class="bottom">&nbsp;</td><td class="corner bottomRight"></td></tr></table></div>');  
	
		$('body').append(container); 
	} 
  
    $('.tooltiptrigger.'+sTooltipType).live('mouseover', function()  
    {  
        if (!$(this).data('hoverIntentAttached'))  
        {  
            $(this).data('hoverIntentAttached', true);  
            $(this).hoverIntent(  
                // hoverIntent mouseOver  
                function()  
                {  
                    if (hideTimer) {
                        clearTimeout(hideTimer); }
					
					if($(this).attr('id')) {
						currentID = $(this).attr('id'); }
					else {
						currentID = ""; }
  
                    var pos = $(this).offset();  
                    var width = $(this).width();  
                    var reposition = { left: (pos.left + width) + 'px', top: pos.top - 5 + 'px' };  
  
                    // If the same popup is already shown, then don't requery  
                    if (currentPosition.left == reposition.left &&  
                        currentPosition.top == reposition.top) { 
                        return; }
  
                    $('#popupContainer').css({  
                        left: reposition.left,  
                        top: reposition.top  
                    });  
  
                    currentPosition = reposition;  
					
					$('.popupPopup', '#popupContainer').removeClass('ttFoot').removeClass('ttEditor').removeClass('ttChanges').removeClass('ttLang').removeClass('ttMs').removeClass('ttVariant').removeClass('ttPerson').removeClass('ttPlace').removeClass('ttComment');
					
					var sTooltipType = findClassWith(this, /^tt/g);
					if(sTooltipType.length > 0)
						$('.popupPopup', '#popupContainer').addClass(sTooltipType);
					else
						$('.popupPopup', '#popupContainer').addClass('ttEditor');

					// Clear html before updating.
					$('#popupContent').html('&nbsp;');

					if(sTooltipType == "ttPerson" || sTooltipType == "ttPlace") 
					{
						if (ajax) {  
							ajax.abort();  
							ajax = null;  
						}  
	  
						if(sTooltipType == "ttPerson" && currentID.length > 0) {
							ajax = $.ajax({  
								type: 'GET',  
								url: 'ajax_personinfo.php',  
								data: 'pid=' + currentID,  
								success: function(data) {  
									var dataObj = eval('('+data+')'); 
									if (typeof(dataObj.personInfo) != 'undefined') {    
										if(dataObj.personInfo.length < 3)
											$('#popupContent').html('<span class="ttFixed">'+dataObj.personName+'</span>');
										else
											$('#popupContent').html('<span class="ttFixed">'+dataObj.personName+', '+dataObj.personInfo+'</span>');  
									}  
								}  
							}); 
						}
						else if(sTooltipType == "ttPlace" && currentID.length > 0) {
							ajax = $.ajax({  
								type: 'GET',  
								url: 'ajax_placeinfo.php',  
								data: 'pid=' + currentID,  
								success: function(data) {  
									var dataObj = eval('('+data+')');  
									if (typeof(dataObj.placeInfo) != 'undefined') {    
										if(dataObj.placeInfo.length < 3)
											$('#popupContent').html('<span class="ttFixed">'+dataObj.placeName+'</span>');
										else
											$('#popupContent').html('<span class="ttFixed">'+dataObj.placeName+', '+dataObj.placeInfo+'</span>');  
									}  
								}  
							}); 
						}
						else
						{
							$('#popupContent').html('');
						}
					}
					else {
						$('#popupContent').html($(this).next('.tooltip').html()); 
					}
					if($('#popupContent').html().length > 0)
						$('#popupContainer').css('display', 'block'); 
                },  
                // hoverIntent mouseOut  
                hideFunction  
            );  
            // Fire mouseover so hoverIntent can start doing its magic  
            $(this).trigger('mouseover');  
        }  
    });  
  
    // Allow mouse over of details without hiding details  
    $('#popupContainer', '.'+sTooltipType).mouseover(function()  
    {  
        if (hideTimer) { 
            clearTimeout(hideTimer); }
    });  
  
    // Hide after mouseout  
    $('#popupContainer', '.'+sTooltipType).mouseout(hideFunction);  
}

function DisableTooltips(sTooltipType)
{
	$('.tooltiptrigger.'+sTooltipType).die('mouseover');
	$('.tooltiptrigger.'+sTooltipType).hoverIntent( function() {}, function() {} );
	$('.tooltiptrigger.'+sTooltipType).removeData('hoverIntentAttached');
	$('#popupContainer', '.'+sTooltipType).unbind('mouseover');
	$('#popupContainer', '.'+sTooltipType).unbind('mouseout');	
}

/*function SetupPersnameTooltips()
{  
    var hideDelay = 500;  
    var currentID;  
    var hideTimer = null;  
    var ajax = null;  
    var hideFunction = function()  
    {  
        if (hideTimer) {
            clearTimeout(hideTimer); }
        hideTimer = setTimeout(function()  
        {  
            currentPosition = { left: '0px', top: '0px' };  
            container.css('display', 'none');  
        }, hideDelay);  
    };  
  
    var currentPosition = { left: '0px', top: '0px' };  
  
    // One instance that's reused to show info for the current person  
    var container = $('<div id="personPopupContainer"><table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="popupPopup ttPerson"><tr><td class="corner topLeft"></td><td class="top"></td><td class="corner topRight"></td></tr><tr><td class="left">&nbsp;</td><td><div class="tooltipContent" id="personPopupContent"></div></td><td class="right">&nbsp;</td></tr><tr><td class="corner bottomLeft">&nbsp;</td><td class="bottom">&nbsp;</td><td class="corner bottomRight"></td></tr></table></div>');  
  
    $('body').append(container);  
  
    $('.person').live('mouseover', function()  
    {  
        if (!$(this).data('hoverIntentAttached'))  
        {  
            $(this).data('hoverIntentAttached', true);  
            $(this).hoverIntent(  
                // hoverIntent mouseOver  
                function()  
                {  
                    if (hideTimer) {
                        clearTimeout(hideTimer); }
  
                    // format of 'rel' tag: pageid,personguid  
                    //var settings = $(this).attr('rel').split(',');  
                    //var pageID = settings[0];  
                    //currentID = settings[1];
					
					if($(this).attr('id')) {
						currentID = $(this).attr('id'); }
					else {
						currentID = ""; }
  
                    // If no guid in url rel tag, don't popup blank  
                    if (currentID == "") {  
                        return; }
  
                    var pos = $(this).offset();  
                    var width = $(this).width();  
                    var reposition = { left: (pos.left + width) + 'px', top: pos.top - 5 + 'px' };  
  
                    // If the same popup is already shown, then don't requery  
                    if (currentPosition.left == reposition.left &&  
                        currentPosition.top == reposition.top) { 
                        return; }
  
                    container.css({  
                        left: reposition.left,  
                        top: reposition.top  
                    });  
  
                    currentPosition = reposition;  
  
                    $('#personPopupContent').html('&nbsp;');  
  
                    if (ajax)  
                    {  
                        ajax.abort();  
                        ajax = null;  
                    }  
  
                    ajax = $.ajax({  
                        type: 'GET',  
                        url: 'ajax_personinfo.php',  
                        data: 'pid=' + currentID,  
                        success: function(data)  
                        {  
							var dataObj = eval('('+data+')');
                            // Verify that we're pointed to a page that returned the expected results.  
                            //if (data.indexOf('personPopupResult') < 0)  
                            //{  
                            //    $('#personPopupContent').html('<span style="color:red" class="smallText">Did not return a valid result for person ' + currentID + '. Please have your administrator check the error log.</span>');  
                            //}  
  
                            // Verify requested person is this person since we could have multiple ajax  
                            // requests out if the server is taking a while.  
                            if (typeof(dataObj.personInfo) != 'undefined')
                            {    
								if(dataObj.personInfo.length < 3)
									$('#personPopupContent').html('<span class="ttFixed">'+dataObj.personName+'</span>');
								else
									$('#personPopupContent').html('<span class="ttFixed">'+dataObj.personName+', '+dataObj.personInfo+'</span>');  
                            }  
                        }  
                    });  
  
                    container.css('display', 'block');  
                },  
                // hoverIntent mouseOut  
                hideFunction  
            );  
            // Fire mouseover so hoverIntent can start doing its magic  
            $(this).trigger('mouseover');  
        }  
    });  
  
    // Allow mouse over of details without hiding details  
    $('#personPopupContainer').mouseover(function()  
    {  
        if (hideTimer) { 
            clearTimeout(hideTimer); }
    });  
  
    // Hide after mouseout  
    $('#personPopupContainer').mouseout(hideFunction);  
}*/
