
function Search()
{
	flag=1;
	category=document.search.category.options[document.search.category.selectedIndex].value;
	brand=document.search.brand.options[document.search.brand.selectedIndex].value;
	if (category==0 && brand==0)
	{
		alert("Не выбраны критерии поиска: товар или торговая марка")
		flag=0;
	}
	if (flag)
	document.search.submit();
}
function Checks(mode)
{
	if (mode==1) document.search.female.checked=false;
	if (mode==2) document.search.male.checked=false;
}
function NewSelect(mode)
{
	category=document.search.category.options[document.search.category.selectedIndex].value;
	brand=document.search.brand.options[document.search.brand.selectedIndex].value;
	url="/misc/search_ind.php?category="+category+"&brand="+brand+"&mode="+mode;
	goAjax(url);
}
function goAjax(url)
{
//	alert(url);
    http.open("get", url);
   	http.onreadystatechange = handleResponse;
    http.send(null);
}

var http = createRequestObject();
function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
	ro = new ActiveXObject("Microsoft.XMLHTTP");
    else ro = new XMLHttpRequest();
    return ro;
}


function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
        var update = new Array();
        if(response.indexOf('|' != -1))
		{
            update = response.split('|');
//			alert(update[0]+"-"+update[1]);
       	    document.getElementById(update[0]).innerHTML = update[1];
		}
    }
}
function SENT()
{
	flag=1;
	if (document.Opinion.names.value=='')
	{
		alert('Не заполнено поле "Имя"');
		document.Opinion.names.focus();
		flag=0;
		return;
	}
	if (document.Opinion.mess.value=='')
	{
		alert('Поле "Вопрос" пустое');
		document.Opinion.mess.focus();
		flag=0;
		return;
	}
	if (document.Opinion.pos.value=='')
	{
		alert('Введите проверочное число');
		document.Opinion.pos.focus();
		flag=0;
		return;
	}
	if (flag==1)
	{
		document.Opinion.sent.value=1;
		document.Opinion.submit();
	}
}
function ShowAll(cat_id)
{
	url="/misc/alltovars.php?cat_id="+cat_id;
	goAjax(url);
}
function Show(curpage)
{
	url="/misc/search.php?curpage="+curpage;
	goAjax(url);
}

