$(document).ready(function() {
	$('ul.product-list li, ul.wide-grid li').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	$('ul.product-list li, ul.wide-grid li').click(function() {
		var productLocation = $('a.product-image', $(this)).attr('href');
		document.location = productLocation;
	});
	
	$("#slider").slider({
		range: true,
		min: 0,
		max: 1000,
		values: [200, 800],
		slide: function(event, ui) {
			$('#slide_min').html(ui.values[0]);
			$('#slide_max').html(ui.values[1]);
		}
	});
	
	$('#slide_min').html($('#slider').slider("values", 0));
	$('#slide_max').html($('#slider').slider("values", 1));
	
	//$("select, input:checkbox, input:radio, input:file").uniform();
	
	// Promo
	$('.promo img').each(function(index) {
		if (index > 0) {
			$(this).css('opacity', 0);
		}
	});
	
	$('.promo .controls li:first-child a').addClass('active');
	
/*	$('.promo-txt .txt').each(function(index) {
		if (index > 0) {
			$(this).hide();
		}
	});*/
	
	// Cliquerdeclique
	$('.promo .controls li a').click(function() {
		var index = $(this).parent().index();
	
		$('.promo img:visible').animate({ opacity: 0 }, 400);		
		$('.promo img:nth-child(' + (index + 1) + ')').animate({ opacity: 1 }, 400);
		
		$('.promo .controls li a').removeClass('active');
		$(this).addClass('active');
		
		var new_left = 0 - (index * 669);
		
		$('.promo .promo-txt').animate({ left: new_left }, 400);
		
		return false;
	});
	
	// Odd elements
	$("ul.submenu > li:nth-child(2n+1)").addClass('odd');
	
	// Tabs
	$(".tab-container .tab").each(function(index) {
		if (index > 0)
		{
			$(this).hide();
		}
	});
	
	$(".tabs li:first-child").addClass('active');
	
	$(".tabs a").click(function() {
		var index = $(this).parent().index();
		
		$(".tab-container .tab").hide();
		$(".tab-container .tab:nth-child(" + (index + 1) +")").show();
		
		$('li', $(this).parent().parent()).removeClass('active');
		$(this).parent().addClass('active');
		
		return false;
	});
	
	// Product buttons
	$('#add_to_cart').click(function() {
		var form_name = $(this).attr('rel');
		
		document.forms[form_name].submit();
		
		return false;
	});
	
	// Image picker
	$('ul.image-picker li a').click(function() {
		var new_img = $('img', $(this)).attr('src');

		$('.image img').attr('src', new_img);
		
		return false;
	});
});
