mainMenuInit = function(){
    var mainMenuTimer;
    var mainMenuFolderCol = jQuery('#main-menu>ul>li.folder');
    jQuery('#main-menu div.sw-in1').slideUp(0, function(){
        jQuery(this).parent().css({'visibility':'visible'});
    });
    var hideMenuItem = function(menuItem){
        jQuery(menuItem).find('div.sw-in1').slideUp("fast", function(){
            jQuery(menuItem).removeClass('hover');
        });
    }
    jQuery('#main-menu li.level1').mouseover(function(){
        clearTimeout( mainMenuTimer );
        jQuery(mainMenuFolderCol).not(this).find('div.sw-in1').each(function(){
            jQuery(this).slideUp(0).parents('li').removeClass('hover');
        });
        if(jQuery(this).hasClass('folder')){
            jQuery(this).addClass('hover').find('div.sw-in1').slideDown("fast");
        }else{
            jQuery(this).addClass('hover');
        }
    }).mouseout(function(){
        if(jQuery(this).hasClass('folder')){
            var tmpThis = this;
            mainMenuTimer = setTimeout(function(){ hideMenuItem(tmpThis); }, 1000);
        }else{
            jQuery(this).removeClass('hover');
        }
    });
}
catalogItemsInit = function(catalogContent){
    var catalogSoputka = jQuery(catalogContent).find('div.catalog-soputka-item');
    if ( catalogSoputka.length ){
        jQuery(catalogSoputka).find('div.cat-sop-content').slideUp(0);
        jQuery(catalogSoputka).find('div.cat-sop-header a').each(function(){
            jQuery(this).click(function(){
                if ( jQuery.browser.msie && jQuery.browser.version > 7 ){
                    jQuery(this).parent().next('div').slideToggle('normal');
                }else{
                    jQuery(this).parent().next('div').slideToggle(0);
                }
                return false
            });
        });
    }
    var regAnchor = /#(.*)/
    var catalogAnchor = regAnchor.exec(document.location);
    if( catalogAnchor ){
        jQuery('#'+catalogAnchor[1]).parent().next('div').slideDown(0);
    }else{
        //jQuery(catalogSoputka).eq(0).find('div.cat-sop-content').slideDown(0);
        // Это чтобы первый открывался по умолчанию
    }
}
mainInitFunction = function(){
    mainMenuInit();
    if ( jQuery('#service-menu li.sm29 a').length ){
        jQuery('#service-menu li.sm29 a').colorbox({
            width:"480px",
            height:"550px",
            iframe: true,
            close : "закрыть"
        });
    }
    if ( jQuery('#askYouQuestion').length ){
        jQuery('#askYouQuestion').colorbox({
            width:"480px",
            height:"550px",
            iframe: true,
            close : "закрыть"
        });
    }
    var catalogContent = jQuery('div.catalog-content-wrap');
    if ( catalogContent.length ){
        catalogItemsInit(catalogContent);
    }
    jQuery('#head-flash').flash({src: '/assets/media/head.swf', width: 980, height: 239, wmode: 'opaque'});
    jQuery('table.style-tbl').find('tbody tr:odd').addClass('alt');
    jQuery('table.style-tbl tr').find('td:last').addClass('lastInRow');
    jQuery('a.colorbox').colorbox({ close : "закрыть" });
}
jQuery.noConflict();
jQuery(document).ready(mainInitFunction);
