window.onload = function(){
    

    // Acordeon menu user-area
    if(typeof $('#products-menu')[0] == 'object'){
         var items = $('li a', '#products-menu');         
         
         $(items).each(function(i, item){
             var submenu = $(this).parent().find('ul');
             if(submenu.length == 1){
                 $(this).parent()[0].className = 'closed';
                 submenu.data('h', submenu[0].offsetHeight);                                         
                 $(submenu).css({"height":0});                 
                 $(item).click(function(){                                
                     if(parseInt($(submenu).css("height")) > 0){                    
                     $(this).parent()[0].className = 'closed';
                     alert($(submenu).find('ul'));
                     if(!$(submenu).find('ul').length){
                        $(submenu).stop().animate({'height': 0}, 500);
                     }
                 }else{                               
                     $(this).parent()[0].className = 'open';
                     $(items).each(function(j, prev){
                         if(parseInt($(prev).next().css("height")) > 0){
                             $(prev).next().stop().animate({'height': 0}, 500);
                         }
                     });
                     $(submenu).stop().animate({'height':submenu.data('h')}, 500);         
                 }              
                 return false;
                 }).mouseover(function(){
                    if(/MSIE 6.0/.test(navigator.userAgent))
                        $(this).css("cursor", "pointer");                
                 });
             }
         });                    
    
    }
}
