var Navigate = Class.create(Component, {
	initialize: function($super, name, owner, editMode){
		$super(name, owner, editMode);
		this.selections = 0;
		this.shoppingCart = 0;
	},

	receiveEvent: function($super, sender, event, args){
		var currentSelections = this.selections;
		var currentShoppingCart = this.shoppingCart;
		var type = "";

		switch (event)
		{
			case "addSelection":
				type = "selection";
				if (this.selections + args > -1)
					this.selections += args;
				break;
			case "clearSelection":
				type = "selection";
				this.selections = 0;
				break;
			case "addShoppingCart":
				type = "shoppingCart";
				if (this.shoppingCart + args > -1)
					this.shoppingCart += args;
		}

		switch (type)
		{
			case "selection":
				if ($("Search:Selections"))
				{
					$("Search:Selections").innerHTML = $("Search:Selections").innerHTML.replace("(" + currentSelections + ")", "(" + this.selections + ")");
					$("Search:Selections").title = $("Search:Selections").innerHTML;
				}
				break;

			case "shoppingCart":
				if ($("My Account:ShoppingCart"))
				{
					$("My Account:ShoppingCart").innerHTML = $("My Account:ShoppingCart").innerHTML.replace("(" + currentShoppingCart + ")", "(" + this.shoppingCart + ")");
					$("My Account:ShoppingCart").title = $("My Account:ShoppingCart").innerHTML;
				}
				break;
		}

		return $super(sender, event, args);
	},

	setStartPage: function(uri){
		if(xajax.request({xjxfun: this.name + "AxSetStartPage"}, {parameters: [uri], mode: "synchronous"})){
			alert("Your start page has been saved.");
			return true;
		}
		return false;
	}
});

