<!--
//Registry, to contain each object.
CategoryMenu.objRegistry = [];
CategoryMenu.animationLength = 200
CategoryMenu.hideDelay = 200
CategoryMenu.minInterval = 10

function CategoryMenu(id, pid, x)
{
	//alert("new menu");
	
	this.ie = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	if (this.ie || this.ns4 || this.dom) {
	
		this.id = id;
		this.parentid = pid;
		this.sliding = false;
		
		this.gRef = "CategoryMenu_"+id
		eval(this.gRef+"=this")
		
		this.originalX = x;
		
		this.hideTimer = false;
		this.aniTimer = false;
		this.open = false
		this.over = false
		this.startTime = 0;
		
		CategoryMenu.objRegistry[id] = this;
		
		this.showcount = 0;
		
		this.load();
	}
}

CategoryMenu.prototype.load = function()
{
	//alert("Loading");
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	if (!obj1 || !obj2) {
		//Couldn't get one of the objects; have it reload.
		window.setTimeout(this.gRef + ".load()", 100);
	} else {
		//Both the container and content were loaded. Set up this object.
		this.container = obj1
		this.menu = obj2
		this.style = this.ns4 ? this.menu : this.menu.style
		// SEE NOTE ABOVE.  The following function call for the 31 menus bug.
		//this.setStyle()
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("CategoryMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("CategoryMenu.hideMenu('" + this.id + "')")
		this.endSlide()
	}
}

CategoryMenu.showMenu = function(id, e)
{
	var reg = CategoryMenu.objRegistry
	var obj = CategoryMenu.objRegistry[id]
	
	if (obj.container)
	{
//		if (obj.ie) alert('showing: ' + id);
		obj.over = true
		
		obj.container.style.zIndex = 1000;
		
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		obj.showcount++;
		if (!obj.open && !obj.aniTimer)
		{
			//alert("Starting the animation.");
			reg[id].startSlide(true)
		}
	}
	if (obj.ns4) obj.menu.routeEvent(Event.MOUSEOVER);
}

CategoryMenu.hideMenu = function(id, e)
{
	var obj = CategoryMenu.objRegistry[id]
	if (obj.container) {
		obj.container.style.zIndex = 1;
//		if (obj.ie) alert('hiding: ' + id);
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.showcount--;
		obj.hideTimer = window.setTimeout("CategoryMenu.hide('" + id + "')", CategoryMenu.hideDelay);
	}
	if (obj.ns4) obj.menu.routeEvent(Event.MOUSEOUT);
}


CategoryMenu.hide = function(id) {
	var obj = CategoryMenu.objRegistry[id]
	var reg = CategoryMenu.objRegistry
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	var close = true;
	for (menu in reg) {
		// for each child, if either
		//  1. the child is open or
		//  2. the child is closing (but hasn't closed yet)
		// then we don't close this menu.
		var pid = CategoryMenu.objRegistry[menu].parentid
		if (pid == id) {
			if (CategoryMenu.objRegistry[menu].open) close = false;
			if (CategoryMenu.objRegistry[menu].open && CategoryMenu.objRegistry[menu].sliding) close = false;
		}
	}
	if (obj.open && !obj.aniTimer && close && !obj.showcount) obj.startSlide(false);
}


CategoryMenu.prototype.startSlide = function(open) {
	//alert("Starting the slide.");
	this.open = open
	if (open)
	{
		this.container.style.left = (this.originalX+document.getElementById('main_layer').offsetLeft)+"px";
		this.setVisibility(true);
		this.container.style.filter="Alpha(Opacity=0)";
		this.container.style.zIndex = 1000;
	}else{
		this.container.style.zIndex = 1;
	}
	this.startTime = (new Date()).getTime() 
	this.sliding = true;
	this.aniTimer = window.setInterval(this.gRef + ".slide()", CategoryMenu.minInterval)
}

CategoryMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	
	if (elapsed > CategoryMenu.animationLength)
		this.endSlide()
	else {
		var trans = Math.round(elapsed/CategoryMenu.animationLength*100);
		
		if(!this.open)
			trans = 100-trans;
		
		this.container.style.filter="Alpha(Opacity="+trans+")";
		//this.reveal(d)
	}
}

CategoryMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	//alert("ending the slide.");
	
	//If it's not supposed to be open, hide it.
	if (!this.open)
	{
		this.setVisibility(false)
		this.container.style.filter="Alpha(Opacity=0)";
	}else{
		this.container.style.filter="";
	}
	
	this.container.style.zIndex=1001;
	
	//Stop the "sliding".
	this.sliding = false;
	
	if (((this.open && !this.over) || (!this.open && this.over)) && (!this.parent || this.parent.open)) {
		this.startSlide(this.over)
	} else {
		//alert("hiding items");
		
		var overchild = false;
		var reg = CategoryMenu.objRegistry
		for (menu in reg) {
			var pid = CategoryMenu.objRegistry[menu].parentid
			if (pid == this.id) overchild = CategoryMenu.objRegistry[menu].over ? true : overchild		
		}
		if (!overchild && this.parentid && !CategoryMenu.objRegistry[this.parentid].over) CategoryMenu.hide(this.parentid);
	}
}

CategoryMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}

CategoryMenu.prototype.moveTo = function(p) { 
	this.style["left"] = p
}

CategoryMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}