﻿jQuery(document).ready(function() {

    if (jQuery.browser.opera) {
           jQuery("body").addClass('opera');
       }
	   
	     if(jQuery('.xxxx').length) {
      
                         alert('Спасибо что оформили заказ в интернет-магазине Etiket-pistolet.com.ua. Ваш заказ находится в обработке. Ожидайте звонка менеджера для уточнения деталей оплаты и доставки.')
                        window.location = "http://www.etiket-pistolet.com.ua/";

    }



    var currentTab = 0;
   function openTab(clickedTab) {
   var thisTab = jQuery(".tabbed-box .tabs a").index(clickedTab);
   jQuery(".tabbed-box .tabs li a").removeClass("active");
   jQuery(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
   jQuery(".tabbed-box .tabbed-content").hide();
   jQuery(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
   currentTab = thisTab;
}
jQuery(document).ready(function() {
    jQuery(".tabbed-box .tabs li a").click(function() {
      openTab(jQuery(this)); return false;
   });
   jQuery(".tabbed-box .tabs li a:eq("+currentTab+")").click() ;
});


    var currentTab1 = 0;
      function openTab1(clickedTab1) {
      var thisTab1 = jQuery(".tabbed-box1 .tabs a").index(clickedTab1);
      jQuery(".tabbed-box1 .tabs li a").removeClass("active");
      jQuery(".tabbed-box1 .tabs li a:eq("+thisTab1+")").addClass("active");
      jQuery(".tabbed-box1 .tabbed-content").hide();
      jQuery(".tabbed-box1 .tabbed-content:eq("+thisTab1+")").show();
      currentTab1 = thisTab1;
   }
   jQuery(document).ready(function() {
       jQuery(".tabbed-box1 .tabs li a").click(function() {
         openTab1(jQuery(this)); return false;
      });
      jQuery(".tabbed-box1 .tabs li a:eq("+currentTab1+")").click() ;
   });

    jQuery('.cur_cat').parent().addClass('biz');

     function ResizeCSS(){
    	if(jQuery('body').width() < 1180){

		jQuery('#wrapper').css("padding","0 10px");
		jQuery('#wrapper').css("min-width","980px");
		jQuery('.re').css("width","60%");
		jQuery('.prplay').css("margin-right","8%");
        }
        if(jQuery('body').width() > 1180){
			jQuery('#wrapper').css("padding","0 50px");
            jQuery('.re').css("width","63.5%");
            jQuery('.prplay').css("margin-right","3.8%");
        }
          if(jQuery('body').width() > 1350){
             jQuery('.prplay').css("margin-right","6.1%");    
          }
    }
	ResizeCSS();
		jQuery(window).resize(function(){
        ResizeCSS();
        });

     /* Carousel */
       jQuery(window).bind('resize', function() {
           set_sizes();
           correct_left();
       });
       carousel = jQuery('div.carousel ul.elements');
       carousel_item = jQuery('div.carousel ul.elements li.c_item');
       jQuery('div.carousel ul.elements li.c_item:first').addClass('curent');

       for (var i = 0; i < carousel_item.length; i++) {
           carousel_item.eq(i).attr('rel', i);
       }

       function set_sizes() {
           win_width = jQuery('.car-wrap').width(); // Window Width
           el_width = win_width/4; // Carousel Element Width (30%)
           el_length = jQuery('li.c_item').length; // Carousel Element Length
           c_width = el_length * el_width; // Carousel Width
           carousel.width(c_width);
           carousel_item.width(el_width);
       }

       function correct_left() {
           cur_num = jQuery('li.curent').attr('rel');
           if (cur_num > 0) {
               c_left = cur_num * el_width;
               carousel.css('left', -c_left + 'px');
           }
           else {
               return false;
           }
       }

       function move_left() {
           cur_left_temp = carousel.css('left');
           cur_left = parseInt(cur_left_temp.replace('px', ''));
           carousel.stop().animate({left:cur_left - el_width + 'px'});
           jQuery('li.curent').next('li').addClass('curent').prev('li').removeClass('curent');

       }

       function move_right() {
           cur_left_temp = carousel.css('left');
           cur_left = parseInt(cur_left_temp.replace('px', ''));
           carousel.stop().animate({left:cur_left + el_width + 'px'});
           jQuery('li.curent').prev('li').addClass('curent').next('li').removeClass('curent');

       }

       function hide_arrow() {
           if (jQuery('div.carousel ul.elements li.c_item:first').hasClass('curent')) {
               jQuery('.c_arrow_left').hide();
           }
           else {
               jQuery('.c_arrow_left').show();
           }
           if (jQuery('div.carousel ul.elements li.c_item:last').prev().prev().prev().hasClass('curent')) {
               jQuery('.c_arrow_right').hide();
           }
           else {
               jQuery('.c_arrow_right').show();
           }
       }
       jQuery('.c_arrow_right').click(function() {
           jQuery(this).stop();
           set_sizes();
           move_left();
           hide_arrow();
       });
       jQuery('.c_arrow_left').click(function() {
           jQuery(this).stop();
           set_sizes();
           move_right();
           hide_arrow();
       });
       set_sizes();
       hide_arrow();
       /* END Carousel */

    jQuery('.cur_cat').parent().parent().addClass('current_cat');

    if (jQuery('li').hasClass('.current_cat'))  {
    var ack11 = jQuery('.current_cat a').html();
       //jQuery(ack11).addClass('title').insertBefore(jQuery('.post'));

        jQuery('.kart').append(ack11);

        jQuery('.kart .category').addClass('title');

    }

    if(jQuery('ul').hasClass('SubCategories')){
       var sub22 = jQuery('.current_cat .SubCategories').html();

      jQuery('.SubCategories').remove();
       jQuery('.kart').append(sub22); 
     //  jQuery(sub22).insertBefore(jQuery('.post')).wrapAll('<ul class="sbm clearfix"></ul>');
    jQuery('.kart li').wrapAll('<ul class="sbm clearfix"></ul>');
    }





    jQuery('<div class="clr"></div>').insertBefore(jQuery('.post'));
       if (jQuery('.wpsc_variation_forms select').hasClass('wpsc_select_variation')) {
        jQuery('.shd').addClass('nopad');
    }


    jQuery(".imagecol a").hover(
  function () {
    jQuery(this).parent().next().find('.wpsc_product_title').addClass("hover");
  },
  function () {
    jQuery(this).parent().next().find('.wpsc_product_title').removeClass("hover");
  }
);

 jQuery(".prodtitles a").hover(
  function () {
    jQuery(this).parent().parent().prev().find('a').addClass("hover");
  },
  function () {
    jQuery(this).parent().parent().prev().find('a').removeClass("hover");
  }
);

    if(jQuery.browser.msie && jQuery.browser.version=="6.0") {

  if (jQuery.cookie('ieshown')==null) {
    jQuery('#upie6').show();
  }

  else if (jQuery.cookie('ieshown')=='true') {
    jQuery('#upie6').hide();
  }

  jQuery('.clox').click(function(){
    jQuery.cookie('ieshown','true',{ expires: 1 });
    jQuery('#upie6').hide();
  });

  jQuery('#upie6 a').click(function(){
    jQuery.cookie('ieshown','true',{ expires: 1 });
    jQuery('#upie6').hide();
  });
}

    jQuery('.wpsc_checkout_forms textarea').empty();
    jQuery('.wpsc_checkout_forms input:text').attr('value','');


});
