function getXmlHttp(){
	var xmlhttp;
	try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){
		try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		catch(E){xmlhttp=false;}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined'){	xmlhttp=new XMLHttpRequest();}
	return xmlhttp;
}
function refill_basket(s,q){
	var basket_div=document.getElementById('oc');
	var i_div=document.getElementById('i'+s);
	var xmlhttp=getXmlHttp();
	sid=document.cookie;
	sid=sid.substr(sid.indexOf('PHPSESSID=')+10);
	pos=sid.indexOf(';');
	if(pos>0){sid=sid.substr(0,pos);}
	xmlhttp.open('GET','/miopizza/ajax.php?q='+q+'&id='+s+'&r='+Math.random(),true);
	xmlhttp.setRequestHeader('PHPSESSID',s);
	xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){
		if(i_div){i_div.innerHTML='';}
		basket_div.innerHTML=xmlhttp.responseText;
	}}};
	xmlhttp.send(null);
}
function add_into_basket(s){
	var basket_div=document.getElementById('oc');
	var i_div=document.getElementById('i'+s);
	basket_div.innerHTML=' &nbsp; <img src="/miopizza/wait.gif" width="32" height="32">';
	i_div.innerHTML=' &nbsp; <img src="/miopizza/loading.gif" width="16" height="16">';
	o=document.getElementById('q'+s);
	q=o.options[o.selectedIndex].value;
	refill_basket(s,q);
	return false;
}
function add_it(s,q){
	var basket_div=document.getElementById('oc');
	var i_div=document.getElementById('i'+s);
	var q_o=document.getElementById('q'+s);
	q_o.value=Math.max(0,q+parseInt(q_o.value,10));
	basket_div.innerHTML=' &nbsp; <img src="/miopizza/wait.gif" width="32" height="32">';
	i_div.innerHTML=' &nbsp; <img src="/miopizza/loading.gif" width="16" height="16">';
	refill_basket(s,q);
	return false;
}
window.onload=function(){refill_basket('','');}
