var glossaryTerms = [];
jQuery(function() {
    jQuery(".glossary").each(function() {
        jQuery(this).data("gterm", this.title);
    });
    
    jQuery(".glossary").each(function() {
        this.title = "Glossary term: "+this.title;
    });
    
    jQuery(".glossary").bind("click", function() {
        var element = this;
        var term = jQuery(element).data("gterm");
        
        if(typeof glossaryTerms[term] == 'undefined')
        {
            jQuery.get('/ajax/Glossary/tooltip/?term='+term, function(data){
                glossaryTerms[term] = data;
                
                jAlert(glossaryTerms[term], term);
            });
        }
        else
        {
            jAlert(glossaryTerms[term], term);
        }
    });
});
