$(document).ready(function(){

/*
    if(!$.cookie('nybn')) {
      openBanner();
      $.cookie('nybn', 'v', { expires: 1, path: "/" });
    }
    
    function openBanner() {
      apprise('<img src="/upload/background_text.jpg" />',{'textOk'	 :	''});
      $('.appriseOuter').addClass('NYbanner');
    }*/
    
    //Добавить стрелки к заголовкам блоков
    $('.arrowdownHeader').append('<span class="arrowDown"></span>');
    
    //Левое меню с разделами
    $('.sectionList .active').parentsUntil('.sectionList').addClass('active').show();
    
    $('.sectionList li a').click(function(e){
        var checkElement = $(this).nextAll('ul');
        if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
            checkElement.slideUp('normal');
            //$this.parent().removeClass("bottomCorners opened");
            $(this).parent().removeClass("active");
            //e.preventDefault();
            return false;
        }
        if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
            checkElement.slideDown('normal');
            //$this.parent().addClass("bottomCorners opened");
            $(this).parent().addClass("active");
            //e.preventDefault();
            return false;
        }
    });
    
    //Выравнивание элементов по высоте в каталоге
    $('.pseudo-table-row').each(function(index){
        var h = 0;
        $productSet = $(this).children('.product').children('.productInside');
        $productSet.each(function(index){
            if ($(this).height() >= h) 
                h = $(this).height();
        });
        $productSet.each(function(index){
            $(this).height(h - 20);
        });
    });
    
    //Стилизованное увеличение/уменьшение кол-ва товаров
    $('.arrws').arrowsCtrl();
    
    //$("input[name='DEL_TIME_DATE']").datepicker();
    
});
(function($){
    $.fn.arrowsCtrl = function(options){
    
        return this.each(function(){
            obj = $(this);
            
            $('.arrUp', obj).click(function(){
                $this = $(this);
                $inpt = $this.parent().parent().contents().find('input');
                var t = parseInt($inpt.val()) + 1;
                $inpt.val('').val(t);
            });
            $('.arrDown', obj).click(function(){
                $this = $(this);
                $inpt = $this.parent().parent().contents().find('input');
                var t = parseInt($inpt.val()) - 1;
                if (t > 0) 
                    $inpt.val('').val(t);
            });
            
        });
    };
})(jQuery);

