var xml_http = getXMLHttp();

function addToCart(tid,amount) {
	
	xml_http.open("GET","kosar.php?act=add&id="+tid+"&amount="+amount);
	 xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
	xml_http.onreadystatechange = addHandler;
	xml_http.send(null);
	
}

function addHandler() {
	if (xml_http.readyState == 4) {	
		listok = 1;
	}	
}


function setInCart(tid,amount) {
	
	xml_http.open("GET","kosar.php?act=mod&id="+tid+"&amount="+amount);
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = setHandler;
	xml_http.send(null);
	
}

function setHandler() {
	if (xml_http.readyState == 4) {	
		listok = 1;
	}	
}

function delFromCart(tid) {
	
	xml_http.open("GET","kosar.php?act=torol&id="+tid);
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = delHandler;
	xml_http.send(null);
	
}

function delHandler() {
	if (xml_http.readyState == 4) {	
		listok = 1;
	}	
}


function clearCart(tid,amount) {
	xml_http.open("GET","kosar.php?act=urit");
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = clearHandler;
	xml_http.send(null);	
}

function clearHandler() {
	if (xml_http.readyState == 4) {	
		listok = 1;
	}	
}


function getList() {
	xml_http.open("GET","kosar.php?act=listaz");
	 xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = getListHandler;
	xml_http.send(null);
}

function getListHandler() {
	if (xml_http.readyState == 4) {	
		document.getElementById("ajaxresp").innerHTML = xml_http.responseText;
	}	
}


function getHtmlList() {
	
	xml_http.open("GET","kosar.php?act=htmllistaz");
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = getHtmlListHandler;
	xml_http.send(null);
	
}

function getHtmlListHandler() {
	if (xml_http.readyState == 4) {	
		document.getElementById("kosar").innerHTML = xml_http.responseText;
	}	
}


function orderStep(step) {
	xml_http.open("GET",encodeURI("rendeles.php?step="+step));
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	 xml_http.setRequestHeader("Accept-Charset","UTF-8");
	xml_http.onreadystatechange = orderHandler;
	xml_http.send(null);	
}

function orderHandler() {
	if (xml_http.readyState == 4) {	
		document.getElementById("lepestart").innerHTML = xml_http.responseText;
		listok = 1;
	}	
}

function orderSave(sznev,szirszam,szvaros,szutca,pnev,pirszam,pvaros,putca,tel,email,egyeb,egyezik) {
	xml_http.open("GET",encodeURI("rendeles.php?step=2&sznev="+sznev+"&szirszam="+szirszam+"&szvaros="+szvaros+"&szutca="+szutca+"&pnev="+pnev+"&pirszam="+pirszam+"&pvaros="+pvaros+"&putca="+putca+"&tel="+tel+"&email="+email+"&egyeb="+egyeb+"&egyezik="+egyezik));
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	 xml_http.setRequestHeader("Accept-Charset","UTF-8");
	xml_http.onreadystatechange = orderHandler;
	xml_http.send(null);
}

function termekInfo(tid) {
	xml_http.open("GET","kosar.php?act=tinfo&tid="+tid);
	xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");	
	xml_http.onreadystatechange = tinfoHandler;
	xml_http.send(null);	
}

function tinfoHandler() {
	if (xml_http.readyState == 4) {	
		document.getElementById("kosarinfo").innerHTML = xml_http.responseText;
	}	
}


function getXMLHttp()
{
	var xmlHttp=null;
	
	if (window.XMLHttpRequest) {
	
		try
  	{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
  	}
  	catch (e) { }
	} else if (window.ActiveXObject)
  {
  	// Internet Explorer
  	try
    {
    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
 		catch (e)
    {
    	try {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	catch (e) { }
    }
  }
  
	return xmlHttp;
	
}
