// ------------------------------------------------------------
// Shopping Cart V0.1		Naich Design

// cart_javascript.js		Last modified 29-07-02

// Contains Javascript utilities for pages in the shopping
// cart system.
// ------------------------------------------------------------

// Kills the current window

function killWindow ()
{
	parent.window.close ();
}

// Reloads the window which opened the one this was called from
function reloadMain ()
{
	top.opener.location.reload ();
}

// Validates the data entered in the "Add to cart" window
function validateForm (inStock)
//
// Form name must be addToCart
// Box name must be quantity
//
// ** This has been hacked to not check the quantity in stock, due to the NYWines case number bodge
//
{
//	if (inStock != -1) {
//		numberRequested = document.forms.addToCart.quantity.value;
//		if (numberRequested > inStock) {
//			alert ("You have ordered " + numberRequested + " but there are only " + inStock + " in stock.");
//			document.forms.addToCart.quantity.focus ();
//			return false;
//			}
//		else return true;
//		}
	return true;
}

// Opens up the "Add to cart" window
function addToCart (item, table, path)
{
	open (path + "cart_add.asp?item=" + item + "&table=" + table, "new", "width=430,height=400,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
	
}

// Opens up the "Remove all from cart" window
function removeFromCart (item, table, path)
{
	open (path + "cart_remove.asp?item=" + item + "&table=" + table, "new", "width=430,height=400,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
	
}

// Opens up the "Add to cart" window, reloads main
function addToCart_r (item, table, path)
{
	open (path + "cart_add.asp?item=" + item + "&table=" + table + "&rl=1", "new", "width=430,height=400,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
	
}

// Opens up the "Remove all from cart" window, reloads main
function removeFromCart_r (item, table, path)
{
	open (path + "cart_remove.asp?item=" + item + "&table=" + table + "&rl=1", "new", "width=430,height=400,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
	
}

// Opens up the "Put one of these in your cart" window
function addToCart1 (item, table, path)
{
	open (path + "cart_add.asp?item=" + item + "&table=" + table + "&quantity=1", "new", "width=430,height=400,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no");
}

// Dreamweaver open window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Dreamweaver popup warning meassage
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}