jQuery(document).ready(function() {
	jQuery("#page_content").jScrollPane({showArrows:true, scrollbarWidth: 13, arrowSize: 15});	
	jQuery('#related_items').jcarousel({
		scroll: 1
	});
	jQuery('#mycarousel').jcarousel({
		vertical: true,
		wrap: 'last',
		scroll: 1,
		auto: 1,
		animation: 3000
	});
	setInterval( "slideSwitch()", 7000 );
    $(".click").click(function () {
    $("#product_feedback_form").toggle();
  });
	/*$(".click").click(function () {
		$("#product_feedback_form").toggle();
	});*/  
	$('#products_image').slides({
		preload: true,
		preloadImage: 'img/loading.gif',
		effect: 'fade',
		crossfade: true,
		slideSpeed: 350,
		fadeSpeed: 500,
		generateNextPrev: true,
		generatePagination: false
	});
	$("a.fancybox").fancybox({						
		"padding" : 20,
		"imageScale" : false, 
		"zoomOpacity" : false,
		"zoomSpeedIn" : 1000,	
		"zoomSpeedOut" : 1000,	
		"zoomSpeedChange" : 1000, 
		"frameWidth" : 700,	 
		"frameHeight" : 600, 
		"overlayShow" : true, 
		"overlayOpacity" : 0.8,	
		"hideOnContentClick" :false,
		"centerOnScroll" : false
	});
	
	$('#t_control a').click(function(event){
			event.preventDefault();
			tc = $(this).attr('href');
			$('#t_control li').removeClass('active');
			$(this).parent('li').addClass('active');		
			$('#t_content div.tab').removeClass('ct');
			$(tc).addClass('ct');
		});
	$(".prd_img img").lazyload();
   
});

function slideSwitch() {
    var $active = $('#slideshow .product_list div.active');
    if ( $active.length == 0 ) $active = $('#slideshow .product_list div.one_product:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow .product_list div.one_product:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');
    
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

