// JavaScript Document

//menu for Glife
$(function(){
    $("ul.dropdown li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	});

// window open and resize

function centeropen(url, winwidth, winheight){
 var centerwin=window.open(url, "", "toolbar=0, menubar=0 resize=1, scrollbars=1, status=0")
 centerwin.resizeTo(winwidth, winheight)
 centerwin.moveTo(screen.width/2-winwidth/2, screen.height/2-winheight/2) //center window on user's screen
}



// Equalize div heights

function equalHeight(group) {
   var tallest = 0;
   group.each(function() {
      var thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest);
}

$(document).ready(function() {
   equalHeight($(".sameheight"));
   equalHeight($(".sameheight2"));
   equalHeight($(".sameheight3"));
   equalHeight($(".sameheight4"));
   equalHeight($(".sameheight5"));
   equalHeight($(".sameheight6"));
});





// BUBBLE POPUP First Trigger and Popup

    $(function () {
        $('.bubbleInfo').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 0;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: -53,
                        right: -220,
                        display: 'block'
                    }).animate({
                        right: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'linear', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        right: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'linear', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
		});
    });




