$(document).ready(function() {
	runCount = 0;
	
	setFooter = function()
	{
		/*
		pos1 = $("#container-bottom").offset();
		pos2 = $("#associations-content a:last-child").offset();
		h = $("#associations-content a:last-child").height();
		diff = ((pos1.top - (pos2.top + h)) -200);
		
		if(diff > 1 && runCount == 0)
		{
			diff = Math.round(diff);
			//current_padding = $("#associations-content").css('padding-bottom');
			//newPadding = current_padding + diff;
			$("#associations-content").css("padding-bottom",diff+"px");
		}
		*/
		
		if($("#inner-right").height() > $("#associations-content").height())
		{
			$("#associations-content").height($("#inner-right").height() + 70);
		}
		else
		{
			if($("#associations-content").height() < 550)
			{
				$("#associations-content").height(550);
			}
		}
		
		runCount++;

		if(runCount >= 6)
		{
			clearInterval(footIntv);
		}
	}
	
	setFooter();
	var footIntv = setInterval(setFooter,500);
	
	zoomAssociation = function(large) {
	    //var o = $(this[0]) // It's your element
		created = new Date();
		$("."+large).after('<div id="association-zoom-'+large+'" created="'+created+'" class="assoc-zoomage"><div onmouseout="removeParent(this)"><img src="/assets/images/logos/'+large+'.png"></div></div>');
		$("#association-zoom-"+large).fadeIn();
	};

	zoomOutAssociation = function(large) {
	    var o = $(this[0]) // It's your element
		$("#association-zoom-"+large).remove();
	};
	
	removeParent = function(e)
	{
		$(e).parent().remove();
	}
	
	checkLogos = function()
	{
		$(".assoc-zoomage").each(function() {
			thisid = $(this).attr('id');
			created = new Date($("#"+thisid).attr('created'));
			//alert(created);
			var seconds = 0;
			var difference = 0;
			today = new Date();
			difference = created - today;
			seconds = Math.round(difference/(1000));
			if(seconds < -2)
			{
				$(this).remove();
			}
		});
	}
	
	$("#associations-content a img").hover(function(e) {
		zoomAssociation($(this).attr("class"));
	}, function() {});
	
	var clearLogos = setInterval(checkLogos,400);
});
