  $('#recapdiv').css('opacity', 0);

  var distance = 10;
  var time = 250;
  var hideDelay = 500;

  var hideDelayTimer = null;

  var beingShown = 0;
  var shown = 0;
	
  var hideDelayTimer = null;    

function showRecap(e, ev)
{
	beingShown = $(e).attr('href').substr(1);
	$('#recapdiv').html('Loading...');
	$.get("/sports-betting/recap/", {Sport: isport, League: ileague, GameId: $(e).attr('href').substr(1)}, function(data){$('#recapdiv').html(data)});
	
	var divleft = ($(e).position().left);
	
	divleft-=(divleft > ($("#colleft").width()-$("#recapdiv").width()) ? (divleft-($("#colleft").width()-$("#recapdiv").width()-50)) : 0);
	
	$('#recapdiv').css({
		top: $(e).position().top+27,
		left: divleft,
		display: 'block'
	});

	$('#recapdiv').animate({
		top: '-=' + distance + 'px',
		opacity: 1
	}, time, 'swing', function() {
		beingShown = 0;
		shown = $(e).attr('href').substr(1);
	});
}

hideRecap = function () 
				{
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      hideDelayTimer = setTimeout(function () 
					{
				        hideDelayTimer = null;
						$('#recapdiv').animate({
							top: '-=' + distance + 'px',
							opacity: 0
						}, time, 'swing', function () 
							{
								shown = 0;
          						$('#recapdiv').css('display', 'none');
        					});
      				}, hideDelay);
				};

$(function () {
  $('.recaplink').each(function () {
	  var trigger = this;

    $(trigger).mouseover(function (e) {
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      if (beingShown==$(trigger).attr('href').substr(1) || shown == $(trigger).attr('href').substr(1)) {
        return;
      } else {
		showRecap(trigger, e);
      }
    });
    $('#recapdiv').mouseover(function (e) {
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
    });
    
	$(trigger).mouseout(hideRecap);
    $(trigger).click(function()
	{
		return false;
	})
  });
	
	$('#recapdiv').mouseout(hideRecap);
	$("body").click(function() {
        hideDelayTimer = null;
		$('#recapdiv').animate(
			{
				top: '-=' + distance + 'px',
				opacity: 0
			}, time, 'swing', function () 
			{
				shown = 0;
        		$('#recapdiv').css('display', 'none');
        	}
		);
	});
});
