
(function($){   
 $.fn.makedropdowns = function() {  	
    return this.each(function() { 
		var selfref=$(this);		
		$('li',selfref).each(function(i){
			var this_li=$(this);						
			if(this_li.parent().html() == selfref.html()){
			var opened=false;
			var intV;
				function showChildren(){
					opened=true;
					var lnkTxt = $('a span',this_li);					
					var posX = 0;
					var newW = 0;
					
					this_li.addClass('over');
					this_li.siblings().removeClass('over');
					
					if(i == 0){
						newW = this_li.innerWidth();
						posX = this_li.offset().left +1;
					}else{
						posX = lnkTxt.offset().left ;
						newW = lnkTxt.innerWidth();
						
					}
					var ie6XOffset = 0;
					if($.browser.msie && $.browser.version<7){
						ie6XOffset -= ($('.maincontainer').offset().left);				
					}
					
					if($.browser.msie && $.browser.version <7){
						posX += ie6XOffset ;
					}
					var child_list =$('ul',this_li).show();					
					if(child_list.width()<newW){
						child_list.css({'width':newW+'px'});
					}
					child_list.css({'position':'absolute','left': posX+'px','top':(this_li.offset().top + this_li.innerHeight())+'px'});
					
				}
				function hideChildren(parent_item){
					opened = false;
					intV=setInterval(function(){reallyHideThem()},20);
				}
				function reallyHideThem(){
					clearInterval(intV)
					if(!opened){
						this_li.removeClass('over');
						$('ul',this_li).hide();
					}
				}
				this_li.bind('mouseover',function(){showChildren(this);});
				this_li.bind('mouseout',function(){hideChildren(this);});
			}
		});		
    });   
 };   
})(jQuery);

runOnLoad = function(){     
   $(".l2_navigation .dropdown_menu").makedropdowns();
   
}