﻿
$(document).ready(function() {
    $('#nav>li>ul').hide();
//alert(fullpath);
    
    var loc = window.location.href.toString().split("/"); // fixed by S. Stephan was split("/")
// alert(loc);     
    var len = loc.length;
//alert(len);
    var fullpath;
//alert(fullpath);
    if (len == 5) {      //changed by S. stephan from len == 6
        fullpath = loc[len - 2] + '/' + loc[loc.length - 1];
    }
    if (len == 4) {     //changed by S. stephan from len == 5
        fullpath = loc[len - 1]
    }
    
    $("a[href='" + [fullpath] + "']").parents("li").each(function() {
        $(this).addClass("active");
    }); 
//alert(fullpath);
    $.cookie('the_cookie', fullpath); // set cookie
    $.cookie('the_cookie', fullpath, { expires: 1 });

    
});

$(function() {

    var fullpath = $.cookie('the_cookie'); 
//alert(fullpath); 
  
    if($("a[href='" + [fullpath] + "']").parents("li").children().size()==2)
    {        
        $("a[href='" + [fullpath] + "']").parents("li").addClass("active arrow-right");
    }
    else
    {
        $("a[href='" + [fullpath] + "']").parents("li").addClass("active");
    }
    
    $("a[href='" + [fullpath] + "']").parents("li").nextAll("ul").slideUp();
    $("a[href='" + [fullpath] + "']").parents("li").find("ul:first").slideDown(500);
});



