$(document).ready(function(){
    clr = document.domain.length + 3; //домен
    window.url = location.href.substring(location.href.indexOf("/")+clr);
    if (url != ''){
        active = $(".leftMenu li a[href$='/"+url+"']");
        if (active.length){
          active.addClass("hover").next("ul").show();
          prevActive1 = active.closest('ul').show().prev('a').addClass("prevHover prevA1");
          prevActive2 = prevActive1.closest('ul').show().prev('a').addClass("prevHover prevA2");
          prevActive3 = prevActive2.closest('ul').show().prev('a').addClass("prevHover prevA3");

          activeTop = $(".topMenu li a[href$='/"+url+"']");
          activeTop.addClass("hover").parent("li").addClass("topHover");
//крошки
          str0 = '<a href="/">Главная</a> /' + '\n\t';
          str1 = '<a href="' + active.attr('href') + '">' + active.text() + '</a>' + '\n\t';
          str2 = ''; str3 =''; str4 = '';
          if (prevActive1.text()){str2 = '<a href="' + prevActive1.attr('href') + '">' + prevActive1.text() + '</a> / \n\t';}
          if (prevActive2.text()){str3 = '<a href="' + prevActive2.attr('href') + '">' + prevActive2.text() + '</a> / \n\t';}
          if (prevActive3.text()){str4 = '<a href="' + prevActive3.attr('href') + '">' + prevActive3.text() + '</a> / \n\t';}
          $('.breadcrumbs').html(str0 + str4 + str3 + str2 + str1);
        }else{
          activeTop = $(".topMenu li a[href$='"+url+"']");
          if (activeTop.length){
            activeTop.addClass("hover").parent("li").addClass("topHover");
            strTop = '';
            str0 = '<a href="/">Главная</a> /' + '\n\t';
            strTop = '<a href="' + activeTop.attr('href') + '">' + activeTop.text() + '</a>' + '\n\t';
            $('.breadcrumbs').html(str0 + strTop);
          }
        }
    }else{
        active = $(".leftMenu li a[href='/']");
        active.addClass("hover").next("ul").show();
        activeTop = $(".topMenu li a[href='/']");
        activeTop.addClass("hover").parent("li").addClass("topHover");
    }
//    $('h1').insertBefore('.breadcrumbs');
});
