function buyItem(newItem, newPrice, newQuantity) {
if (newQuantity <= 0) {
rc = alert('La cantidad ingresada es incorrecta');
return false;
}
if (confirm('¿Confirma agregar al carrito de compras '+newQuantity+' licencia(s) para\n'+newItem+'?')) {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newPrice+"#"+newQuantity+"]";
window.location.href = "index.php?do=estado"; //top.location = "http://www.eset.com.uy/compras2/index.php?do=estado";
}
return true;
}

function resetShoppingBasket() {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
}

function getComprar() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
var tax = itemtotal / 100 * (22 - 0);
tax = Math.floor(tax * 100)/100
totprice = totprice + itemtotal + tax;
itemlist=itemlist+1;
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
if (totprice == 0) {
 alert("Antes debe agregar un producto al carrito");
 return; }
 window.location.href = "index.php?do=formulario"; //top.location = "http://www.eset.com.uy/compras2/index.php?do=formulario";
}

function getEstado() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
var tax = itemtotal / 100 * (22 - 0);
tax = Math.floor(tax * 100)/100
totprice = totprice + itemtotal + tax;
itemlist=itemlist+1;
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
if (totprice != 0) {
 document.writeln("Productos en el carrito: "+itemlist+"&nbsp;&nbsp;&nbsp;(Total + IVA = u$s "+alterError(totprice)+")");
 return; }
 document.writeln("No hay productos en el carrito");
return;
}