$.fn.accMenu = function(settings){
    var defaults = {
        accEf: 'slow'
    };
    settings = $.extend(defaults, settings);
    $this = $(this);
    
    $(this).ajaxComplete(function(request, settings){
        child = "";
        hex = "";
        red = "";
        green = "";
        for (i = 15; i >= 0; i--) {
            if (i == 15) 
                hex = "#FFFFFF";
            else 
                if (i == 14) 
                    hex = "#E6F1FF";
                else 
                    if (i == 13) 
                        hex = "#CCE2FF";
                    else 
                        if (i == 12) 
                            hex = "#B3D4FF";
                        else 
                            if (i == 11) 
                                hex = "#99C5FF";
                            else 
                                if (i == 10) 
                                    hex = "#80B7FF";
                                else 
                                    if (i == 9) 
                                        hex = "#66A8FF";
                                    else 
                                        if (i == 8) 
                                            hex = "#4D9AFF";
                                        else 
                                            if (i == 7) 
                                                hex = "#338BFF";
            
            
            child += "li ";
            $("#accordion-menu " + child).css({
                backgroundColor: hex
            });
        }
    });
    
    
    
    
    $(this).find("a").live('click', function(){
        var href = 'conteudo/produtos/conteudo.php';
        var htmlStr = $(this).attr('href');
        htmlStr = htmlStr.substr(htmlStr.lastIndexOf("#") + 1);
        if (htmlStr != 'javascript:void(0)') {
			scrollTo(0,0);
            $('#divCenter').html('<div id="loading"></div>');
            $this.find("a").css({
                color: '#242f4f'
            });
            $(this).css({
                color: '#0080ff'
            });
            $.get(href, {
                familia: htmlStr,
                title: $(this).attr("rel")
            }, function(data){
                $('#divCenter').html(data);
            });
        }
        else {
        
            itemPosic = $(this);
            if ($(itemPosic).parent().find("ul").html() == null) {
                //$(this).before('<img id="accMenuIco" src="img/bgAccMenuItem.png"/>');
                $.get('menus/loadMenProdu.php', {
                    item: $(this).attr("rel")
                }, function(data){
                    $(itemPosic).after(data);
                });
            }
            
        }
        
        /*
         $this.find("a").css({
         color: '#000000'
         });
         if ($(this).parent().find("ul").html()) {
         }
         else {
         $(this).css({
         color: '#0080ff'
         });
         }
         */
        $(this).parent().find('ul:first').toggle(settings.accEf).each(function(){
            $(this).parent().find('ul').hide();
            //$(this).parent().find('ul').find("#accMenuIco").remove();
        });
        
    });
    return $this;
};

