ShoppingCartSubMenu =
{
	// Main show sub menu function, compute the position and offset.
	showAuxilarySub : function(parent, child)
	{
		  var p = $(parent); // the parent menu item.
		  var c = $(child ); // the child menu item.
		
		  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
		  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
		  
		  // set the link color to hover..
		  $(p.id).style.color = "#FFEE00";
		  
		  for (; p; p = p.offsetParent)
		  {
			top  += p.offsetTop;
			left += p.offsetLeft;
		  }
		
		  c.style.position   = "absolute";
		  c.style.visibility = "visible";
	},
	
	// Trigger the display methode.
	triggerDisplayMethod : function()
	{
		  if ($(this["at_parent"]))
		  	var p = $(this["at_parent"]); // get the ID's
		  else
		  	var p = $('shopCartMenuItem');
			
		  if ($(this["at_child" ]))
		  	var c = $(this["at_child" ]);
		  else
		  	var c = $('shopCartMenu');
			
		  // Show the submenu...
		  ShoppingCartSubMenu.showAuxilarySub(p.id, c.id);
		  // clear the hide sub menu timeout....
		  clearTimeout(c["at_timeout"]);
	},
	
	// ----- Hide -----
	
	triggerHideMethod : function()
	{
		// get the child menu...
		var c = $(this["at_child"]);
		var p = $(this["at_parent"]);
		// set a hide timeout delay of 33 milliseconds..
		if (! c)
			var c = $('shopCartMenu');
		c["at_timeout"] = setTimeout("$('"+c.id+"').style.visibility = 'hidden'", 333);
		// set the link color to normal..
		$(p.id).style.color = "#FFFFFF";
	},
	
	// ----- Click -----
	
	triggerOnClickMethod : function()
	{					   
		 var p = $(this["at_parent"]); // Get ID's
		 var c = $(this["at_child" ]);
		 if (! c)
		 	var c = $('shopCartMenu');
		  // if the menu is hidden, the show it...
		 if (c.style.display != "none")
		   	ShoppingCartSubMenu.showAuxilarySub(p.id, c.id);
		// if the menu is hidden, the show it...	
		 else c.style.display = "block";
			AjaxCalls.getShoppingCart();
	},
	
	
	triggerHideOnClickMethod : function()
	{					   
		 var p = $(this["at_parent"]); // Get ID's
		 var c = $(this["at_child" ]);
		 if (! c)
		 	var c = $('shopCartMenu');
		 if (! p)
		 	var p = $('shopCartMenuItem');	
		 c.style.display != "none";	
	},
	
	// ----- Attach -----
	
	// PARAMETERS:
	// parent   - id of visible html element
	// child    - id of invisible html element that will be dropdowned
	// showtype - "click" = you should click the parent to show/hide the child
	//            "hover" = you should place the mouse over the parent to show
	//                      the child
	// position - "x" = the child is displayed to the right of the parent
	//            "y" = the child is displayed below the parent
	// cursor   - Omit to use default cursor or use any CSS valid cursor types.
	
	attachSubToParent : function(parent, child, showtype, position, cursor)
	{
		  var p = $(parent);
		  var c = $(child);
		
		  p["at_parent"]     = p.id;
		  c["at_parent"]     = p.id;
		  p["at_child"]      = c.id;
		  c["at_child"]      = c.id;
		  p["at_position"]   = position;
		  c["at_position"]   = position;
		
		  c.style.position   = "absolute";
		  c.style.visibility = "hidden";
		
		  if (cursor != undefined) p.style.cursor = cursor;
		
		  switch (showtype)
		  {
			case "click": // Triggers......
			  p.onclick     = ShoppingCartSubMenu.triggerOnClickMethod;
			  p.onmouseout  = ShoppingCartSubMenu.triggerHideMethod;
			  c.onmouseover = ShoppingCartSubMenu.triggerDisplayMethod;
			  c.onmouseout  = ShoppingCartSubMenu.triggerHideMethod;
			  break;
			case "hover":
			  p.onmouseover = ShoppingCartSubMenu.triggerOnClickMethod;
			  p.onmouseout  = ShoppingCartSubMenu.triggerHideMethod;
			  c.onmouseover = ShoppingCartSubMenu.triggerDisplayMethod;
			  c.onmouseout  = ShoppingCartSubMenu.triggerHideMethod;
			  break;
		  }
	}

};