jQuery(document).ready(function(){
	// jQuery random function START
	jQuery.extend({
		random: function(X) {
			return Math.floor(X * (Math.random() % 1));
		},
		randomBetween: function(MinV, MaxV) {
		  return MinV + jQuery.random(MaxV - MinV + 1);
		}
	});
	// jQuery random function END
	
	jQuery('body').addClass('bg_' + jQuery.randomBetween(1, 5));
	
	jQuery('#main_top_cycle div.content').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 4000,
		prev:   '#main_top_cycle a.prev',
		next:   '#main_top_cycle a.next'
	});
	
	jQuery('#main_four .block span.cycle').cycle({
		fx:     'fade', 
		speed:  'slow', 
		timeout: 4000,
		prev:   '#main_four .block span.prev',
		next:   '#main_four .block span.next'
	});
	
	jQuery('#main_four .block span.prev, #main_four .block span.next').hover(
		function() {jQuery(this).parents('.block').find('span.text').css({'text-decoration' : 'none'})},
		function() {jQuery(this).parents('.block').find('span.text').css({'text-decoration' : ''})}
	);
	
	// Magic =)
	jQuery('#list a.block').hoverIntent(function() {
		if (!jQuery(this).children('span.action').length) {
			jQuery(this).animate({backgroundColor:'#FFF'}, 'slow');
		};
		var h = jQuery(this).find('span.info').height();
		jQuery(this).find('span.info').fadeIn('slow').next('span.action').animate({bottom: h + 25 + 'px'}, 500).next('span.price').animate({bottom: h + 67 + 'px'}, 500);
	}, function() {
		if (!jQuery(this).children('span.action').length) {
			jQuery(this).animate({backgroundColor: '#EEE'}, 'slow');
		};
		jQuery(this).find('span.info').fadeOut('slow').next('span.action').animate({bottom:'6px'}, 500).next('span.price').animate({bottom:'48px'}, 500);
	});
	
	jQuery('#product a.pic').flyout({
		inOpacity:0,
		fullSizeImage:true,
		inSpeed:1000
	});
	
	jQuery('#product ul.thumbs a').click(function() {
		jQuery('#product a.pic').attr('href', jQuery(this).attr('title'))
		jQuery('#product a.pic img').attr('src', jQuery(this).attr('href'));
		return false;
	});
	
	jQuery('#similar div.content div.carousel').jCarouselLite({
        btnPrev: "#similar div.content div.arrows a.prev",
        btnNext: "#similar div.content div.arrows a.next",
		visible: 5,
		scroll: 1
    });
});
