var xmlhttp_carrello;

function inc_carrello(id, azione)
	{
	xmlhttp_carrello=GetXmlHttpObject();
	if (xmlhttp_carrello==null)
		{
		alert ("Browser does not support HTTP Request");
		return;
		}
		
	if (azione == 'invia')
		{	
		var url="/ajax/inc_carrello.asp";
		url=url+"?azione="+azione;
		url=url+"&nominativo="+document.getElementById('nominativo').value;
		url=url+"&indirizzo="+document.getElementById('indirizzo').value;
		url=url+"&cap="+document.getElementById('cap').value;
		url=url+"&citta="+document.getElementById('citta').value;
		url=url+"&provincia="+document.getElementById('provincia').value;
		url=url+"&stato="+document.getElementById('stato').value;
		url=url+"&telefono="+document.getElementById('telefono').value;
		url=url+"&email="+document.getElementById('email').value;
		url=url+"&commenti="+document.getElementById('commenti').value;
		}
	else	
		{
		var url="/ajax/inc_carrello.asp?id="+id+"&azione="+azione;
		}
	xmlhttp_carrello.onreadystatechange=function(){stateChanged_carrello(id, azione)}
	xmlhttp_carrello.open("GET",url,true);
	xmlhttp_carrello.send(null);
	}

function stateChanged_carrello(id, azione)
	{
	if (xmlhttp_carrello.readyState==4 || xmlhttp_carrello.readyState=="complete")
		{
		if (xmlhttp_carrello.responseText != '')
			{			
			setTimeout(function(){  
				$(".carrello").html(xmlhttp_carrello.responseText);	
				}, 400);
			if ($('.contentopaque').width() > 0)
				{
				$('.carrello').css('margin-left', '520pt');
				}
			else
				{
				$('.carrello').css('margin-left', '520pt');
				}					
			$('.carrello').fadeIn(800);
			}
		}
	}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
