function getXmlHttp(){
  var http;
  try {
    http = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      http = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      http = false;
    }
  }
  if (!http && typeof XMLHttpRequest!='undefined') {
    http = new XMLHttpRequest();
  }
  return http;
}



function Search(){
var area=document.getElementById('find').value;
location.replace("/search/"+area+"/");

}



function RatingSet(value, id){
	//document.getElementById("rating_"+id).innerHTML="<img src='/img/theme/loader.gif'>";
var adress="../../parts/rating.php?addrating=" + value + "&id=" + id; 
var breq = getXmlHttp();
breq.onreadystatechange = function() {   
if(breq.readyState==4){if(breq.status==200){
	document.getElementById("rating_"+id).innerHTML=breq.responseText;
}}} 
breq.open('GET', adress, true); breq.send(null); return false}


function recountFinalPrice(id,amount){
	document.getElementById("final_price_"+id).innerHTML="<img src='/img/theme/loader.gif'>";
var adress="../../parts/recount_price.php?id=" + id +"&amount="+amount; 
var breq = getXmlHttp();
breq.onreadystatechange = function() {   
if(breq.readyState==4){if(breq.status==200){
	document.getElementById("final_price_"+id).innerHTML=breq.responseText;
}}} 
breq.open('GET', adress, true); breq.send(null); return false}




function AddToCart(product_id,bt){ 
	var amount=document.getElementById('ProductAmount_'+product_id).value;
	var adress="../../parts/mod.basket.php?work=add&product_id="+product_id+"&amount="+amount;

	var breq = getXmlHttp();
		breq.onreadystatechange = function() {   
		if (breq.readyState == 4) { 
			if(breq.status == 200) { 
			//document.getElementById('buy_button_'+product_id).innerHTML=breq.responseText;
document.getElementById('AddBt_'+product_id).innerHTML='<input type="button" value="Добавлено" />';				
				AutoRefleshBasket();
			}
		}
	}
	breq.open('GET', adress, true); 
	breq.send(null); 

}


function AutoRefleshBasket(){
var adress="../../parts/mod.basket.php?work=reflesh";
var breq = getXmlHttp();
breq.onreadystatechange = function() {   
if(breq.readyState==4){if(breq.status==200){
	document.getElementById('basket').innerHTML=breq.responseText;
}}} 
breq.open('GET', adress, true); breq.send(null);}
//setInterval(AutoRefleshBasket, 1500);

function ClearBasket(){
var adress="../../parts/mod.basket.php?work=clear";
var breq = getXmlHttp();
breq.onreadystatechange = function() {   
if(breq.readyState==4){if(breq.status==200){
	document.getElementById('basket').innerHTML=breq.responseText;
}}} 
breq.open('GET', adress, true); breq.send(null); return false}








function getRadioGroupValue(radioGroupObj){
for (var i=0; i < radioGroupObj.length; i++)
if (radioGroupObj[i].checked) return radioGroupObj[i].value;
return null;}


function OprosSend(){
	var sel = getRadioGroupValue(document.forms["module_opros"].opros_golos);
var adress="../../parts/mod.opros.php?work=send&id_ans="+sel;
var breq = getXmlHttp();
breq.onreadystatechange = function() {   
if(breq.readyState==4){if(breq.status==200){
	document.getElementById('module_opros').innerHTML=breq.responseText;
}}} 
breq.open('GET', adress, true); breq.send(null); return false}

