function parse_url (str, component) {

    var  o   = {

        strictMode: false,

        key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],        q:   {

            name:   "queryKey",

            parser: /(?:^|&)([^&=]*)=?([^&]*)/g

        },

        parser: {            strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,

            loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-protocol to catch file:/// (should restrict this)

        }

    };

    var m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),

    uri = {},

    i   = 14;

    while (i--) {uri[o.key[i]] = m[i] || "";}

    uri[o.q.name] = {};

    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {

         if ($1) uri[o.q.name][$1] = $2;

    });        

    return uri;

}

$(document).ready(function() {
     $('#header ol li:not(:last)').css({'border-right':'1px solid #222'});
     $('.menu .subnav a').filter(function(index) { return ($(this).attr('title').length<1 && $(this).text().length<1); }).each(function(index) {

          $(this).parent('li').remove();

     });

     $('.menu ul').filter(function(index) { return $('li',this).size()==0; }).remove();

     $('.menu > li').live('mouseenter',function(e) {

          e.preventDefault();

          $('.menu > li > .subnav').hide();

          $('> .subnav',this).show();

          if (!$(this).is('#nav3')) $('> .subnav',this).css('width','auto');

     });

     $('.menu > li > .subnav').live('mouseleave',function(e) {

            e.stopPropagation();

            $(this).hide();

     });

     var docUrl=location.pathname;

     $('#image-menu a').each(function(index) {

            var url=parse_url($(this).attr('href'))

            if (docUrl.indexOf(url.path)>=0 && docUrl.length>1) $(this).addClass('selected');

            else $(this).removeClass('selected');

     });

});
