$(document).ready(function(){
	if ($('.search input[type=text]').val() == ""){
		$('.search input[type=text]').val("Поиск").addClass("wait");
	}
	$('.search input[type=text]').bind("focus", function(){
		if ($(this).is(".wait")){
			$(this).removeClass("wait");
			if ($(this).val() == "Поиск"){
				$(this).val("");
			}
		}
	}).bind("blur", function(){
		if ($(this).val() == ""){
			$(this).val("Поиск").addClass("wait")
		}
	});
	
	$('.products .item .image .cont').mouseover(function(){
		if ($(this).find('.product-cover').removeClass('hidden-ex')[0]){
			$(this).find('.product-image').addClass('hidden-ex');
		}
	}).mouseout(function(){
		if ($(this).find('.product-cover').addClass('hidden-ex')[0]){
			$(this).find('.product-image').removeClass('hidden-ex');
		}
	});
	
	$('.product .count .plus').click(function(){
		val = $('.product .count input').val() * 1;
		if (val < 99){
			$('.product .count input').val(val + 1);
		}
	});
	$('.product .count .minus').click(function(){
		val = $('.product .count input').val() * 1;
		if (val > 1){
			$('.product .count input').val(val - 1);
		}
	});
	
	$('.product .small-image a').click(function(){
		$('.product .full-image img').attr('src', $(this).attr('href'));
		$(this).parent().parent().find(".small-image").removeClass("active");
		$(this).parent().addClass("active");
		return false;
	});
	$('.product .colors .color-switcher').click(function(){
		$(this).parent().find(".color-switcher").removeClass("selected");
		$(this).addClass("selected");
		var color = $(this).attr("id").substr("color-switcher-".length).toUpperCase();
		$('.product .small-image.colored').addClass("hidden-ex");
		$('.product .small-image.img-color-' + color).removeClass("hidden-ex").eq(0).find("a").click();
		$('#option-color').val($(this).attr("title"));
	});
});
