﻿
$(document).ready(function () {

    $("a[rel*=external]").click(
                function (event) {
                    window.open(this.href);
                    event.preventDefault();
                }
              );


    //TOPMENU A SUBMENU
    var Timer;
    var menuDelay = 0.5;
    $('.menuHref').mouseover(function () {



        $('.submenu').hide();
        //$(this).parent().next().find('.submenu').each(function () { if ($(this).hasClass('submenu')) $(this).fadeIn(250); });
        var id = this.id;
        $("#" + id + "-submenu").fadeIn(250);

        $('.menuHref').each(function () {
            var id = this.id;
            if ($("#" + id).hasClass(id + 'Active'))
                $("#" + id).removeClass(id + 'Active');
        });

        clearTimeout(Timer);
    }).mouseout(
          function () {
              var id = this.id;
              var string = "$('#" + id + "-submenu').fadeOut(500);"

              if ($("#" + id).hasClass(id + 'Active'))
                  $("#" + id).removeClass(id + 'Active').addClass('menuHref');


              Timer = setTimeout(string, menuDelay * 500);
          });


    $('.submenu').mouseout(function () {
        var id = this.id;
        var string = "$('#" + id + "').fadeOut(500);";

        var parent_id = this.id.replace('-submenu', '');

        if ($("#" + parent_id).hasClass(parent_id + 'Active')) {
            $("#" + parent_id).removeClass(parent_id + 'Active').addClass('menuHref');
        }

        Timer = setTimeout(string, menuDelay * 500);
    }).mouseover(
          function () {
              var parent_id = this.id.replace('-submenu', '');

              if (!$("#" + parent_id).hasClass(parent_id + 'Active')) {
                  $("#" + parent_id).addClass(parent_id + 'Active');
                 // $("#" + parent_id).removeClass('menuHref');
              }

              clearTimeout(Timer);
         });
   

});

