function makeDictDescription(cls, data) {
var pageElems = [];
if ($$(cls + ' .h_word').length > 0) {
var actual = $('article').down('h2').innerHTML.stripTags().toLowerCase();
$$(cls + ' .h_word').each(function(el, i){
el = $(el);
var dataKey = el.innerHTML.stripTags().toLowerCase().replace('&nbsp;', ' ').replace(/[\r\n]/g, ' ').replace(/[\n|\r]/g, ' ').unescapeHTML();
if (dataKey == actual || el.up('a') != null) {
el.removeClassName('h_word');
} else {
var info = data[dataKey];
pageElems.push([el, info]);
}
});
pageElems.each(function(pel, i) {
var el = $(pel[0]);
var dataKey = el.innerHTML.stripTags().toLowerCase().replace(/[\r\n]/g, ' ').replace(/[\n|\r]/g, ' ').unescapeHTML();
var info = pel[1];
var title = info[0].unescapeHTML().replace('&nbsp;', ' ');
el.title = title;
var timerId;
var span = new Element('div', {'id': 'dict_description_'+i, 'class': 'dict_description'});
span.update('<strong>'+ el.innerHTML +'</strong><br />'+ info[0] +'<span class="cleaner"></span><a href="'+ info[1] +'">více</a>');
$(document.body).insert(span);
span.absolutize().setStyle({top: (el.cumulativeOffset().top + 15)+'px', left: el.cumulativeOffset().left+'px', display: 'none'});
el.observe('click', function(){
$('dict_description_'+i).show();
window.clearTimeout(timerId);
timerId = Element.hide.delay(2, span);
if (typeof _gaq != 'undefined') {
_gaq.push(['t2._trackEvent', 'glossary', dataKey, window.location.href]);
}
});
span.observe('mouseover', function(ev) {
window.clearTimeout(timerId);
});
el.up('div#all').observe('mouseover', function(ev) {
if ($(Event.element(ev)).descendantOf && !$(Event.element(ev)).descendantOf('dict_description_'+i) && Event.element(ev).id !== 'dict_description_'+i) {
$('dict_description_'+i).hide();
}
});
})
}
}
