$(document).ready(function () {
	//Корзинка мимо 
	$.post('/cabinet/get_user/ajax/1/', {}, 
		function(data){
			if(data){
				$('#logoutlink').show();
				$('#linkcabinet').text('Личный кабинет');
				}
			else{
				$('#logoutlink').hide();
				$('#linkcabinet').text('Регистрация | Войти');
				}
		}
	);
	
	//Красивые Alert'ы
	window._alert = window.alert;
    window.alert = function(message) {
        $.pnotify({
            pnotify_title: 'Системное сообщение',
            pnotify_text: message,
            pnotify_delay: 5000
        });
    };

    $(".header_menu td:not(.side)").hover(function(){
        $(this).addClass('active');
    }, function(){
        $(this).removeClass('active');
    });

    $(".brands_block li").hover(function(){
        $(this).addClass('hover');
    }, function(){
        $(this).removeClass('hover');
    });
    $(".brands_list li").hover(function(){
        $(this).addClass('hover');
    }, function(){
        $(this).removeClass('hover');
    });

    $('#main_banner').cycle({
        fx:      'scrollHorz',
        speed:    1000,
        timeout:  6000,
        pager:   '.tv_pager',
        next: '.banner_controls #next',
        prev: '.banner_controls #prev'
    });

    $('#brands_block').myCarousel({
        btnNext: '.brands_block_outer .next',
        btnPrev: '.brands_block_outer .prev',
        el_width: 108,
        visible: 8,
        rotateBy: 3,
        speed:1800
    });

   /* $('.cat_item .parameters .size, .cart div.size').each(function(){
        $(this).addClass('jNice');
        $(this).jNice();
    });*/

    /*$('form').not('.no_jNice').each(function(){
        $(this).addClass('jNice');
        $(this).jNice();
    });*/
    $('.jNicer').each(function(){
        $(this).jNice();
    });

    //$('*').randomColorize();

    $('.color_f.active a').click(function(){
        return false;
    });

    $(".cart .size").each(function(){
        var sel = $(this).find(".jNiceSelectWrapper");
        var r = $(this).attr('rel');
        sel.css("z-index", 9999-r);
    });

    $("#main_banner").append("<div class='main_banner_mask'></div>");
    $(".promo_banners a").each(function(){
        $(this).append("<div class='promo_banner_mask'></div>");
    });


    $(".cabinet .forms .is_empty").each(function(){
        $(this).hide();
    });

    $("#main_plusaddress").click(function(){
        $("#main_plusaddress_hr").hide();
        $(this).parent(".plus_block").hide();
        return false;
    });
    $("#addresses .plusadress").click(function(){
        $(this).hide();
        return false;
    });

    $("a.current").click(function(){
        return false;
    });
    
    $("a.subfoto").click(function(){
        $(".photo_gallery").html("<img src='"+this.href+"'>");
        return false;
    });

    var w = $(window).width();
    $("#popup_window").css({'left': w/2-300});

    var intervalID;
    jQuery(".MagicZoomPlus").hover(function () {
        var popup = jQuery(this).parent().find(".MagicZoomHint");
        popup.hide();
    }, function(){
            var popup = jQuery(this).parent().find(".MagicZoomHint");
            popup.show();
            clearInterval(intervalID);
    });

});
