$(document).ready(function() { carga_calendario(0, 0); $("#select-categorias").change(function() { if($("#select-categorias").val()=="") window.location = "/eventos.html#top"; else window.location = "/eventos/" + $("#select-categorias").val() + ".html#top"; }); $("#select-meses").change(function() { window.location = "/eventos/cambiames.html?mes=" + $("#select-meses").val(); }); }); function carga_calendario(mes, anio) { var data = ""; if(mes!=0) data = data + "m=" + mes; if(anio!=0) data = data + "&y=" + anio; $.ajax({ type: "get", url: "/eventos/calendario.html", data: data, cache: false, async: true, success: function(result) { $("#div_calendario").html(result); init(); }, error: function(result) { } }); return false; } function init() { $('.date_has_event, .date_has_old_event').each(function () { // options var distance = 10; var time = 200; var hideDelay = 0; var hideDelayTimer = null; // tracker var beingShown = false; var shown = false; var trigger = $(this); var popup = $('.events ul', trigger.parent()).css('opacity', 0); // set the mouseover and mouseout on both element $(trigger.get(0)).mouseover(function () { // stops the hide event if we move from the trigger to the popup element if (hideDelayTimer) clearTimeout(hideDelayTimer); // don't trigger the animation again if we're being shown, or already visible if (beingShown || shown) { return; } else { beingShown = true; // reset position of popup box popup.css({ bottom: 40, left: -76, display: 'block' // brings the popup back in to view }) // (we're using chaining on the popup) now animate it's opacity and position .animate({ bottom: '+=' + distance + 'px', opacity: 1 }, time, 'swing', function() { // once the animation is complete, set the tracker variables beingShown = false; shown = true; }); } }).mouseout(function () { shown = false; popup.css('display', 'none'); }); }); }