$(document).ready(function(){
    $('#mainMenu > li').mouseenter(function(){
        //$('#mainMenu > li.selected').removeClass('selected').addClass('semiSelected').next().removeClass('noSeparator');
        $(this).addClass('active');
        $(this).find('div').stop(true, true).slideDown('fast');
        $(this).next().addClass('noSeparator');
    }).mouseleave(function(){
        $(this).removeClass('active');
        $(this).find('div').stop(true, true).hide();
        if (!$(this).hasClass('active')) $(this).next().removeClass('noSeparator');
        //$('#mainMenu > li.semiSelected').addClass('selected').next().addClass('noSeparator');
    }).each(function(){
        $(this).find('div').width($(this).outerWidth());
    });
    
    $('#mainMenu li.selected').each(function(){
        //$(this).next().addClass('noSeparator');
    });
    
    $('.popupContainer .popup').mouseenter(function() {
        $(this).stop(true, true).animate({borderColor: '#333333'});
    }).mouseleave(function() {
        $(this).stop(true, true).animate({borderColor: '#e9e9e9'});
    });
    
    $('#contactForm').each(function() {
        $(this).parent().addClass('slimer');
    });
    
    $('#contactForm .reset').click(function() {
        $(this).parent().parent().find('.row').removeClass('error');
        $(this).parent().parent().find('label').each(function(){
            $(this).text($(this).attr('title') + ':');
        });
        $(this).parent().parent().find('input.text, textarea').each(function(){
            $(this).val('');
            $(this).text('');
        });
        return false;
    });
    
    $("a.popup").fancybox();
    
    $('input.button, a.more, a.edit, a.buy').mouseenter(function(){
        $(this).css({opacity: 0.9});
    }).mouseleave(function(){
        $(this).css({opacity: 1});
    });
    
    $("div.captcha .refresh").click(function() {
        $(this).parent().find('img').attr('src', $(this).attr('href') + '&time=' + Math.random());
        return false;
    });
});

$(window).load(function() {
    $('#topmapContainer').nivoSlider({ 
	 	effect: 'fade',
		pauseTime : 5000, 
        pauseOnHover : false,
        directionNav : false,
        controlNav : false,
        slices : 25
    });
});
