$(document).ready(function() {
                    
    //    $('#mainNav li:first').css({
    //        "background-image":"none"
    //    });
    
    $('.top-menu li:first > a').addClass("first");
    
    $('.top-menu li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);

        }, 
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);			
        }
        );
    
    $('#search-by-articul').click(function() {
        $(this).attr('value', '');
    });
    $('#add-email').click(function() {
        $(this).attr('value', '');
    });

    $('#button-add-email, #MailForm').live('submit', function(e){
        e.preventDefault();
        var colorboxOptions = {
            ajax: true,
            href: $(this).attr('action')+"form.html",
            data: $(this).serializeArray(),
            width: '600px'
        }

        $.colorbox(colorboxOptions);
    });

    $('#send-rezume').click(function(e){
        e.preventDefault();
        var colorboxOptions = {
            href: $(this).attr('href')+"form.html",
            width: '600px',
            height: '1170px'
        }

        $.colorbox(colorboxOptions);
    });

    $('#send-message').click(function(e){
        e.preventDefault();
        var colorboxOptions = {
            href: $(this).attr('href')+"form.html",
            width: '600px',
            height: '810px'
        }

        $.colorbox(colorboxOptions);
    });

    $('#comment-user-link').click(function(e){
        e.preventDefault();
        var colorboxOptions = {
            href: $(this).attr('href'),
            width: '600px',
            height: '650px'
        }

        $.colorbox(colorboxOptions);
    });

    $('.about-job').click(function(e){
        e.preventDefault();
        var colorboxOptions = {
            ajax: true,
            href: "content.html"+$(this).attr('href'),
            width: '50%'

        }
        $.colorbox(colorboxOptions);
    });
    
    $("a[rel='foto-ab']").colorbox();
    
    $(".block-image").each(function(){
        var gallery = $(this);                    
        gallery.find(".block-imageset a[rel^=imgset]").colorbox({
            current: "Изображение {current} из {total}"
        });
        gallery.find(".link-foto").click(function(e){
            e.preventDefault();
            gallery.find(".block-imageset a[rel^=imgset]").eq(0).click(); 
        });
    });
     
    $(".tabs-city .city").click(function() {
        $(this).next(".box-adress").fadeIn();
    });
    $(".close-box-adress").click(function() {
        $(this).parent(".box-adress").fadeOut();
    });
    
    $(".menu-collection li").has("li").addClass("collapse");	
    $(".menu-collection li").has("li.active").addClass("active");	
    $(".menu-collection ul > li:not(.active) ul").hide();

    var menuItems = $(".menu-collection a");
    menuItems.click(function(e){
        var subItems = $(this).parent().children("ul");
        if (subItems.size() > 0) {
            e.preventDefault();
            subItems.slideToggle("fast");
            subItems.parent().toggleClass("active");
        }
        else {
            return true;
        }
    });
    
    $(".slide-show-product").live("click", function(e){
        e.preventDefault();
        var url = $(this).attr("href")
        var linkproduct = url.split('?');
        var current_url = '?' + linkproduct[1];
        var ajaxLink = "./" + current_url + " " + "#slideshow-product > *";
        var loader = $("<div></div>").addClass("loader");
        loader
        .css("height", $("#slideshow-product").height())
        .css("width", $("#slideshow-product").width())
        .css("float", $("#slideshow-product").css("float"));
        $("#slideshow-product").fadeOut("fast", function(){
            $(this).before(loader);
            $(this).load(ajaxLink, function(){
                loader.remove();
                $(this).fadeIn("fast");
            });
        });
    });
    
    $("ul.myslidemenu").supersubs({ 
        minWidth:    16,   
        maxWidth:    32,   
        extraWidth:  1     
    }).superfish({
        animation: {
            opacity:'show',
            height:'show'
        },
        speed: 'fast',
        autoArrows: false,
        dropShadows: false
    });  

/*   var menuItems = $(".myslidemenu a");
    menuItems.click(function(e){
        var subItems = $(this).parent().children("ul");
        if (subItems.size() > 0) {
            e.preventDefault();
        }
        else {
            return true;
        }
    });*/
});


