include("fancybox.js");
include("jcarousel.js");

// Закрываем элемент по клику вне его (выборка по классу)
function elemHider(elemClass) {
    $(document).click(function(e){
        if ($(e.target).parents().filter("."+elemClass+":visible").length !== 1 && e.target.className !== elemClass) {
            $("."+elemClass).hide();
        }
    });
}

    function selmodsys(ind, alias){
        icol=$('#icol'+ind+' option:selected').val();
        icol2=$('#icol2'+ind+' option:selected').val();
        location.href='/catalog/icol_'+icol+'_icol2_'+icol2+'_category_'+ind+'_al_'+alias+'.html';
    }
function paytype(mod){
  if(mod==1) {
    $('.pay_cash').addClass('paytype_active');
    $('.pay_bank').removeClass('paytype_active');
    $('#step3').attr("rel","1");
  }
  if(mod==2) {
    $('.pay_bank').addClass('paytype_active');
    $('.pay_cash').removeClass('paytype_active');
    $('#step3').attr("rel","2");
  }  
}
$(document).ready(function() {
	$(".fancy1").fancybox();
    $(".carousel").jCarouselLite({
        btnNext: ".carousel_wrap .teaser_switcher",
		speed: 300,
		start:0,
		circular: true,
		scroll: 1
    });

    // Подсвечиваем товар в каталоге при наведении
    $(".cat_item").hover(
		function () {
			$(this).addClass("cat_item_hover");
		},
		function () {
			$(this).removeClass("cat_item_hover");
		}
    );

    $(".callback").click(function () {
		$("#callbackWindow").fadeIn();
	});
    $("#callbackWindowClose").click(function () {
		$("#callbackWindow").fadeOut();
	});

    $("#WindowClose").click(function () {
		$("#cscol").fadeOut();
	});

    $(".prev_item").click(function () {
		var smallPhoto = $(this).attr('rel1');
		var bigPhoto = $(this).attr('rel2');
		$(".big_photo .fancy1").attr('href', bigPhoto);
		$("#bigpic").attr('src', smallPhoto);
	});

    $(".swt_b").click(function () {
		if (!$(this).hasClass("swt_active")){
			$(".swt_b").removeClass("swt_active");
			$(this).addClass("swt_active");
			if ($(this).hasClass("l")){
				$(".auth").show();
				$(".reg").hide();
			}
			else
			{
				$(".reg").show();
				$(".auth").hide();
			}
		}
	});

    // Скрываем-показываем сортировки и фильтры
	$(".dd_call").click(function () {
		if ($(this).nextAll(".dropdown").is(":visible")) {
			$(this).parents(".c_select").removeClass("sort_zindex");
            $(this).nextAll(".dropdown").hide();
		}
		else
		{
			$(".c_select").removeClass("sort_zindex");
			$(".dropdown").hide();
			$(this).parents(".c_select").addClass("sort_zindex");
            $(this).nextAll(".dropdown").show();
		}
	});

});
