//создание XMLHttpRequest
function xml_req(){
  var http_request = false;
         if(window.XMLHttpRequest)
         {
                   http_request = new XMLHttpRequest();
                   if(http_request.overrideMimeType)
                   {
                            http_request.overrideMimeType('text/xml');
                   }
         }
         else if (window.ActiveXObject)
         {
                   try
                   {
                            http_request = new ActiveXObject("Msxml2.XMLHTTP");
                   }
                   catch (e)
                   {
                            try
                            {
                                      http_request = new ActiveXObject("Microsoft.XMLHTTP");
                            }
                            catch (e) {}
                   }
         }
		 return http_request;
}

function basket(id) {
if(obj=document.getElementById('price_atribut_chnger')){
var price=obj.options[obj.selectedIndex].value;
a=price.split("--");
if (a[0]==""){alert ("нужно выбрать размер");}
else{
window.open("/modules/basket/index.php?product="+id+"&price="+a[1]+"&atribut="+a[0],'basket','top=150, left=200, menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, width=300, height=100');
location.reload();}
}
else{
window.open("/modules/basket/index.php?product="+id,'basket','top=150, left=200, menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, width=300, height=100');
location.reload();
}
}
function chng_photo(img){
var photo=document.getElementById('product_photo');
var main_photo=document.getElementById('main_photo');
main_photo.href="/upload/catalog/"+img;
photo.src="/upload/catalog/"+img;
}
function del_basket_item(id) {
window.open("/modules/basket/del.php?product="+id,'del_basket_item','top=150, left=200, menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, width=200, height=100');
location.reload();
}
function summa(kol, price, id){
var sum="sum"+id;
var kol=kol.value;
sum=document.getElementById(sum);
price=Number(price);
kol=Number(kol);
sum1=kol*price;
sum.value=sum1;
}
function chng_price_atrib(){
var obj=document.getElementById('price_atribut_chnger');
var price=obj.options[obj.selectedIndex].value;
a=price.split("--");
price=document.getElementById('price_atribut')
if (a==""){price.innerHTML="";}
else {price.innerHTML=a[1];}
}
function change_filter(elem){
name=elem.name;
value=elem.value;
var tovar_area=document.getElementById('tovar');
var cat=document.getElementById('cat').value;
var podcat=document.getElementById('podcat').value;
var proizvod=document.getElementById('proizvod').value;
var price=document.getElementById('price').value;
if (cat=="no"&&podcat=="no"&&proizvod=="no"&&price=="no"){
	location.reload();
}
else{
tovar_area.innerHTML="";
tovar_area.innerHTML="<div style='width:762px; margin:10px 0; text-align:center;'>Идет поиск</div><div style='width:762px; text-align:center;'><img src='/images/site/search.gif' /></div>";}

if (name=='cat'){
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4) document.getElementById("result").innerHTML=req.responseText;}
req.open(null,"modules/catalog/podcat.php",true);
req.send({categories_id:value});}

http_request=xml_req();
    http_request.onreadystatechange = function()
    {
        if(http_request.readyState == 4)
        {
            if(http_request.status == 200)
            {
                tovar_area.innerHTML=http_request.responseText;
            }
        }
    }
    http_request.open('POST', 'modules/catalog/search.php', true);
    http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    http_request.send('cat='+cat+'&podcat='+podcat+'&proizvod='+proizvod+'&price='+price);
}
