//cantidad de pixeles que se ven del footer asomarse
var asomaFooter = 147;
var minimoSeparacionFooter = 100;

//Funcion que toma el div push y le da tamaño necesario para dejar el footer al final de la pagina
jQuery(document).ready(function() {
	calculaAltoPush();
});

jQuery(window).resize(function() {
	waitForFinalEvent(function(){
	      calculaAltoPush();
	    }, 300, "some unique string");
});

jQuery(document).resize(function() {
	waitForFinalEvent(function(){
	      calculaAltoPush();
	    }, 300, "some unique string");
});

var calculaAltoPush = (function() {
	var altoBrowser = $( window ).height();
	var altoContent = $("div#content").height();
	
	var altoPush = altoBrowser - altoContent;
	if (altoPush - asomaFooter > 0 && altoPush - asomaFooter > minimoSeparacionFooter) {
		altoPush = altoPush - asomaFooter;
	} else {
		altoPush = minimoSeparacionFooter;
	}
	$("div#push").css({height: altoPush});
});

var waitForFinalEvent = (function () {
	  var timers = {};
	  return function (callback, ms, uniqueId) {
	    if (!uniqueId) {
	      uniqueId = "Don't call this twice without a uniqueId";
	    }
	    if (timers[uniqueId]) {
	      clearTimeout (timers[uniqueId]);
	    }
	    timers[uniqueId] = setTimeout(callback, ms);
	  };
})();


