jQuery(function($) { $("a.topopup2").click(function() { loading2(); // loading setTimeout(function(){ // then show popup, deley in .5 second loadPopup2(); // function show popup }, 500); // .5 second return false; }); $("div.close").hover( function() { $('span.ecs_tooltip2').show(); }, function () { $('span.ecs_tooltip2').hide(); } ); $("div.close").click(function() { disablePopup2(); // function close pop up }); $(this).keyup(function(event) { if (event.which == 27) { // 27 is 'Ecs' in the keyboard disablePopup2(); // function close pop up } }); $("div#backgroundPopup").click(function() { disablePopup2(); // function close pop up }); $('a.livebox').click(function() { alert('Hello World!'); return false; }); /************** start: functions. **************/ function loading2() { $("div.loader").show(); } function closeloading2() { $("div.loader").fadeOut('normal'); } var popupStatus = 0; // set value function loadPopup2() { if(popupStatus == 0) { // if value is 0, show popup closeloading2(); // fadeout loading $("#toPopup2").fadeIn(0500); // fadein popup div $("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8 $("#backgroundPopup").fadeIn(0001); popupStatus = 1; // and set value to 1 } } function disablePopup2() { if(popupStatus == 1) { // if value is 1, close popup $("#toPopup2").fadeOut("normal"); $("#backgroundPopup").fadeOut("normal"); popupStatus = 0; // and set value to 0 } } /************** end: functions. **************/ }); // jQuery End