////////////////////////////////////////////////////////////////////////////////////
//  cart.js --  Please leave leave the following notice.
//
//  Copyright (C) 2000, Small Business Web Developer, a division of Fromert Programming (info@smallbusinessweb.cjb.net).
//  
//
//  This script was created for use by the Small Business Web Developer
//  and is not to be sold or included in any programs or web based applications
//  without the expressed consent of Fromert Programming.
//  Please do not try to sell this solution to a company or individual claiming it is yours.
//
//  If you would like to use this in your own solutions, please contact Fromert Programming
//  at fromertprogramming@juno.com for consideration.
////////////////////////////////////////////////////////////////////////////////////


function addtocart(sku){
	buyItem(sku[0],sku[1],1,'-',sku[2]);

}

function MakeTen(expr,decimal){
	var str="" + Math.round(eval(expr) * Math.pow(10,decimal))
	while (str.length <= decimal){
	   str = "0" + str
	}
	var decpoint = str.length - decimal
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function MakeTwo(expr){
	return "$" + MakeTen(expr,2)
}       

function buyItem(newItem, newPrice, newQuantity, newOption, newWeight) {
		if (newQuantity <= 0) {
                        rc = alert('Zero is not a quantity.');
                        return false;
                }
                if (newQuantity >= 0) {
                        index = document.cookie.indexOf("navajocart");
                        countbegin = (document.cookie.indexOf("=", index) + 1);
                        countend = document.cookie.indexOf(";", index);
                        if (countend == -1) {
                                countend = document.cookie.length;
			location = "basket.htm";
                        }
                        document.cookie="navajocart="+document.cookie.substring(countbegin, countend)+"["+newWeight+"|"+newItem+","+newPrice+"^"+newOption+"~"+newQuantity+"#"+"]";
		}
                return true;
        }
function resetShoppingCart() {
                index = document.cookie.indexOf("navajocart");
                document.cookie="navajocart=.";
        }

