function b5280Cart () {
	this.totalQty = 0;
	this.totalPrice = 0.00;
	this.items = {};
	this.getCookie = function(cookieName){
		var cookie = $.getJSONCookie(cookieName);
		if (typeof(cookie.totalQty) !== 'undefined' && cookie.totalQty != null) {
			this.totalQty = cookie.totalQty;
			this.totalPrice = cookie.totalPrice;
			this.items = cookie.items;
		}
	};
	this.setCookie = function(cookieName){
		var date = new Date();
	    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
									// day * hours * min * sec * mili
		var t = $.JSONCookie(cookieName, this, { path: '/', expires: date });
	};
	this.removeCookie = function(cookieName) {$.removeJSONCookie(cookieName);};
	this.newItem = function (item){
		return (typeof(this.items[item]) === 'undefined' || this.items[item] == null);
	};
	this.addItem = function(item, qty, bag, el) {
		var parent = null;
		if(typeof(products[item].options) !== 'undefined' && products[item].options != null) {
			parent = item;
			item = el.parents('.steps').find("select:select").val();
		}
		var note = null;
		if(typeof(products[item].note) !== 'undefined' && products[item].note != null) {
			note = el.parents('.steps').find("input:"+products[item]["note-type"]).val();
		}		
		if(this.newItem(item)) {
			this.items[item] = {'qty': qty, 'parent': parent, 'note': note};
			this.totalQty++;
			this.totalPrice +=  (parent === null) ? products[item].price*qty : products[parent].price*qty;
			//this.updateBag(bag, item, parent);
			return item;
		} else {
			return false;
		} 
	};
	this.updateQty = function(item, qty){
		if(this.items[item].qty == qty) {
			return false
		} else {
			var parent = this.items[item].parent;
			var price = (parent == null) ? products[item].price : products[parent].price;
			this.totalPrice += (qty - this.items[item].qty)*price;
			this.items[item].qty = qty;
			var shping = "5.95";
			if(this.totalPrice > 20)
				shping = "0.00";
			$(".shipping-total").replaceWith("<span class=\"shipping-total\">"+shping+"</span");
			return true;
		}		
	};
	this.updateNote = function(item, note) {
		if(this.items[item].note == note) {
			return false
		} else {
			this.items[item].note = note;
			return true;
		}		
	};
	this.removeItem = function(line,cookieName){
		var item = (line.attr("href")).replace("#","");
		var qty = line.siblings('input').val();
		if(this.items[item].parent == null) {
			$("#"+item + " .item-action").html("<a href=\"#"+item+"\" class=\"add-to-bag\"><img src=\"images/addToBag.gif\" alt=\"Add to Bag\" /></a>");
			$("#"+item + " .quantity").val("1").removeAttr("disabled");
		} else {
			$("#"+this.items[item].parent + " .item-action").html("<img src=\"images/addToBagOff.gif\" alt=\"Disabled Add to Bag\" class=\"item-no-select\" />");
		}
		if(this.totalQty == 1) {
			this.totalQty = 0;
			this.totalPrice = 0;
			this.items = {}; //delete this.items[item];
			this.removeCookie(cookieName);
			$("#bag-overlay table").remove();
			$("#bag-overlay .check-out").hide();
			$("#bag-overlay h4").text("Your Bag is Empty");
		} else {
			this.totalQty--;
			var parent = null;
			if(typeof(products[item].parent) !== 'undefined' && products[item].parent != null) {
				parent = products[item].parent;
			}
			this.totalPrice -=  (parent == null) ? products[item].price*qty : products[parent].price*qty;
			delete this.items[item];
			line.parents('.bag-item').remove();
			this.setCookie(cookieName);
		}
		$(".bag-qty").replaceWith("<span class=\"bag-qty\">"+this.totalQty+"</span");
		$(".bag-total").replaceWith("<span class=\"bag-total\">"+this.totalPrice.toFixed(2)+"</span");
		var shping = "5.95";
		if(this.totalPrice > 20)
			shping = "0.00";
			$(".shipping-total").replaceWith("<span class=\"shipping-total\">"+shping+"</span");
		return true;
	};
	this.updateHtmlRemove = function (line){
	};
	this.emptyBag = function(){
		var bag = this;
		$('.bag-item a[rel]').each(function (e) {
			bag.removeItem($(this));
		});
	};
	this.resetBag = function(cookieName){
		this.totalQty = 0;
		this.totalPrice = 0.00;
		this.items = {};
		this.removeCookie(cookieName);
	};
	this.paypalCheckout = function(form){
		//this.emptyBag();
		$(".add-at-checkout").remove();
		var count = 0;
		for(i in this.items) {
			count++;
			var cString = "_"+count,
				price = products[i].price, 
				shipping = "5.95";
			if(typeof(products[i].parent) !== 'undefined' && products[i].parent != null) {
				var j = products[i].parent;
				price = products[j].price;
			}
			if(this.totalPrice > 20) {
				shipping = "0.00";
			}
			if(this.items[i].qty > 0) {
				form.append(
					"<input name=\"item_number"+cString+"\" value=\""+i+"\" type=\"hidden\" class=\"add-at-checkout\">"+
					"<input name=\"item_name"+cString+"\" value=\""+products[i].title+"\" type=\"hidden\" class=\"add-at-checkout\">"+
					"<input name=\"amount"+cString+"\" value=\""+price+"\" type=\"hidden\" class=\"add-at-checkout\">"+
					"<input name=\"quantity"+cString+"\" value=\""+this.items[i].qty+"\" type=\"hidden\" class=\"add-at-checkout\">"+
					"<input name=\"shipping\" value=\"0.00\" type=\"hidden\" class=\"add-at-checkout\">"
				);
				if(typeof(this.items[i].note) !== 'undefined' && this.items[i].note != null) {
					form.append(
						"<input name=\"on0"+cString+"\" value=\"Note\" type=\"hidden\" class=\"add-at-checkout\">"+
						"<input name=\"os0"+cString+"\" value=\""+this.items[i].note+"\" type=\"hidden\" class=\"add-at-checkout\">"
					);
				}
			}
		}
		if (typeof(_gat) == "object") {
			pageTracker._trackPageview('/outgoing/paypal.com');
		}
		form.submit();
	};
}
