function getXmlpHttpobject() {
	var xmlHttp;
	
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function shopitemdel(aruid,arlista) {
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			//window.location.replace("index.php");
			window.location.replace(window.location.href);
			return true;
		}
	}
	//alert(aruid);	
	xmlHttp.open("POST","xml-modules/webshop_request.php?webshop=delitem&aruid="+aruid+"&arlista="+arlista,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
}

function shopalldel(aruid) {
	if (!confirm("Összes tétel törlése.\nBiztos benne ?")) { return; }
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			window.location.replace(window.location.href);
			return true;
		}
	}
	//alert(aruid);	
	xmlHttp.open("POST","xml-modules/webshop_request.php?webshop=alldel",true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
}

function shopsubmit(aobj) {
	aform=aobj;
	while (aform.tagName!="FORM") { aform=aform.parentNode; }
	ainputs=aform.getElementsByTagName("INPUT");
	aaruid=ainputs[0].value;
	amennyiseg=ainputs[1].value;
	if ((amennyiseg=="") || (parseInt(amennyiseg)==0)) {
		alert("Nem adta meg a rendelni kívánt mennyiséget ...");
		return false;
	}
	
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			//alert("Hozzáadtam a kosár tartamához");
			if (!document.getElementById("tdwebshoposszeg")) {
				window.location.replace(window.location.href);
			}
			s = xmlHttp.responseXML.getElementsByTagName("price")[0].firstChild.data;
			if (document.getElementById("tdwebshoposszeg")) {
				document.getElementById("tdwebshoposszeg").innerHTML="<b>"+s+"</b>";
			}
		}
	}
	
	xmlHttp.open("GET",'xml-modules/webshop_request.php?webshop=additem&aruid='+aaruid+'&mennyiseg='+amennyiseg,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
	ainputs[1].value="";
}

function shopsubmit_konfig(aobj,aurl) {
	aform=aobj;
	while (aform.tagName!="FORM") { aform=aform.parentNode; }
	ainputs=aform.getElementsByTagName("INPUT");
	aaruid=ainputs[0].value;
	amennyiseg=ainputs[1].value;
	if ((amennyiseg=="") || (parseInt(amennyiseg)==0)) {
		alert("Nem adta meg a rendelni kívánt mennyiséget ...");
		return false;
	}
	
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			window.location.href=aurl;
			return;
		}
	}
	
	xmlHttp.open("GET",'xml-modules/webshop_request.php?webshop=additem&aruid='+aaruid+'&mennyiseg='+amennyiseg,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
	ainputs[1].value="";
}

function input_numericfilter(aevent,ainput,asubmit) {
	if (iebrowser) {
		if ((aevent.keyCode != 46) && (aevent.keyCode != 37) && (aevent.keyCode != 39) && (aevent.keyCode != 9) && (aevent.keyCode != 8) && (aevent.keyCode != 13) && (aevent.keyCode < 48 || aevent.keyCode > 57)) {
			aevent.returnValue = false;
			return false;
		}
	}
	else {
		if ((aevent.keyCode == 13) || (aevent.keyCode == 46) || (aevent.keyCode == 37) || (aevent.keyCode == 39) || (aevent.keyCode == 9) || (aevent.which == 8) || (aevent.keyCode == 13) || (aevent.which >= 48 && aevent.which <= 57)) {
			if (asubmit && (aevent.keyCode==13)) {
				shopsubmit(ainput);
				aevent.returnValue = false;
				return false;
			}
			return true;
		}
		else {
			return false;
		}
	}
	if (asubmit && (aevent.keyCode==13)) {
		shopsubmit(ainput);
		aevent.returnValue = false;
		return false;
	}
}

function input_numericfilter_konfig(aevent,ainput,asubmit) {
	if (iebrowser) {
		if ((aevent.keyCode != 46) && (aevent.keyCode != 37) && (aevent.keyCode != 39) && (aevent.keyCode != 9) && (aevent.keyCode != 8) && (aevent.keyCode != 13) && (aevent.keyCode < 48 || aevent.keyCode > 57)) {
			aevent.returnValue = false;
			return false;
		}
	}
	else {
		if ((aevent.keyCode == 13) || (aevent.keyCode == 46) || (aevent.keyCode == 37) || (aevent.keyCode == 39) || (aevent.keyCode == 9) || (aevent.which == 8) || (aevent.keyCode == 13) || (aevent.which >= 48 && aevent.which <= 57)) {
			return true;
		}
		else {
			return false;
		}
	}
}

function rendeles_torol(arendelesid) {
	if (!confirm("Biztos törölni akarja a rendelést ?")) { return; }
	xmlHttp = getXmlpHttpobject();
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			window.location.reload();
		}
	}
	//alert(aruid);	
	xmlHttp.open("POST","xml-modules/webshop_request.php?webshop=delrendeles&id="+arendelesid,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
}

function rendeles_torol2(arendelesid) {
	if (!confirm("Biztos törölni akarja a rendelést ?")) { return; }
	xmlHttp = getXmlpHttpobject();
	xmlHttp=getXmlpHttpobject();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			window.history.go(-1);
		}
	}
	//alert(aruid);	
	xmlHttp.open("POST","xml-modules/webshop_request.php?webshop=delrendeles&id="+arendelesid,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
}

