
function agregarAlCarrito(id, cCodigo, cDescripcion, nCan, nPrecio,dPeso,dLPI,nAlmacen,cNumSer){
	oXML = crearObjAJAX();
	oXML.open('POST', 'insertar_en_carrito.php',false);
	//document.getElementById(id).innerHTML = oXML.responseText;
	oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXML.send('cCodigo='+encodeURIComponent(cCodigo)+'&cDescripcion='+encodeURIComponent(cDescripcion)+'&nCan='+nCan+'&nPrecio='+nPrecio+'&dPeso='+dPeso+'&dLPI='+dLPI+'&nAlmacen='+nAlmacen+'&cNumSer='+encodeURIComponent(cNumSer));
	return true;
}

function borrarDelCarrito(nLinea, id){
	oXML = crearObjAJAX();
	oXML.open('POST', 'borrar_de_carrito.php',false);
	document.getElementById(nLinea).style.display = "none";
//	document.getElementById(id).innerHTML = oXML.responseText;
	oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXML.send('nLinea='+nLinea);
    location.href = "chart_v3.php";
	return true;
}

function borrarDelCarrito_v3(nLinea, id){
	oXML = crearObjAJAX();
	oXML.open('POST', 'borrar_de_carrito.php',false);	
	oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXML.send('nLinea='+nLinea);
	return true;
}

function actualizarCarrito(id){    
	oXML = crearObjAJAX();    
	oXML.open('POST', 'resumenchart_inc_v3.php',true);
	oXML.onreadystatechange = function(){
		if(oXML.readyState==1){
			document.getElementById(id).innerHTML = '... actualizando carrito ... <img src="images/cargando.gif" border="0">';
		}else if(oXML.readyState==4){
			if(oXML.status==200){
				document.getElementById(id).innerHTML = oXML.responseText;
			}
		}
	}
	oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXML.send('cId='+id);
	return true;
}

function actualizarCarritoPadre(id){
	oXML = crearObjAJAX();
	oXML.open('POST', 'resumenchart_inc_v3.php',true);
	oXML.onreadystatechange = function(){
		if(oXML.readyState==1){
			window.opener.document.getElementById(id).innerHTML = '... actualizando carrito ... <img src="images/cargando.gif" border="0">';
		}else if(oXML.readyState==4){
			if(oXML.status==200){
				window.opener.document.getElementById(id).innerHTML = oXML.responseText;
			}
		}
	}
	oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	oXML.send('cId='+id);
	return true;
}

function vaciarCarrito(bPedirConfirmacion){
	if(bPedirConfirmacion){
		if(confirm("¿Está seguro de vaciar su carrito?")){
			oXML = crearObjAJAX();
			oXML.open('POST', 'borrar_carrito_completo.php',false);
//			document.getElementById(nLinea).style.display = "none";
//			document.getElementById(id).innerHTML = oXML.responseText;
			oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			oXML.send(null);
			window.location.reload(); 
			return true;
		}else{
			return false;
		}
	}else{
		oXML = crearObjAJAX();
		oXML.open('POST', 'borrar_carrito_completo.php',false);
		oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		oXML.send(null);
		//window.location.reload(); 
		return true;
	}
}

function vaciarCarrito2(bPedirConfirmacion,bRecargar){
	if(bPedirConfirmacion){
		if(confirm("¿Está seguro de vaciar su carrito?")){
			oXML = crearObjAJAX();
			oXML.open('POST', 'borrar_carrito_completo.php',false);
//			document.getElementById(nLinea).style.display = "none";
//			document.getElementById(id).innerHTML = oXML.responseText;
			oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			oXML.send(null);
			if(bRecargar)
				window.location.reload(); 
			return true;
		}else{
			return false;
		}
	}else{
		oXML = crearObjAJAX();
		oXML.open('POST', 'borrar_carrito_completo.php',false);
		oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		oXML.send(null);
		if(bRecargar)
			window.location.reload(); 
		return true;
	}
}
