d = document;

function buy(p) {
	if (d.getElementById) {
		pqty = d.getElementById("products_id[" + p + "]");
	} else if (d.all) {
		pqty = d.all["products_id[" + p + "]"];
	}
	d.location.href = 'index.php?main_page=index&action=add_product&cart_quantity=' +
		((pqty.value == 0) ? 1 : escape(pqty.value * 1)) + '&products_id=' + p;
}
