window.onerror = null;
// You do not need to touch the javascript code below.

function MakeArray(n) {
	if(n <= 0) {this.length = 0;return this;} this.length = n; 
	for( var i = 1; i <= n; i++ ) {this[ i ] = 0;} 
	return this;
}

function store(item1,item2,item3,item4) { 
	//item1 is qty, item2 is name of item, item3 is price, item4 is weight
	var cartItems; 
	cartListForm1[ index ] = "/" + item2 + "_" + item3 + "_" + item1 + "_" + item4; 
	++index;
	Add(item1);
}

var cartListForm1 = new MakeArray(40); 
var index = 0; 
var cmmnd = 1;

function Add(qty) {
	var cart, i; 
	cart = ""; 
	for( i = 0; i < index; i++ ) cart += cartListForm1[i]; 
	var cartItems = GetCookie('cartItems'); 
	if (cartItems == null) {cartItems = "";} 
	if (cartItems == cart){} else {cart = (cartItems + cart);} 
	var cartItems = cart; 
	SetCookie ('cartItems', cartItems, null, "/"); 
	var cart = ""; 
	var hashave = " has";
	if (document.cartListForm1.quantity.value > 1) {hashave = " have";} 
	for( i = 0; i < index; i++ ) {cartListForm1[i] = "";}
	//alert("The item selected has been added to your cart.");
	//alert(document.cartListForm1.quantity.value+" "+document.cartListForm1.productSelected.value+hashave+" been added to your cart.");
	alert(qty+" "+document.cartListForm1.productSelected.value+hashave+" been added to your cart.");
}

function Clear() {
	var cartItems = "";	
	var cart = ""; 
	for( i = 0; i < index; i++ ) {cartListForm1[i] = "";} SetCookie ('cartItems', cartItems, null, "/"); 
	var cartItems = GetCookie('cartItems'); 
	alert("Your shopping cart has been emptied.\n\nThis page will now reload to display your empty cart.\n\nEnjoy the Tex-Mex To Go web site.");
}

function SetCookie (name, value) {	
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function Who(info){ 
	var cart; 
	if (cart == "undefined") {cart = "";}
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) {var j = i + alen; 
	if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
	i = document.cookie.indexOf(" ", i) + 1; 
	if (i == 0) break;}return null;
}
