
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});



  function ImgShw(ID, width, height, alt)
               {
                    var scroll = "no";
                    var top=0, left=0;
                    if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
                    if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
                    if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
                    width = Math.min(width, screen.width-10);
                    height = Math.min(height, screen.height-28);
                    var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
                    wnd.document.write("<html><head>\n");
                    wnd.document.write("<"+"script language='JavaScript'>\n");
                    wnd.document.write("<!--\n");
                    wnd.document.write("function KeyPress()\n");
                    wnd.document.write("{\n");
                    wnd.document.write("     if(window.event.keyCode == 27)\n");
                    wnd.document.write("          window.close();\n");
                    wnd.document.write("}\n");
                    wnd.document.write("//-->\n");
                    wnd.document.write("</"+"script>\n");
                    wnd.document.write("<title>"+(alt == ""? "Картинка":alt)+"</title></head>\n");
                    wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n");
                    wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\">");
                    wnd.document.write("</body>");
                    wnd.document.write("</html>");
                    wnd.document.close();
               }


// ---------------------------------------------------------------------
// Main menu for chevrolet.sts
// by IonDen
// rev: 2
// ---------------------------------------------------------------------

$(document).ready(function(){
    var $menu_button = $("#top_nav > ul > li > a");
    var menu_int, submenu_int, supersubmenu_int;
    var menu_timer, submenu_timer, supersubmenu_timer = 0;

    $menu_button.mouseenter(function(e){
        menu_timer = 0;
        clearInterval(menu_int);
        submenu_timer = 0;
        clearInterval(submenu_int);
        $("#top_pop").remove();
        $("#top_subtop").remove();
        $("#top_end").remove();

        $menu_button.removeClass("on");
        $(this).addClass("on");
        var has_menu = $(this).siblings().length;

        if(has_menu == 1) {
            show_menu($(this));
        }
    });
    $menu_button.mouseleave(function(e){
        hide_menu();
    });

    $("#top_pop").live("mouseenter",function(e){
        menu_timer = 0;
        clearInterval(menu_int);
    });
    $("#top_pop").live("mouseleave",function(e){
        hide_menu();
    });

    $("#top_subtop").live("mouseenter",function(e){
        menu_timer = 0;
        clearInterval(menu_int);
        submenu_timer = 0;
        clearInterval(submenu_int);
    });
    $("#top_subtop").live("mouseleave",function(e){
        hide_menu();
        hide_submenu();
    });

    $("#top_end").live("mouseenter",function(e){
        menu_timer = 0;
        clearInterval(menu_int);
        submenu_timer = 0;
        clearInterval(submenu_int);
        supersubmenu_timer = 0;
        clearInterval(supersubmenu_int);
    });
    $("#top_end").live("mouseleave",function(e){
        hide_menu();
        hide_submenu();
        hide_supersubmenu();
    });

    function hide_menu(){
        menu_int = setInterval(function(){
            if(menu_timer < 10) {
                menu_timer++;
            } else {
                menu_timer = 0;
                clearInterval(menu_int);
                $menu_button.removeClass("on");
                $("#top_pop").remove();
            }
        },50);
    }

    function show_menu(_this) {
        var offset = _this.offset();
        var html = '<div class="top_pop" id="top_pop"><ul>';
        html += _this.siblings("ul").html();
        html += '</ul></div>';

        $("body").append(html);
        $("#top_pop").css("top",offset.top + 29).css("left",offset.left);

        var $sm_button = $("#top_pop > ul > li > a");

        $sm_button.mouseenter(function(e){
            submenu_timer = 0;
            clearInterval(submenu_int);
            $sm_button.removeClass("on");
            $(this).addClass("on");
            $("#top_subtop").remove();
            $("#top_end").remove();

            var has_submenu = $(this).siblings().length;
            if(has_submenu == 1) {
                if($(this).siblings("ul").length > 0) {
                    show_submenu($(this));
                } else {
                    show_end($(this),171);
                }
            }
        });
        $sm_button.mouseleave(function(e){
            hide_submenu();
        });
    }

    function hide_submenu(){
        submenu_int = setInterval(function(){
            if(submenu_timer < 10) {
                submenu_timer++;
            } else {
                submenu_timer = 0;
                clearInterval(submenu_int);
                $("#top_pop > ul > li > a").removeClass("on");
                $("#top_subtop").remove();
                $("#top_end").remove();
            }
        },50);
    }

    function show_submenu(_this) {
        var offset = _this.offset();
        var html = '<div class="top_pop" id="top_subtop"><ul>';
        html += _this.siblings("ul").html();
        html += '</ul></div>';

        $("body").append(html);
        $("#top_subtop").css("top",offset.top).css("left",offset.left + 171);

        var $ssm_button = $("#top_subtop > ul > li > a");
        $ssm_button.mouseenter(function(e){
            supersubmenu_timer = 0;
            clearInterval(supersubmenu_int);
            $ssm_button.removeClass("on");
            $(this).addClass("on");
            $("#top_end").remove();

            var has_end = $(this).siblings().length;
            if(has_end == 1) {
                show_end($(this),201);
            }
        });
        $ssm_button.mouseleave(function(e){
            hide_supersubmenu();
        });
    }

    function hide_supersubmenu(){
        supersubmenu_int = setInterval(function(){
            if(supersubmenu_timer < 10) {
                supersubmenu_timer++;
            } else {
                supersubmenu_timer = 0;
                clearInterval(supersubmenu_int);
                $("#top_subtop > ul > li > a").removeClass("on");
                $("#top_end").remove();
            }
        },50);
    }

    function show_end(_this,wid) {
        var offset = _this.offset();
        var html = '<div class="top_pop" id="top_end">';
        html += _this.siblings("i").html();
        html += '</div>';

        $("body").append(html);
        $("#top_end").css("top",offset.top - 15).css("left",offset.left + wid);
    }
});
