// JavaScript Document
function theRotator() {
	$('div#rotator ul li').css({opacity: 0.0});
	$('div#rotator ul li:first').css({opacity: 1.0});
	setInterval('rotate()',3000);
}
 
function rotate() {	
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
 
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1500);
 
	current.animate({opacity: 0.0}, 1500)
	.removeClass('show');
};
 
$(document).ready(function() {		
	theRotator();
});
 
////////////////////////////////details.tpl tabs
$(function(){
	$('.nav_details_info').delegate('#tab:not(.current)', 'click', function(){
		$(this).addClass('select').siblings().removeClass('select')
		 .parents('.details_info').find('.hide').hide().eq($(this).index()).show();
	});
});
////////////////////////////////details.tpl img product & cm
$(function()  
{  
    $("#product_img").click(function() { 
         $(".details_images,.list_last,.details_right,#sidebar2").hide();  
         $("#product_img_big").show();
		 $('#mainContent').removeClass('main_pos').addClass('main_big_img');
		 $('#prev_img').removeClass('exturls').addClass('exturls_big');
		 
    });  
    $("#product_img_big").click(function() { 
         $("#product_img_big").hide();  
         $(".details_images,.list_last,.details_right,#sidebar2").show();
		 $('#mainContent').removeClass('main_big_img').addClass('main_pos');
		 $('#prev_img').removeClass('exturls_big').addClass('exturls');
    });  
	$(".sizes_block label").click(function() { 
         $(".cm").show();
		 $(".mes_size span").hide();
    });  
});
////////////////////////////////details.tpl .sizechart & price_alarm
$(function() {
 $("#sizeschart").fancybox({'hideOnContentClick': true});	
 $("#inline").fancybox();
});

////////////////////////////////start.tpl jcarousel
function mycarousel_initCallback(carousel)
{
        // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
	        carousel.startAuto(0);
	});
	
	carousel.buttonPrev.bind('click', function() {
	        carousel.startAuto(0);    
	});
	    // Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
		        carousel.stopAuto();
		}, function() {
		        carousel.startAuto();
		})
;};

jQuery(document).ready(function() {
    jQuery('#start-carousel').jcarousel({
	        auto: 5,
			scroll: 4,
			wrap: 'circular',
			animation: 800,
			initCallback: mycarousel_initCallback
	});
});

////////////////////////////////start.tpl opacity
$(document).ready(function(){
$('.sbox').each(function(){
	  $('.sbox .jcarousel-prev, .sbox .jcarousel-next').animate({opacity:'0'},1);
      $(this).mouseover(function(){
          $('.sbox .jcarousel-prev, .sbox .jcarousel-next').stop().animate({opacity:'0.6'},200);
      });
      $(this).mouseout(function(){
          $('.sbox .jcarousel-prev, .sbox .jcarousel-next').stop().animate({opacity:'0'},200);
      });
});
});

$(document).ready(function(){
$('.s_opa').each(function(){
      $(this).mouseover(function(){
          $(this).stop().animate({opacity:'0.5'},300);
      });
      $(this).mouseout(function(){
          $(this).stop().animate({opacity:'1'},300);
      });
});
});

