function Browser() {
	var b=navigator.appName;
	if (!b) alert('Unidentified browser.\nThis browser is not supported,');
	
	this.dom=document.getElementById?true:false;
	this.ie=document.all?true:false;
	this.ie4= (this.ie && !this.dom)?true:false;
	this.ns = (b.indexOf('Netscape')!=-1);
	this.ns4 = (this.ns && !this.dom)?true:false;
	this.opera=window.opera?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	this.dyn=this.dom||this.dom||this.ns4;
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is=new Browser();


function DynLayer() {
var a=arguments;
	this.id=a[0]||0;
	this.par=a[1]||0;
	this.x=a[2]||0;
	this.y=a[3]||0;
	this.w=a[4]||null;
	this.h=a[5]||null;
	this.bgColor=a[6]||null;
	this.visible=(a[7]!=false && a[7]!='hidden');
	this.z=a[8]||0;
	this.bgImage=a[9]||null;
	this.html=a[10]||null;
	this.elm=null;
	this.doc=null;
	this.css=null;
	//this.setRef();
};


DynLayer.prototype.setRef = function(){
	if (is.dom){ 
		this.elm = document.getElementById(this.id)
		this.css = this.elm.style
		this.clipRef = this.elm.currentStyle;
		this.doc = document
	}
	else if (is.ie){
		this.elm = document.par.all[this.id]
		this.css = this.elm.style
		this.clipRef = this.elm.currentStyle;
		this.doc = document
	}
	else if (is.ns4){
		this.css = (this.par)? eval("document."+this.par+".document.layers['"+this.id+"']") : document.layers[this.id];
		this.elm=this.css;
		this.doc=this.elm.document;
	}
}
	
if (is.ns) {
	if (document.documentElement){
	DynLayer.prototype._setX=function(){ this.css.left=this.x + "px"; };
	DynLayer.prototype._setY=function(){ this.css.top=this.y + "px";};
	}else{
	DynLayer.prototype._setX=function(){ this.css.left=this.x; };
	DynLayer.prototype._setY=function(){ this.css.top=this.y; };
	}
} else {
	DynLayer.prototype._setX=function(){ this.css.pixelLeft=this.x; };
	DynLayer.prototype._setY=function(){ this.css.pixelTop=this.y; };
};

DynLayer.prototype.moveTo=function(x,y) {
	if (x!=null) this.x=x;
	if (y!=null) this.y=y;
	if (this.css==null) return;
	this._setX();
	this._setY();
	//this.invokeEvent('move');
};

DynLayer.prototype.moveBy=function(x,y) {
	this.moveTo(this.x+x,this.y+y);
};

DynLayer.prototype.getX=function() { return this.x; };
DynLayer.prototype.getY=function() { return this.y; };

DynLayer.prototype.setVisible=function(b) {
	this.visible=b;
	if (this.css==null) return;
	this.css.visibility = b? "inherit" : (is.ns4?"hide":"hidden");
};
DynLayer.prototype.getVisible=function() {
	return this.visible;
};
DynLayer.prototype.show =function() {
this.setVisible(true)
}
DynLayer.prototype.hide =function() {
this.setVisible(false)
}

DynLayer.prototype.setZIndex=function(z) {
	this.z=z;
	if (this.css==null) return;
	this.css.zIndex=z;
};
DynLayer.prototype.getZIndex=function() {
	return this.z;
};

DynLayer.prototype.setBgColor=function(color) {
	if (color==null) {
		if (is.ns4) color=null;
		else color='transparent';
	}
	this.bgColor=color;
	if (this.css==null) return;
	if (is.ns4) this.doc.bgColor=color;
	else this.css.backgroundColor=color;
};
DynLayer.prototype.getBgColor=function() {
	return this.bgColor;
};


DynLayer.prototype.clip=function() {
a = arguments;
if (is.ns4) with(this.css){left=a[0];top=a[1];right=a[2];bottom=a[3]}
else this.css.clip="rect("+a[1]+"px "+a[2]+"px "+a[3]+"px "+a[0]+"px)";
}

var section = "";

function Menu(id,name,top,left,styles){
	this.id=id
	this.name=name
	this.nav = new Array()
	this.width=0;
	this.top = top;
	this.left = left;
	this.sectionClass = styles[0];
	this.itemClass = styles[1];
	this.pipeClass = styles[2];
	this.bgColor=styles[3];
	this.overColor=styles[4];
	this.itemBgColor = styles[5];
	this.itemOverColor=styles[6];
	this.borderColor=styles[7]
	this.borderWidth = 0;
	this.cursor = (is.ie) ? "hand" : "pointer";
	this.activeMenu = null;
	this.activeLabel = null;
	this.addSection = addSection
	this.addItem = addItem;
	this.genNavDivs = genNavDivs;
	this.genItemDivs = genItemDivs;
	this.init = initDivs;
	mnList[mnList.length] = this;
}

function navObj(par,id,label,url,newWin,width,height,useDivider){
	this.type = "nav"
	this.par = par
	this.id = id;
	this.label = label;
	this.url = url;
	this.newWin = newWin;
	this.height = height;
	this.width = width;
	this.useDivider = (useDivider!=null) ? useDivider : true;
	this.top = this.par.top;
	this.bottom = this.top + this.height;
	this.left = par.left + par.width;
	this.par.width=this.par.width+this.width-1;
	this.className = (label.toLowerCase().replace(' ','_') != section)? this.par.sectionClass : this.par.sectionClass +"Current" ;
	this.overClassName = this.par.sectionClass + "On";
	this.bgColor = this.par.bgColor;
	this.overColor = this.par.overColor;
	this.lyr = new DynLayer("nav"+this.par.id+ "_" +id+"Div",null,this.left,this.top,this.width,this.height,this.bgColor,true,1000);
	this.item = new Array();
	this.openMenu = openMenu;
	this.runAnim = runAnim;
	this.over = navOver;
	this.out = navOut;
	this.obj = "nav"+ this.par.id+ "_" + id + "Obj"
	eval(this.obj + "=this")	
	this.menulyr = new DynLayer("nav"+ this.par.id+ "_" +this.id+"MenuDiv",null,this.left,(this.top+this.height),this.width,0,this.par.borderColor,false,1000);
	this.menuheight = this.par.borderWidth;
	this.menuwidth = 0;
	this.openLink = openLink;
}

function navItem(id,par,path,label,url,newWin){
	this.type="item"
	this.id = id;
	this.par = par;
	this.menuName = this.par.par.name
	this.path = path;
	this.label = label;
 	this.url = url;
	this.newWin = newWin;
	this.width = 120;
	this.height= 24;
	this.left = this.par.par.borderWidth;
	this.top = this.id*this.height + (this.id*this.par.par.borderWidth)+this.par.par.borderWidth
	this.className = this.par.par.itemClass;
	this.overClassName = this.className + "On";
	this.bgColor = this.par.par.itemBgColor;
	this.overColor = this.par.par.itemOverColor;
	this.lyr = new DynLayer("item"+ this.par.par.id+ "_" +this.par.id+"_"+id+"Div","nav"+ this.par.par.id+ "_" +this.par.id+"MenuDiv",this.left,this.top,this.width,this.height,this.bgColor,false,5000);
	this.par.menuheight += (this.height+this.par.par.borderWidth)
	this.par.menuwidth = ((this.width>this.par.menuwidth)? (this.width+2*this.par.par.borderWidth) : this.par.menuwidth)
	this.over = itemOver;
	this.out = itemOut;
	this.openLink = openLink;
}

function openLink(){
	if (this.newWin){
		window.open(this.url);
	}else{
		document.location.href=this.url;
	}
}

function addSection(id,label,url,newWin,width,height,useDivider){
this.nav[id]=new navObj(this,id,label,url,newWin,width,height,useDivider)
} 

function addItem(section,id,path,label,url,newWin){
this.nav[section].item[id] = new navItem(id,this.nav[section],path,label,url,newWin)
}


function genNavDivs(){
	var navStr = "";
  	for(x=0;x<this.nav.length;x++){
		with (this.nav[x]){
			navStr += (is.ns4)? "<layer " : "<div ";
		    navStr += "id='nav" + par.id + "_" + x + "Div'";
			navStr += (is.ns4)? " visibility='visible' bgcolor='" +bgColor+"' width='"+width+"' height='"+height+"' top='"+top+"' left='"+left+"' z-index='1000'" : "style='position:absolute;background-color:"+bgColor+";left:"+left+"px;top:"+top+"px; width:"+width+"px;height:"+height+"px;cursor:"+par.cursor+";'";
			navStr += " onclick='"+par.name+".nav["+x+"].openLink()' onmouseover='"+par.name+".nav[" + x + "].over() ";
			if(item.length!=0) navStr += "; "+par.name+".nav["+x+"].openMenu()'";
			else navStr += "; if("+par.name+".activeMenu)closeItems("+par.name+".activeMenu);if("+par.name+".isAnim)cancelAnimation("+par.name+".isAnim);' onmouseout='"+par.name+".nav[" + x + "].out()'"; 
			if (is.ns4){
			navStr += "><a href='"+url+"' class='"+className+"'"
			navStr += (newWin) ? " target='_blank'>" : ">"
			}else{
			navStr += " class='"+className+"'>";	
			}
			navStr +="" + label + "";
			navStr += (is.ns4)?"</a></layer>\n":"</div>\n";
			if(useDivider){
			var offset = 2;
			navStr += (is.ns4)? "<layer left='"+(left + width-offset)+"' top='"+(top)+"' width='1' height='"+height+"' z-index='2000'><span class='"+par.pipeClass+"'>|</span></layer>" : "<div style='position:absolute;left:"+(left + width -offset)+"px;top:"+top+"px; width:2px;height:"+height+"px;' class='" +par.pipeClass + "'>|</div>"
			}
		}
	}
  	document.write(navStr);
  	document.close();
}

function genItemDivs(){
	var subStr = "";
	for(x=0;x<this.nav.length;x++){
		subStr += (is.ns4)? "<layer " : "<div ";
		subStr += " id='nav" + this.nav[x].par.id + "_" + x +"MenuDiv'"
		with(this.nav[x]){
		if (is.ns4) subStr += " visibility='hidden' bgcolor='"+par.borderColor+"' width='"+menuwidth+"' height='"+menuheight+"' top='0' left='0' z-index='1000'>";	
		else subStr += " style='position:absolute;visbility:hidden;display:none;background-color:"+par.borderColor+";width:"+menuwidth+"px;height:"+menuheight+"px;top:"+bottom+"px;left:" + left + "px;z-index:1000;filter:alpha(opacity=85);'>";
		}
		for(y=0;y<this.nav[x].item.length;y++){
			with(this.nav[x].item[y]){
				linkStr =" onmouseover='"+menuName+".nav[" + x + "].item[" + y + "].over()' onmouseout='"+menuName+".nav[" + x + "].item[" + y + "].out()'";
				if (is.ns4) subStr += "<layer id='item" + par.par.id+ "_" + x + "_" +  y + "Div' visibility='inherit' bgcolor='" +bgColor+"' width='"+width+"' height='"+height+"' top='"+top+"' left='"+ par.par.borderWidth+"' z-index=1000";		
				else subStr += "<div id='item"+ par.par.id+ "_" + x + "_" +  y + "Div' style='position:absolute;visibility:inherit;background-color:" +bgColor+";width:"+width+"px;height:"+height+"px;top:"+top+"px;left:"+ par.par.borderWidth+"px;cursor:"+par.par.cursor+";filter:alpha(opacity=100);' class='"+par.par.itemClass+"' ";
				subStr += linkStr;
				if (is.ns4){
				subStr += "><layer class='itmpad'><a href='" + url +"' class='"+className+"NS'"
				subStr += newWin ? " target='_blank'>" : ">";
				}
				else{
					subStr += linkStr + " onclick='"+menuName+".nav[" + x + "].item[" + y + "].openLink()'><div class='itmpad'>";
				}
				subStr += label;
				subStr += (is.ns4)? "</a></layer></layer>\n" : "</div></div>\n";
			}
		}subStr += (is.ns4) ? "</layer>\n":"</div>\n";
	}
	document.write(subStr);
    document.close();
}

function navOver(){
	if(this.item.length>0)this.lyr.setBgColor(this.overColor);
	this.lyr.elm.className = this.overClassName
	if(this.item.length>0)this.lyr.setZIndex(this.lyr.getZIndex()+2000);
	this.par.activeLabel = this;
}

function navOut(){
	this.lyr.setBgColor(this.bgColor);
	this.lyr.elm.className = this.className;
	this.lyr.setZIndex(1000);
	this.par.activeLabel = null;
}

function itemOver(){
this.lyr.setBgColor(this.overColor);
this.lyr.elm.className = this.overClassName;
}

function itemOut(){
this.lyr.setBgColor(this.bgColor);
this.lyr.elm.className = this.className;
}

function openMenu(){
	if (this.par.activeMenu!=null){ //if a menu is open
		if (this.id == this.par.activeMenu.id) return;
		if (is.ns4) closeItems(this.par.activeMenu); 	
		else cancelAnimation(this.par.activeMenu)
	}else{}
	var x = testEdge(this);
	if (x!=this.menulyr.getX()) this.menulyr.moveTo(x);
	if (is.ns4)openItems(this);
	else this.runAnim();
}

function testEdge(obj){
viewportWidth = (is.ns) ? innerWidth : getWidthVal();
scrolled = (is.ns4)?(top.pageXOffset):getLeftVal();
w = obj.left+obj.width
mnw = obj.left + obj.menuwidth
	if(w >  (viewportWidth + scrolled)){
		return (viewportWidth-obj.menuwidth+scrolled);
	}else if(mnw > (viewportWidth + scrolled)){
		return (obj.left - (obj.menuwidth-obj.width));
	}else{
		return (obj.left);
	}
}

function runAnim(){
	menuAnim(this,10) //animation
}

function openItems(obj){
		obj.menulyr.show();
		obj.par.activeMenu=obj;
}

function closeItems(obj){
		obj.menulyr.hide();
   		if(is.dom) obj.menulyr.css.display="none"
		obj.out();
		obj.par.activeMenu=null;
}

function cancelAnimation(obj){
		clearTimeout(obj.timer);
		obj.counter =0;
		closeItems(obj)
}

function menuAnim(obj,dir)
{
 obj.par.isAnim = (obj.par.isAnim) ? obj.par.isAnim : null;
 if (obj.par.isAnim){
 if(obj.par.isAnim.id != obj.id)
 cancelAnimation(obj.par.isAnim)
 }
 id= obj.id
 if (!obj.timer) obj.timer = 0;
 if (!obj.counter) obj.counter = 0;
 obj.par.isAnim= obj;
 with (obj)
 {
  // Stop any existing animation.
  clearTimeout(timer);
   if (dir>0){
    menulyr.show();
    if(is.dom)menulyr.css.display="block"
   menulyr.clip(0, 0, menuwidth+2, (menuheight+2)*Math.pow(Math.sin(Math.PI*counter/200),0.75) );
  }
  // Remove clipping in NS6 on completion, seems to help old versions.
  if ((is.dom&&!is.ie) && (counter>=100)) menulyr.css.clip='';
  counter += dir;
  
  if (counter>100) {counter = 0; par.activeMenu=par.nav[id];par.isAnim=null;}
  else timer = setTimeout(obj+".runAnim()",20)

 }
}

function initDivs(){
	for (var i=0;i<this.nav.length;i++){
		with(this.nav[i]){
			lyr.setRef();
			menulyr.setRef();
			if(is.ns4) menulyr.moveTo(left,(top+height));
			
			for (var j=0;j<item.length;j++){
				item[j].lyr.setRef();
				if(is.ns4){
					item[j].lyr.doc.captureEvents(Event.CLICK);
					item[j].lyr.doc.onclick= onclick;
				}
			}
		}
	}
}

function getTopVal(){
  topVal = 0;
  if (document.documentElement && document.documentElement.scrollTop)
	topVal = document.documentElement.scrollTop;
  else if (document.body)
	topVal = document.body.scrollTop;
  return topVal;
}

function getLeftVal(){
  leftVal = 0;
  if (document.documentElement && document.documentElement.scrollLeft)
	leftVal = document.documentElement.scrollLeft;
  else if (document.body)
	leftVal = document.body.scrollLeft;
  return leftVal;
}

function getWidthVal(){
  widthVal = 0;
  if (document.documentElement && document.documentElement.clientWidth)
	widthVal = document.documentElement.clientWidth;
  else if (document.body)
	widthVal = document.body.clientWidth;
  return widthVal;
}

function mouseMove(e) {
  var x = (is.ns)? e.pageX : event.x+getLeftVal();
  var y = (is.ns)? e.pageY : event.y+getTopVal();
  mouseX = x;
  mouseY = y;
  for (var j=0;j<mnList.length;j++){
	if(is.ns4){
	  	if(mnList[j].activeLabel==null) continue;
	  	with(mnList[j].activeLabel){
			if (y < top || x< left || ((x>left + width)&&mnList[j].activeMenu==null) || ((y>(top + height))&&mnList[j].activeMenu==null)){
	  		mnList[j].activeLabel.out();} 
		}
	}
	if(mnList[j].activeMenu==null)continue;
	else{
		with(mnList[j].activeMenu){
			var leftEdge = menulyr.getX();
			var rightEdge = menuwidth + leftEdge;
			var navEdge = (width+left)
			//window.status = x + " " + left
			var bottomEdge = menulyr.getY() + menuheight + 2;
			if(y>bottomEdge|| y<top || x<leftEdge || x>(rightEdge) || ((x>navEdge) && y<top+height) ){
				closeItems(mnList[j].activeMenu)
		}
		}
	}
 }
	return true;
}

function onclick(e){
var x = e.pageX
var y = e.pageY
for (var j=0;j<mnList.length;j++){
	eventY = (y - mnList[j].activeMenu.bottom)
	i = Math.floor((eventY+1)/(mnList[j].activeMenu.item[0].height+1))
	document.location.replace(mnList[j].activeMenu.item[i].url)
}
}
mnList = new Array();

document.onmousemove = mouseMove;
if (is.ns4) document.captureEvents(Event.MOUSEMOVE);
var nsWinW = window.innerWidth, nsWinH = window.innerHeight, popOldOR = window.onresize;
window.onresize = function()
{
 if (popOldOR) popOldOR();
 if (is.ns4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) history.go(0);
}
//global mouse coord
var mouseX;
var mouseY;
