﻿$(function()
{
    ZobrazRegistr(".jquery_registr_0", ".registrnarodni", ".narodnipopis");
    ZobrazRegistr(".jquery_registr_1", ".registrhygienicky", ".hygienickypopis");
    ZobrazRegistr(".jquery_registr_2", ".registrspecialni", ".specialnipopis");
})

//Zobrazi vypis vsech registru a zese ho schova po najeti mysi
function ZobrazRegistr(obal ,registr, detail)
{
    //Zorazit jednotlive registry
    $(registr).bind("mouseover", function()
    {
        $(detail + " p.popis").hide();
        $(detail + " .jquery_seznam_registru").show();
        $(obal + " h3 a").addClass("jquery_odkaz_zvyraznit");
    });

    //Skreju jednotlive registry pokud nebudu uvnitr divu
    $(obal).bind("mouseout", function(e)
    {
        var o = $(detail).offset();
        var w = $(detail).width();
        var h = $(detail).height();
        var tolerance = 10

        if (!(o.top <= e.pageY && o.left <= e.pageX &&
            ((o.top - tolerance) + h) >= e.pageY && ((o.left - tolerance) + w) >= e.pageX))
        {
            $(detail + " p.popis").show();
            $(detail + " .jquery_seznam_registru").hide();
            $(obal + " h3 a").removeClass("jquery_odkaz_zvyraznit");
        }
    });

    //Nastavim udalost na konrektni registr abych zobrazil jeho cele jmeno
    $(obal + " li a").bind("mouseover", function()
    {
        $(detail + " .label p").html($(this).attr("title"));
    });

    //Nastavim udalost na konrektni registr abych skryl jeho cele jmeno
    $(obal + " li a").bind("mouseout", function()
    {
        $(detail + " .label p").html("");
    });
}