/*** First, extend xLayer for extra functionality ***/
/*** NOTE: If these ever need to be used in others scripts - move to LayerExt ***/
JSFX.Layer.prototype.getPageX		= function(el) 	
{ 
	if(el == null) 
		el = this.elem;
	return el.offsetLeft + (el.offsetParent ? this.getPageX(el.offsetParent) : 0);
}
JSFX.Layer.prototype.getPageY		= function(el) 	
{ 
	if(el == null) 
		el = this.elem;
	return el.offsetTop + (el.offsetParent ? this.getPageY(el.offsetParent) : 0);
}
if(ns4)
{
	JSFX.Layer.prototype.getPageX 	= function() 	{ return this.elem.pageX; }
	JSFX.Layer.prototype.getPageY 	= function() 	{ return this.elem.pageY; }
}
JSFX.Layer.prototype.setColor	= function(c){this.style.color=c;}
if(ns4)
	JSFX.Layer.prototype.setColor	= function(c)
	{
		this.elem.document.write("<FONT COLOR='"+c+"'>"+this.elem.innerHTML+"</FONT>");
		this.elem.document.close();
	}

/*** Borders in IE4+ and NS6 are easy ***/
JSFX.Layer.prototype.setBorderHighColor	= function(c)
{
	this.style.borderStyle="solid"
	this.style.borderWidth = 1;
	this.style.borderTopColor = c;
	this.style.borderLeftColor = c;
}
JSFX.Layer.prototype.setBorderLowColor	= function(c)
{
	this.style.borderStyle="solid"
	this.style.borderWidth = 1;
	this.style.borderRightColor = c;
	this.style.borderBottomColor = c;
}
/*** Borders in NS4 require that we add extra layers ***/
if(ns4)
{
	JSFX.Layer.prototype.setBorderHighColor	= function(c)
	{
		if(!this.borderHiLayer)
		{
			this.borderHiLayer = new JSFX.Layer(" ");
			this.borderHiLayer.setzIndex(2);
		}
		this.borderHiLayer.setBgColor(c);
	}

	JSFX.Layer.prototype.setBorderLowColor	= function(c)
	{
		if(!this.borderLoLayer)
		{
			this.borderLoLayer = new JSFX.Layer(" ");
			this.borderLoLayer.setzIndex(1);
		}
		this.borderLoLayer.setBgColor(c);
	}
	JSFX.Layer.prototype.moveTo = function(x,y)
	{
		this.elem.moveTo(x,y);
		if(this.borderHiLayer)
		{
			this.elem.moveTo(x+1,y+1);
			this.borderHiLayer.moveTo(x,y);
		}
		if(this.borderLoLayer)
			this.borderLoLayer.moveTo(x+2,y+2);
	}
	JSFX.Layer.prototype.resizeTo = function(w,h)
	{
		this.style.clip.width	=w;
		this.style.clip.height	=h;
		if(this.borderHiLayer)
		{
		this.style.clip.width	=w+2;
		this.style.clip.height	=h+2;
			this.borderHiLayer.style.clip.width = w+1;
			this.borderHiLayer.style.clip.height = h+1;
		}
		if(this.borderLoLayer)
		{
			this.borderLoLayer.style.clip.width = w;
			this.borderLoLayer.style.clip.height = h;
		}
	}
	JSFX.Layer.prototype.show = function()
 	{
		this.style.visibility = "show"; 
		if(this.borderHiLayer)
			this.borderHiLayer.style.visibility = "show";
		if(this.borderLoLayer)
			this.borderLoLayer.style.visibility = "show";
	}
	JSFX.Layer.prototype.hide = function()
	{
		this.style.visibility = "hide";
		if(this.borderHiLayer)
			this.borderHiLayer.style.visibility = "hide";
		if(this.borderLoLayer)
			this.borderLoLayer.style.visibility = "hide";
	}
}
/******************************************************************* 
* 
* File    : JSMenu.js 
* 
* Created : 2001/01/20 
* 
* Author  : Roy Whittle  (Roy@Whittle.com) www.Roy.Whittle.com 
* 
* Purpose : To create a cross browser menu (just like all the others)
* 
* History 
* Date         Version        Description 
* 2001-01-20	1.0		Initial version
***********************************************************************/
if(!window.JSFX)
	window.JSFX=new Object();

JSFX.MenuBars = new Array();

var menuBarColor    = "#777777";

var menuBgColor		= "#777777";
var menuBgColorOn		= "#BBBBBB";
var menuBorderColorH	= "#BBBBBB";
var menuBorderColorL	= "#333333";
var menuFontColor		= "#000000";
var menuFontColorOn	= "#CC0000";
var menuFontFace		= "Arial";
var menuFontSize		= "3";
var menuItemBgColor	= "#999999";
var menuItemBgColorOn	= "#DDDDDD";
if(ns4)
	menuFontColorOn	= null;

JSFX.theMenuTimer = null;
JSFX.startMenuCheck = function()
{
	if(JSFX.theMenuTimer == null)
		JSFX.theMenuTimer = setInterval("JSFX.menuCheck()", 500);
}
JSFX.menuCheck = function()
{
	var i;
	for(i=0 ; i<JSFX.MenuBars.length ; i++)
	{
		mb = JSFX.MenuBars[i];
		if(mb.currOn != null && !mb.isActive)
		{
			mb.currOn.close();
			mb.currOn = null;
		}
	}

}

/**********************************************************************/
/*
 * JSMenuItem - extends Object
 */
JSFX.JSMenuItem = function (theText, theLink, theTarget)
{
	if(!theText)
		return;

	this.elemType 	= "JSMenuItem";

	this.theText	= theText;
	this.theLink 	= theLink;
	this.theTarget 	= theTarget;
	this.bgColor 	= menuItemBgColor;
	this.bgColorOn 	= menuItemBgColorOn;
	this.color 		= menuFontColor;
	this.colorOn 	= menuFontColorOn;
	this.currOn		= null;
	this.parentElem   = null;
	this.isVerticle 	= false;

//	this.textPane = new JSFX.Layer("<FONT FACE='"+menuFontFace+"' SIZE='"+menuFontSize+"' COLOR='"+menuFontColor+"'>&nbsp;"+theText+"&nbsp;</FONT>");
	this.textPane = new JSFX.Layer("<FONT FACE='"+menuFontFace+"' SIZE='"+menuFontSize+"'>&nbsp;"+theText+"&nbsp;</FONT>");
	this.textPane.setzIndex(4);
	this.textPane.setBgColor(this.bgColor);
	this.textPane.setColor(this.color);
	this.textPane.hide();

	this.glassPane = new JSFX.Layer(" ");
	this.glassPane.setzIndex(5);
	this.glassPane.parentElem = this;
	this.glassPane.addEventHandler("onmouseover", JSFX.JSMenuItemOver);
	this.glassPane.addEventHandler("onmouseout",  JSFX.JSMenuItemOut);
	this.glassPane.addEventHandler("onmouseup",   JSFX.JSMenuItemUp);
	this.glassPane.hide();

	this.w = this.textPane.getWidth();
	this.h = this.textPane.getHeight();
}
JSFX.JSMenuItem.prototype.getRealWidth = function ()
{
	//NS6 bug;
	if(this.w==0)
		this.w=this.textPane.getWidth();

	return this.w;
}
JSFX.JSMenuItem.prototype.getRealHeight = function ()
{
	//NS6 bug;
	if(this.h==0)
		this.h=this.textPane.getHeight();

	return this.h;
}

JSFX.JSMenuItem.prototype.build = function (x,y,w,h)
{
	this.glassPane.setBorderHighColor(menuBorderColorH);
	this.glassPane.setBorderLowColor(menuBorderColorL);

	this.textPane.resizeTo(w,h);
	this.textPane.moveTo(x+1, y+1);
	this.glassPane.resizeTo(w,h);
	this.glassPane.moveTo(x, y);

	var glassPaneStr = "<IMG SRC='/javascript/jsmenu.gif' WIDTH='"+w+"' HEIGHT='"+h+"' BORDER='0'>"
	var contentStr   = glassPaneStr;
	if(this.theLink != null)
	{
		contentStr = "<A HREF='"+this.theLink+"'";
		if(this.theTarget != null)
			contentStr += " TARGET='"+this.theTarget+"'";
		contentStr += ">"+glassPaneStr+"</A>";
	}
	this.glassPane.setContent(contentStr);
}
JSFX.JSMenuItem.prototype.setBgColor = function (c)
{
	this.bgColor = c;
	this.textPane.setBgColor(c);
}
JSFX.JSMenuItem.prototype.setbgColorOn = function (c)
{
	this.bgColorOn = c;
}
JSFX.JSMenuItem.prototype.show = function()
{
	this.textPane.show();
	this.glassPane.show();
}
JSFX.JSMenuItem.prototype.hide = function()
{
	this.textPane.hide();
	this.glassPane.hide();
}
JSFX.JSMenuItem.prototype.open = function() { }
JSFX.JSMenuItem.prototype.close = function() { }

JSFX.JSMenuItem.prototype.setActive = function(elem)
{
	this.parentElem.setActive(this);
	if(this.currOn != elem)
	{
		if(this.currOn != null)
			this.currOn.close();

		this.currOn = elem;
		this.currOn.open();
	}	
	elem.textPane.setBgColor(elem.bgColorOn);
	if(elem.colorOn)
		elem.textPane.setColor(elem.colorOn);
}
JSFX.JSMenuItem.prototype.setInActive = function(elem)
{
	this.parentElem.setInActive(this);
}
JSFX.JSMenuItemOver = function(pane, ev)
{
	elem = pane.parentElem;
	if(elem.colorOn)
		elem.textPane.setColor(elem.colorOn);
	elem.textPane.setBgColor(elem.bgColorOn);
	elem.parentElem.setActive(elem);
}
JSFX.JSMenuItemOut = function(pane, ev)
{
	elem = pane.parentElem;
	if(elem.colorOn)
		elem.textPane.setColor(elem.color);
	elem.textPane.setBgColor(elem.bgColor);
	elem.parentElem.setInActive(elem);
}
JSFX.JSMenuItemUp = function(pane, ev)
{
	var elem = pane.parentElem;
	var prev = pane.parentElem;

	if(elem.theLink == null)
		return(true);

	while(elem != null)
	{
		prev = elem;
		elem = elem.parentElem;
	}
	if(prev.currOn != null)
		prev.currOn.close();
	prev.currOn=null;

	return(true);
}

/**********************************************************************/
/*
 * JSMenu - extends JSMenuItem
 */
JSFX.JSMenu = function(theText)
{

	//Call the super Constructor;
	this.superC = JSFX.JSMenuItem;
	this.superC(theText, null, null);

	this.elemType 	= "Jsmenu";
	this.elements	= new Array();
	this.setBgColor(menuBgColor);
	this.setbgColorOn(menuBgColorOn);
}
JSFX.JSMenu.prototype = new JSFX.JSMenuItem;

JSFX.JSMenu.prototype.add = function (elem, link)
{
	var num = this.elements.length;
	this.elements[num] = elem;

	elem.isVerticle 	= true;
	elem.parentElem 	= this;
}
JSFX.JSMenu.prototype.open = function()
{
	var i;
	for(i=0 ; i<this.elements.length ; i++)
		this.elements[i].show();
}
JSFX.JSMenu.prototype.close = function()
{
	var i;
	this.textPane.setBgColor(this.bgColor);
	if(elem.colorOn)
		this.textPane.setColor(this.color);
	for(i=0 ; i<this.elements.length ; i++)
	{
		var e = this.elements[i];
		e.close();
		e.hide();
		e.currOn = null;
	}
}
JSFX.JSMenu.prototype.build = function (x,y,w,h)
{
	var i;
	var menuItem;
	var hasMenu = false;

	//Call the superclass function
	this.superF = this.superC.prototype.build;
	this.superF(x,y,w,h);

	if(this.isVerticle)
	{
		x+=(w+2);
		y-=(h+2);
		w=0;
	}

	for(i=0 ; i<this.elements.length ; i++)
	{
		e = this.elements[i];

		if(e.getRealWidth() > w)
			w = e.getRealWidth();
	}	
	for(i=0 ; i<this.elements.length ; i++)
	{
		var e = this.elements[i];
		e.build(x, y + (h+2)*(i+1), w, h);
	}
}

/**********************************************************************/
JSFX.JSMenuBar = function(verticle, constWidth)
{
	this.elemType 	= "JSMenuBar";

	this.textPane = new JSFX.Layer("<FONT FACE='"+menuFontFace+"' SIZE='"+menuFontSize+"'>MENUBAR</FONT>");
	this.x	= 0;
	this.y	= 0 ;
	this.w	= 800; 
	this.h	= this.textPane.getHeight()+4;
	this.isVerticle	= verticle;
	this.isConstWidth = constWidth;
	this.currOn	= null;
	this.isActive = false;
	this.attached = null;

	this.elements = new Array();

	if(document.body)
	{
		if(document.body.clientWidth)
			this.w = document.body.clientWidth;
		else if(innerWidth != null)
			this.w = innerWidth;
	}
	else if(innerWidth != null)
		this.w = innerWidth;

	this.textPane.setBgColor(menuBarColor);
	this.textPane.hide();
	this.textPane.parentElem = this;
	this.textPane.setzIndex(1);

	this.ns6BuildNo = JSFX.MenuBars.length;
	JSFX.MenuBars[JSFX.MenuBars.length] = this;
}

JSFX.JSMenuBar.prototype.moveTo = function (x,y)
{
	this.x = x;
	this.y = y;
}
JSFX.JSMenuBar.prototype.attachLayer = function (theLayer)
{
	this.attached = new JSFX.Layer(JSFX.findLayer(theLayer));
}
JSFX.JSMenuBarHolder = function(theId, w, h)
{
	var str = "&nbsp;";
	var hStr = "";
	if(!w) w = "100%"

	if(document.layers)
	{
		if(h)
			hStr = ' HEIGHT="'+h+'"';
		return('<ILAYER WIDTH="'+w+'"><LAYER name="'+theId+'" WIDTH="'+w+'"'+hStr+'>'+str+'</ILAYER></LAYER>');
	}
	else
	{
		if(h)
			hStr = ' height:'+h;
		return('<div id="'+theId+'" STYLE="width:'+w+hStr+'">'+str+'</div>');
	}
}

JSFX.JSMenuBar.prototype.show = function ()
{
	var i;
	this.textPane.show();
	for(i=0 ; i<this.elements.length ; i++)
		this.elements[i].show();
}
JSFX.JSMenuBar.prototype.build = function ()
{
	var i;

	//In netscape 6 we have to delay the building of the menu so the DIV's can get a width & height
	if(navigator.appName.indexOf("Netscape") != -1 && document.getElementById)
	{
		if(!this.timeout)
		{
			this.timeout = setTimeout("JSFX.MenuBars["+this.ns6BuildNo+"].build()",100);
			return;
		}
	}

	//NS6 bug;
	if(this.h==4) this.h=this.textPane.getHeight()+4;

	if(this.attached)
	{
		this.x = this.attached.getPageX();
		this.y = this.attached.getPageY();
		this.w = this.attached.getWidth();
		this.h = this.attached.getHeight();
	}

	var maxW=0;
	var maxH=0;
	var totalH = 0;
	for(i=0 ; i<this.elements.length ; i++)
	{
		var e = this.elements[i];

		if(e.getRealWidth() > maxW)
			maxW = e.getRealWidth();
		if(e.getRealHeight() > maxH)
			maxH = e.getRealHeight();
		totalH += e.getRealHeight();
	}
	if(this.isVerticle)
	{
		this.w = maxW;
		this.h = totalH;
	}
	else
	{
		maxW = ( this.w/(this.elements.length) ) - 2;
		this.h = maxH;
	}

	this.textPane.setContent("<IMG SRC='/javascript/jsmenu.gif' WIDTH='"+this.w+"' HEIGHT='"+this.h+"'>");
	this.textPane.resizeTo(this.w,this.h+4);
	if(this.attached)
		this.attached.resizeTo(this.w,this.h+4);
	this.textPane.show();
	this.textPane.moveTo(this.x, this.y);
	var x=this.x+1;
	var y=this.y+1;
	
	for(i=0 ; i<this.elements.length ; i++)
	{
		var e = this.elements[i];

		if(this.isVerticle)
		{
			e.build(x,y,maxW, e.h);
			y=y+e.h+2;
		}
		else if(this.isConstWidth)
		{
			e.build(x,y,maxW, maxH);
			x=x+maxW+2;
		}
		else
		{
			e.build(x,y,e.w, maxH);
			x=x+e.w+2;
		}

		e.show();
	}

	JSFX.startMenuCheck();
}
JSFX.JSMenuBar.prototype.add = function (elem)
{
	var num = this.elements.length;
	this.elements[num] = elem;

	elem.isVerticle	= this.isVerticle;
	elem.parentElem 	= this;
}
JSFX.JSMenuBar.prototype.setActive = function (elem)
{
	if(this.currOn != elem)
	{
		if(this.currOn != null)
			this.currOn.close();

		this.currOn = elem;
		this.currOn.open();
	}
	elem.textPane.setBgColor(elem.bgColorOn);
	if(elem.colorOn)
		elem.textPane.setColor(elem.colorOn);
	this.isActive = true;
}
JSFX.JSMenuBar.prototype.setInActive = function(elem)
{
	this.isActive = false;
}

if(!JSFX.jsmenu_resize)
{
	if(document.layers)
	{
		JSFX.ow = outerWidth;
		JSFX.oh = outerHeight;
		JSFX.jsmenu_resize = function()
		{
			if(outerWidth != JSFX.ow || outerHeight != JSFX.oh )
				location.reload();
		}
	}
	else
		JSFX.jsmenu_resize = function()
		{
			location.reload();
		}
}
window.onresize=JSFX.jsmenu_resize;

