var xmlHttp;
var idname;
var path = 'http://softorg.com.ua/sewing';

function get_cat(nm)
{
// 	alert("sadfas");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var url=path+"/ajax.php?act=get_cat&name="+nm;
	idname="cat";
 	document.getElementById("subcat").innerHTML = "";
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function get_subcat(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var nm = document.getElementById("firm").value;
	var url=path+"/ajax.php?act=get_subcat&id="+id+"&name="+nm;
// 	alert('as')
	idname="subcat";
// 	document.getElementById(idname).innerHTML = '<img src="'+path+'images/loader.gif" alt="loading.." title="loading.."/>';
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function add_basket(id,count)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var url=path+"/ajax.php?act=get_basket&id="+id+"&count="+count;
	idname="basket";
	document.getElementById(idname).innerHTML = '<img src="'+path+'images/loader.gif" alt="loading.." title="loading.."/>';
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function add_basket2(id,count,types)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var url=path+"/ajax.php?act=get_basket2&id="+id+"&count="+count+"&type="+types;
	idname="basket";
	document.getElementById(idname).innerHTML = '<img src="'+path+'images/loader.gif" alt="loading.." title="loading.."/>';
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById(idname).innerHTML = xmlHttp.responseText 
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
