// Проверка введенных данных на соответствие буквам или цифрам и длине i символов
function checkFild(id,type,i) {
	switch (type){
		case 'str' :
			expr = /[^а-яА-Яa-zA-Z]/;
			expr2 = /[^а-яА-Яa-zA-Z]/g;
			break;
		case 'dig' :
			expr = /[^0-9]/;
			expr2 = /[^0-9]/g;
			break;
		case 'mail' :
			expr = /[^a-zA-Z0-9@._-]/;
			expr2 = /[^a-zA-Z0-9@._-]/g;
			break;
		case 'pass' :
			expr = /[^a-zA-Z0-9]/;
			expr2 = /[^a-zA-Z0-9]/g;
			break;
	}
	if (id.value.match(expr)) id.value = id.value.replace(expr2, '');
	if (id.value.length>i) id.value = id.value.substr(0, i);
}

var idAjax = 0;
$(document).ready(function() {

// Лидеры продаж на главной странице
	$(".productsIcons a").hover(function() {
        $(".productsIcons a").removeClass("currentProd");
		$(this).addClass("currentProd");
        var href = $(this).attr("href").split("=");
		if (idAjax != href[1]) {
			idAjax = href[1];
			var topCatName = $(this).attr("title").split(":");
			$.post("includes/bestseller.php", { id: idAjax, topcat: topCatName[0] },
				function(data){
					$("#bsHeader").animate({ opacity: 'hide' }, 100, function () {
						$("#bsHeader").html(decodeURIComponent(data)).animate({ opacity: 'show' }, 200);
					});
				}, "html");
		}
	});

// Выпадающее меню
	$("#topmenu td").hover(function() {
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
	});

// Расширенный поиск
	$(".graybox form a").click(function() {
		$.ajax({
			url: "includes/search.php",
			dataType : "html",
			success: function (data) {
				$("#middlecolumn .contentbox").animate({ opacity: 'hide' }, 200, function () {
                        		$("#middlecolumn h1").html('<span>Расширенный поиск</span>');
					$("#middlecolumn .contentbox").html(decodeURIComponent(data)).animate({ opacity: 'show' }, 400);
				});
			}
		});
		return false;
	});

});
