$(document).ready(function(){ //Ensure that the newsticker items and bubbles are not displayed $('.newsHeadline').hide(); $('.newsHeadline').eq(0).show(); $('.bubbles').hide(); //Function that displays/hides the bubbles when hovering over the links $("a[rel^='bubble']").hover(function(){ //Function that displays bubble $('.bubbles').hide(); var bubble_id = '#' + $(this).attr("rel"); var xpos = $(this).offset().left; var ypos = $(this).offset().top; $(bubble_id).css({ "position": "absolute", "top": ypos + 15, "left": xpos - 10 }); /* EG: Added this code to have middle bubble display aboe the link and not below it */ $('.bubbles').eq(1).find('.top').css({ "background-image": "url(/assets/partners/images/bubble_top_rev.gif)", "height": "9px", "background-position": "left bottom" }); $('.bubbles').eq(1).find('.bottom').css({ "background-image": "url(/assets/partners/images/bubble_bottom_rev.gif)", "height": "22px" }); $('.bubbles').eq(1).css({ "top": ypos - $('.bubbles').eq(1).height() }); /* EG: End customised code */ $(bubble_id).show(); }, function(){ //Function that hides bubble var bubble_id = '#' + $(this).attr("rel"); var b_height = $(bubble_id).height(); var b_width = $(bubble_id).width(); var b_startx = $(bubble_id).offset().left; var b_starty = $(bubble_id).offset().top; $(document).bind("mousemove", function(e){ if (!(((e.pageX >= b_startx) && (e.pageX <= (b_startx + b_width))) && ((e.pageY >= b_starty) && (e.pageY <= (b_starty + b_height))))) { $(bubble_id).hide(); $(document).unbind("mousemove"); } }); }); //Function that makes the newsticker work function toggleNewsTicker(){ var news_items = $('.newsHeadline'); var news_item_id = news_items.filter(':visible').attr('id'); var i = 0; for (i = 0; i < news_items.length; i++) { if (news_item_id == "msg" + (i)) { news_items.hide(); if (i == (news_items.length - 1)) { news_items.eq(0).show(); } else { news_items.eq(i + 1).show(); } } } } //Execute newsticker function every 5 seconds $("#newsticker").everyTime(3000, toggleNewsTicker); $.get("/assets/shared/includes/latest_news.html", function(data){ $("#newsfeed").html(data); }); });