jQuery.noConflict();
jQuery(document).ready(function(){
    /*BEGIN Nivo ------------------------------------------------------------*/
    jQuery('#slider').nivoSlider({
        effect:'sliceDown'
    });
    jQuery('#slider-mal').nivoSlider({
        effect:'sliceDown'
    });
    jQuery("._small_pic").parent().not(".current").click(function() {
        jQuery(".small_pic").parent().removeClass("current");
        jQuery(this).addClass("current");
        href = jQuery(this).attr("href");
        jQuery('.img-select-color img').attr("src", jQuery(this).find("img").attr("src"));
        jQuery('.name-select-color').html(jQuery(this).attr("title"));
        jQuery(".big_pic").parent().attr("href", href);
        jQuery(".big_pic").hide().attr("src", href).show();
        return false;
    });
    /*END Nivo ------------------------------------------------------------*/
    /*BEGIN slider ------------------------------------------------------------*/
    jQuery('#mycarousel').jcarousel({
        scroll: 4,
        vertical: false,
        auto: 1000
       });
    jQuery('#seotext ul').jcarousel({
        scroll: 1,
        auto: 1000
       });
    jQuery('#mycarousel-mal').jcarousel({
        scroll: 5,
        vertical: false,
        auto: 1000
       });


	 jQuery('#mycarousel-cities').jcarousel({
        scroll: 16,
        vertical: true,
        auto: 1000
       });
     jQuery('.list_cities .jcarousel-container').hide();

    /*END slider ------------------------------------------------------------*/
    jQuery('.collection-left-menu .red-title').toggle(function(){
            //jQuery(this).parents('.collection-left-menu').addClass("collection-show");
            jQuery(this).parents('.collection-left-menu').find('ul').slideDown();
        },function(){
            //jQuery(this).parents('.collection-left-menu').removeClass("collection-show");
            jQuery(this).parents('.collection-left-menu').find('ul').slideUp();
    });
    jQuery('.collection-left-menu ul li.active').parents('.collection-left-menu').addClass('collection-show');

    jQuery("a.zoom-img").fancybox();
    /*BEGIN ajax ------------------------------------------------------------*/
    jQuery('#shpons li a').live("click",function() {//catalog page
        var target_obj=jQuery(this);
        var PID = target_obj.attr("pid");
        var COL_ID = target_obj.parent().index();
        var TON_ID = jQuery('#active_ton').attr('ton_id');
        var TON_COUNT = jQuery('#tonirovki li').size();
		jQuery('#shpons .border-green').removeClass('border-green');
		jQuery(this).addClass('border-green');
        jQuery('#active_color').attr('color_id',COL_ID);

        jQuery('#active_color').slideDown();

        var shpon_img=target_obj.find('img').attr('src');
        jQuery('#shpon_info_img').html('<img src="'+shpon_img+'" />');

        var shpon_title=target_obj.attr('title');
        jQuery('#shpon_info_text').html(shpon_title);

        jQuery.ajax({
            type: "POST",
            url: '/index-ajax.php',
            data: {q: 'assets/snippets/ajax/catalog.php', 'col_id': COL_ID, 'ton_id': TON_ID, 'ton_count': TON_COUNT, 'pid': PID},
            cache: false,
            success: function(html){
                jQuery("#dveri").html(html);
            }
        });
        return false;
    });

    jQuery('#tonirovki li a').live("click",function() {//catalog page
        var target_obj=jQuery(this);
        var PID = target_obj.attr("pid");
        var COL_ID = jQuery('#active_color').attr('color_id');
        var TON_ID = target_obj.parent().index();
        var TON_COUNT = jQuery('#tonirovki li').size();
		jQuery('#tonirovki .border-green').removeClass('border-green');
		jQuery(this).addClass('border-green');

        jQuery('#active_ton').attr('ton_id',TON_ID);

        jQuery('#active_ton').slideDown();

        var shpon_img=target_obj.find('img').attr('src');
        jQuery('#ton_info_img').html('<img src="'+shpon_img+'" />');

        var shpon_title=target_obj.attr('title');
        jQuery('#ton_info_text').html(shpon_title);

        jQuery.ajax({
            type: "POST",
            url: '/index-ajax.php',
            data: {q: 'assets/snippets/ajax/catalog.php', 'col_id': COL_ID, 'ton_id': TON_ID, 'ton_count': TON_COUNT, 'pid': PID},
            cache: false,
            success: function(html){
                jQuery("#dveri").html(html);
            }
        });
        return false;
    });

    jQuery('#product_shpons li a').live("click",function() {//product page
        var target_obj=jQuery(this);
        var PID = target_obj.attr("pid");
        var COL_ID = target_obj.parent().index();
        var TON_ID = jQuery('#active_ton').attr('ton_id');
        var TON_COUNT = jQuery('#product_tonirovki li').size();
		jQuery('.border-green').removeClass('border-green');
		jQuery(this).addClass('border-green');
        jQuery('#active_color').attr('color_id',COL_ID);

        jQuery('#active_color').slideDown();

        var shpon_img=target_obj.find('img').attr('src');
        jQuery('#shpon_info_img').html('<img src="'+shpon_img+'" />');

        var shpon_title=target_obj.attr('title');
        jQuery('#shpon_info_text').html(shpon_title);


        jQuery.ajax({
            type: "POST",
            url: '/index-ajax.php',
            data: {q: 'assets/snippets/ajax/product.php', 'col_id': COL_ID, 'ton_id': TON_ID, 'ton_count': TON_COUNT, 'pid': PID},
            cache: false,
            success: function(html){
                jQuery("#dver").attr('src',html);
                jQuery(".zoom-img").attr('href',html);
            }
        });


        return false;
    });

    jQuery('#product_tonirovki li a').live("click",function() {//product page
        var target_obj=jQuery(this);
        var PID = target_obj.attr("pid");
        var COL_ID = jQuery('#active_color').attr('color_id');
        var TON_ID = target_obj.parent().index();
        var TON_COUNT = jQuery('#product_tonirovki li').size();

        jQuery('#active_ton').attr('ton_id',TON_ID);

        jQuery('#active_ton').slideDown();

        var shpon_img=target_obj.find('img').attr('src');
        jQuery('#ton_info_img').html('<img src="'+shpon_img+'" />');

        var shpon_title=target_obj.attr('title');
        jQuery('#ton_info_text').html(shpon_title);


        jQuery.ajax({
            type: "POST",
            url: '/index-ajax.php',
            data: {q: 'assets/snippets/ajax/product.php', 'col_id': COL_ID, 'ton_id': TON_ID, 'ton_count': TON_COUNT, 'pid': PID},
            cache: false,
            success: function(html){
                jQuery("#dver").attr('src',html);
                jQuery(".zoom-img").attr('href',html);
            }
        });


        return false;
    });
    /*END ajax ------------------------------------------------------------*/

    jQuery('.feedback_link').live("click",function() {
        jQuery('.black-bg').show();
        return false;
    });

    jQuery('.black-bg .close').live("click",function() {
        jQuery('.black-bg').hide();
        return false;
    });

    if(jQuery('.black-bg .errors').text()!='' || jQuery('.black-bg h3').size()>0 || jQuery('.black-bg h4').next('p').size()>0) {
        jQuery('.black-bg').show();
    }

    jQuery('.up_button_text a').live("click",function() {
        jQuery('html,body').animate({scrollTop : 0},'slow');
        return false;
    });
    /*BEGIN map ------------------------------------------------------------*/
    jQuery('#city_list li a, #city_list_other li a').live("click",function() {
        jQuery('#map div').removeClass('.static');
    });

    jQuery('#city_list li a, #city_list_other li a, #map a').live("click",function() {
        jQuery('#map a').removeClass('active');
        jQuery('#map a[id='+jQuery(this).attr('id')+']').addClass('active');
    });

    jQuery('#city_list li a, #city_list_other li a, #map a').live("click",function() {
        var target_obj=jQuery(this);
        jQuery('#map div').fadeOut(100);
        var rel=target_obj.attr('rel');
        if(rel) {
            jQuery('#map div').removeClass('static');
            jQuery('#map div.'+rel).fadeIn(100).addClass('static');
        }
        var ID = target_obj.attr("id");
        jQuery('#city_list li').removeClass('active');
        jQuery('#city_list a[id='+ID+']').parent().addClass('active');
        jQuery('#city_list_other li').removeClass('active');
        jQuery('#city_list_other a[id='+ID+']').parent().addClass('active');
        jQuery.ajax({
            type: "POST",
            url: '/index-ajax.php',
            data: {q: 'assets/snippets/ajax/map.php', 'id': ID},
            cache: false,
            success: function(html){
                jQuery("#map_info").html(html);
            }
        });
        jQuery('html,body').animate({scrollTop : 800},'slow');
        return false;
    });

    jQuery('#map a').hover(function() {
        var target_obj=jQuery(this);
        var oblast=target_obj.attr("rel");
        jQuery('#map div.'+oblast).not('.static').stop(false, true).fadeIn(100);
    },function() {
        var target_obj=jQuery(this);
        var oblast=target_obj.attr("rel");
        jQuery('#map div.'+oblast).not('.static').stop(false, true).fadeOut(100);
    }
    );

    jQuery('.list_cities .open_button').live("click",function() {
        jQuery('.list_cities .jcarousel-container').slideToggle();
    });
    /*END map ------------------------------------------------------------*/

    jQuery('.yams_current_text').html(jQuery('.header-bottom-menu .lang .yams_current').html());
    jQuery('.yams_choose_lang_statement a').live("click",function() {
        jQuery('.yams_list').slideToggle();
        return false;
    });


    /*jQuery('.socila_button').live("click",function() {
        jQuery('.soc').animate({
            width: '108px'
          }, 500);
          return false;
    });*/


});
