//********************************************************************************************************
//       Author: Chad McKee
//      Company: StarTech Computing, Inc.
//    Copyright: Copyright © 2002 StarTech Computing, Inc.  All rights reserved.
//Last Modified: 10/17/2002
//      Version: 1.0
//********************************************************************************************************
	function objReadProperty(){
		this.getLinkProperty = function (vProperty){
			var tempString = "";
			tempString = this.addToPropertyString("class", vProperty.getStyleClass());
			tempString += this.addToString(this.addToPropertyString("target", vProperty.getTarget()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));
			tempString += this.addToString(this.addToPropertyString("id", vProperty.getID()));
			return tempString;
		}
		this.getCellProperty = function (vProperty){
			var tempString = "";
			
			tempString = this.addToPropertyString("width", vProperty.getWidth());
			tempString += this.addToString(this.addToPropertyString("height", vProperty.getHeight()));
			tempString += this.addToString(this.addToPropertyString("class", vProperty.getStyleClass()));
			tempString += this.addToString(this.addToPropertyString("valign", vProperty.getvAlign()));
			tempString += this.addToString(this.addToPropertyString("align", vProperty.getAlign()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));
			
			return tempString;
		}
		this.getRowProperty = function (vProperty) {
			var tempString = "";
				
			tempString = this.addToPropertyString("height", vProperty.getHeight());
			tempString += this.addToString(this.addToPropertyString("class", vProperty.getStyleClass()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));	
						
			return tempString;
		}
		this.getTableProperty = function (vProperty) {
			var tempString = "";
				
			tempString += this.addToString(this.addToPropertyString("width", vProperty.getWidth()));
			tempString += this.addToString(this.addToPropertyString("height", vProperty.getHeight()));
			tempString += this.addToString(this.addToPropertyString("cellpadding", vProperty.getCellPadding()));
			tempString += this.addToString(this.addToPropertyString("cellspacing", vProperty.getCellSpacing()));
			tempString += this.addToString(this.addToPropertyString("bgcolor", vProperty.getBackGroundColor()));
			tempString += this.addToString(this.addToPropertyString("bordercolor", vProperty.getBorderColor()));
			tempString += this.addToString(this.addToPropertyString("valign", vProperty.getvAlign()));
			tempString += this.addToString(this.addToPropertyString("align", vProperty.getAlign()));
			tempString += this.addToString(this.addToPropertyString("border", vProperty.getBorderSize()));
			tempString += this.addToString(this.addToPropertyString("class", vProperty.getStyleClass()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));
			tempString += this.addToString(this.addToPropertyString("id", vProperty.getID()));
			
			return tempString;
		}
		
		
		this.getLayerProperty = function (vProperty){
			var tempString = "z-index=\"100\"";
			
			tempString += this.addToString(this.addToPropertyString("width", vProperty.getWidth()));
			tempString += this.addToString(this.addToPropertyString("bgcolor", vProperty.getBackGroundColor()));
			tempString += this.addToString(this.addToPropertyString("visibility", "hide"));
			tempString += this.addToString(this.addToPropertyString("top", vProperty.getTop()));
			tempString += this.addToString(this.addToPropertyString("left", vProperty.getLeft()));
			tempString += this.addToString(this.addToPropertyString("id", vProperty.getID()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));
			
			return tempString;
		}
		this.getDIVProperty = function (vProperty){
			var tempString = "";
			
			tempString = this.addToPropertyString("style", "Z-INDEX:100;position:absolute;visibility:hidden;padding-left:0px;width:" + vProperty.getWidth() + "px;top:" + vProperty.getTop() + "px;left:" + vProperty.getLeft() + "px;background:" + vProperty.getBackGroundColor() + ";");
			tempString += this.addToString(this.addToPropertyString("id", vProperty.getID()));
			tempString += this.addToString(this.addToPropertyString("onMouseOver", vProperty.getonMouseOver()));
			tempString += this.addToString(this.addToPropertyString("onMouseOut", vProperty.getonMouseOut()));
			
			return tempString;
		}
		this.addToPropertyString = function (vProperty, vValue){
			if (vValue + "" == "" || vValue == -1){
				return "";
			}else{
				return vProperty + "=\"" + vValue + "\"";
			}		
		}
		this.addToString = function (vCurrentString){
			if (vCurrentString == "") {
				return "";
			}else{
				return " " + vCurrentString;
			}
		}
		
	}
//********************************************************************************************************
	function objHTML(){
		objReadProperty.call(this);
		this.createRow = function (vProperies, vContent){
			return "<TR" + this.addToString(this.getRowProperty(vProperies)) + ">" + vContent + "</TR>";	
		}
		this.createCell = function (vProperies, vContent){
			return "<TD" + this.addToString(this.getCellProperty(vProperies)) + ">" + vContent + "</TD>";		
		}
		this.createTable = function (vProperies, vContent){
			return "<TABLE" + this.addToString(this.getTableProperty(vProperies)) + ">" + vContent + "</TABLE>";
		}
		this.createLayer = function (vProperies, vContent){
			return "<LAYER" + this.addToString(this.getLayerProperty(vProperies)) + ">" + vContent + "</LAYER>";
		}
		this.createDIV = function (vProperies, vContent){
			return "<DIV" + this.addToString(this.getDIVProperty(vProperies)) + ">" + vContent + "</DIV>";
		}
		this.createLink = function (vProperies, vContent, vLink){
			return "<A href=\"" + vLink + "\"" + this.addToString(this.getLinkProperty(vProperies)) + ">" + vContent + "</A>";
		}
	}
//********************************************************************************************************
	function objProperies(){
		if (arguments.length == 1){
			var mbgColor = arguments[0].getBackGroundColor();
			var mBorderColor = arguments[0].getBorderColor();
			var mStyleClass = arguments[0].getStyleClass();
			var mHeight = arguments[0].getHeight();
			var mWidth = arguments[0].getWidth();
			var mCellSpacing = arguments[0].getCellSpacing();
			var mCellPadding = arguments[0].getCellPadding();
			var mTop = arguments[0].getTop();
			var mLeft = arguments[0].getLeft();
			var mBorderSize = arguments[0].getBorderSize();
			var mTarget = arguments[0].getTarget();
			var mvAlign = arguments[0].getvAlign();
			var mAlign = arguments[0].getAlign();
			var monMouseOver = arguments[0].getonMouseOver();
			var monMouseOut = arguments[0].getonMouseOut();
			var mID = arguments[0].getID();
			var mArrowImage = arguments[0].getArrow();
		}else{
			var mbgColor = "";
			var mBorderColor = "#000000";
			var mStyleClass = "";
			var mHeight = -1;
			var mWidth = -1;
			var mCellSpacing = 0;
			var mCellPadding = 0;
			var mTop = -1;
			var mLeft = -1;
			var mBorderSize = 0;
			var mTarget = "";
			var mvAlign = "";
			var mAlign = "";
			var monMouseOver = "";
			var monMouseOut = "";
			var mID = "";
			var mArrowImage = "";	
		}
		this.setBackGroundColor = function(vColor){mbgColor = vColor;}
		this.getBackGroundColor = function(){return mbgColor;}
		this.setBorderColor = function(vColor){mBorderColor = vColor;}
		this.getBorderColor = function(){return mBorderColor;}
		this.setStyleClass = function(vClassName){mStyleClass = vClassName;}
		this.getStyleClass = function(){return mStyleClass;}
		this.setHeight = function(vHeight){mHeight = vHeight;}
		this.getHeight = function(){return mHeight;}
		this.setWidth = function(vWidth){mWidth = vWidth;}
		this.getWidth = function(){return mWidth;}
		this.setTop = function(vTop){mTop = vTop;}
		this.getTop = function(){return mTop;}
		this.setLeft = function(vLeft){mLeft = vLeft;}
		this.getLeft = function(){return mLeft;}
		this.setCellSpacing = function(vCellSpacing){mCellSpacing = vCellSpacing;}
		this.getCellSpacing = function(){return mCellSpacing;}
		this.setCellPadding = function(vCellPadding){mCellPadding = vCellPadding;}
		this.getCellPadding = function(){return mCellPadding;}
		this.setBorderSize = function(vBorderSize){mBorderSize = vBorderSize;}
		this.getBorderSize = function(){return mBorderSize;}
		this.setTarget = function(vTarget){mTarget = vTarget;}
		this.getTarget = function(){return mTarget;}
		this.setvAlign = function(vAlign){mvAlign = vAlign;}
		this.getvAlign = function(){return mvAlign;}
		this.setAlign = function(vAlign){mAlign = vAlign;}
		this.getAlign = function(){return mAlign;}
		this.setonMouseOver = function(vScript){monMouseOver = vScript;}
		this.getonMouseOver = function(){return monMouseOver;}
		this.setonMouseOut= function(vScript){monMouseOut = vScript;}
		this.getonMouseOut = function(){return monMouseOut;}
		this.setID= function(vID){mID= vID;}
		this.getID = function(){return mID;}
		this.setArrow = function(vArror){mArrowImage = vArror;}
		this.getArrow = function(){return mArrowImage;}	
	}
//********************************************************************************************************	
	function objMenuItem(){
		var mHasSub = false;
		var mSubMenu;
		var mParentMenu;
		var mRowProp;
		var mCellProp;
		var mLinkProp;
		var mLink;
		var mDisplayText;
		var mTarget;
		var mSubMenuPic = "";
		
		objHTML.call(this);
		
		this.setSubMenu = function(vSubMenu){
			mHasSub = true;
			mSubMenu = vSubMenu;
		}
		this.getSubMenu = function(){return mSubMenu;}
		this.hasSubMenu = function(){return mHasSub;}
		this.setParentMenu = function(vParentMenu){mParentMenu = vParentMenu;}
		this.genLink = function(){
			var tempString = "";
			var tempTable = "";
			
			var tempProperty = new objProperies();
	
			mLinkProp.setTarget(mTarget);
			if (mHasSub){
				mLinkProp.setonMouseOver("objMenus.showMenu('" + mSubMenu + "');objMenus.updateMenu('" + mParentMenu + "', '" + mSubMenu + "')");
				tempProperty.setonMouseOver("objMenus.showMenu('" + mSubMenu + "');objMenus.updateMenu('" + mParentMenu + "', '" + mSubMenu + "')");
			}else{
				mLinkProp.setonMouseOver("objMenus.updateMenu('" + mParentMenu + "', '')");
				tempProperty.setonMouseOver("objMenus.updateMenu('" + mParentMenu + "', '')");
			}
			tempProperty.setAlign(mCellProp.getAlign());
			tempProperty.setvAlign(mCellProp.getvAlign());
			tempTable = this.createCell(tempProperty, this.createLink(mLinkProp, mDisplayText, mLink));
			tempProperty.setAlign("center");
			tempProperty.setvAlign("middle");
			tempProperty.setWidth(0);
			if (mHasSub && mSubMenuPic != "") {
				tempTable += this.createCell(tempProperty,"<IMG src=\"" + mSubMenuPic + "\">");
			}else{
				tempTable += this.createCell(tempProperty,"");
			}
			tempProperty.setWidth("100%");
			tempProperty.setAlign("left");
			tempProperty.setvAlign("top");
			tempTable = this.createTable(tempProperty, this.createRow(tempProperty, tempTable));
			
			return this.createRow(mRowProp, this.createCell(mCellProp, tempTable));;
		}
		this.setLink = function(vLink, vDisplayText, vTarget){
			mLink = vLink;
			mDisplayText = vDisplayText;
			mTarget = vTarget;
		}
		this.setCellProperty = function(vProperty){mCellProp = new objProperies(vProperty);}
		this.setLinkProperty = function(vProperty){mLinkProp = new objProperies(vProperty);}
		this.setRowProperty = function(vProperty){mRowProp = new objProperies(vProperty);}
		this.setSubMenuPic = function(vPath){mSubMenuPic = vPath;}
	}
//********************************************************************************************************	
	function objMenu(){
		var mMenuItems = new Array();
		var mNumberOfItems = 0;
		var mRowProp;
		var mCellProp;
		var mLinkProp;
		var mTableProp;
		var mPositionProp;
		var mLeft;
		var mTop;
		var mLeft;
		var mMenuName = "";
		var mLinkPath = "";
		var mMenuOpen = false;
		
		objHTML.call(this);
		this.addMenuItem = function(vLink, vDisplayText, vTarget){
			mMenuItems[mNumberOfItems] = new objMenuItem();
			mMenuItems[mNumberOfItems].setSubMenuPic(mLinkPath);
			mMenuItems[mNumberOfItems].setCellProperty(mCellProp);
			mMenuItems[mNumberOfItems].setLinkProperty(mLinkProp);
			mMenuItems[mNumberOfItems].setRowProperty(mRowProp);
			mMenuItems[mNumberOfItems].setLink(vLink, vDisplayText, vTarget);
			mMenuItems[mNumberOfItems].setParentMenu(mMenuName);
			mNumberOfItems++;
		}
		this.addSubMenuToLast = function(vMenu){mMenuItems[mNumberOfItems-1].setSubMenu(vMenu);}
		this.genMenu = function(){
			var i;
			var tempString = "";
			for(i=0; i<mNumberOfItems; i++){
				tempString += mMenuItems[i].genLink();
			}
			mPositionProp.setID(mMenuName);
			if(this.getBrowserType() == "doLayer"){
				tempString = this.createLayer(mPositionProp, this.createTable(mTableProp, tempString));
			}else{
				tempString = this.createDIV(mPositionProp, this.createTable(mTableProp, tempString));
			}
			document.write(tempString);
			//alert(tempString); 
		}
		this.getBrowserType = function(){
			var vBrowser;
			
			if (document.layers){
				//Netscape 4 specific code
					vBrowser = "doLayer";
				}
			if (document.getElementById){
			//Netscape 6 specific code
				if (window.navigator.appName != "Microsoft Internet Explorer"){
					vBrowser = "doNDiv";
				}
			}
			if (document.all){
				//IE4+ specific code
				vBrowser = "doDiv";
			}
			return vBrowser;
		}
		this.getSubMenuArray = function(vtempArray){
			var i = 0;
			var j = 0;
			for(i=0; i<mNumberOfItems; i++){
				if (mMenuItems[i].hasSubMenu()){
					vtempArray[j] = mMenuItems[i].getSubMenu();
					j++;
				}
			}
		}
		this.showNav = function(){
			var vBrowser = this.getBrowserType();
			var theObj;
			if(vBrowser=="doLayer"){
				theObj = document.layers[mMenuName];
  				if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
			}
			else if(vBrowser=="doDiv"){
				theObj=document.all[mMenuName];
				if (theObj) if(theObj.style.visibility=='hidden'){theObj.style.visibility = 'visible'}
			}
			else{
				theObj=document.getElementById(mMenuName);
				if (theObj) if(theObj.style.visibility=='hidden'){theObj.style.visibility = 'visible';}
			}
			mMenuOpen = true;
		}
		this.hideNav = function(){
			var vBrowser = this.getBrowserType();
			var theObj;
			if(this.getBrowserType()=="doLayer"){
				theObj = document.layers[mMenuName];
				if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
			}
			else if(this.getBrowserType()=="doDiv"){
				theObj=document.all[mMenuName];
				if (theObj) if(theObj.style.visibility=='visible'){theObj.style.visibility = 'hidden'}
				}
			else{
				theObj=document.getElementById(mMenuName);
				if (theObj) if(theObj.style.visibility=='visible'){theObj.style.visibility = 'hidden';}
			}
			mMenuOpen = false;
		}
		this.isMenuOpen = function(){return mMenuOpen;}
		this.setCellProperty = function(vProperty){mCellProp = new objProperies(vProperty);}
		this.setLinkProperty = function(vProperty){mLinkProp = new objProperies(vProperty);}
		this.setRowProperty = function(vProperty){mRowProp = new objProperies(vProperty);}
		this.setTableProperty = function(vProperty){mTableProp = new objProperies(vProperty);}
		this.setPositionProp = function(vProperty){mPositionProp = new objProperies(vProperty);}
		this.setLinkPath = function(vLink){mLinkPath = vLink;}
		this.setMenuName = function(vName){mMenuName = vName;}
		this.getMenuName = function(){return mMenuName;}
	}
//********************************************************************************************************
	function objMainNav(){
		var mMenus = new Array();
		var mRootMenus = new Array();
		var mNumberOfMenus = 0;
		var mRowProp;
		var mCellProp;
		var mLinkProp;
		var mTableProp;
		var mPositionProp;
		var mImageLink;
		var mTimerInterval = 0;
		var mTimer;
				
		this.addRootMenus = function(){
			var i = 0;
			for(i=0; i<arguments.length; i++){
				mRootMenus[mRootMenus.length] = arguments[i];
			}
		}
		
		this.updateRootMenus = function(vMenu){
			var i = 0;
			for (i=0; i<mRootMenus.length; i++){
				if (vMenu != ""){
					if(vMenu != mRootMenus[i]){
						this.closeMenu(mRootMenus[i]);
					}
				}else{
					this.closeMenu(mRootMenus[i]);
				}
			}
			if (vMenu == "" && mTimerInterval != 0){
				//Clears Timer
				window.clearInterval(mTimer);
			}
		}
		this.addToMenu = function(vMenuName, vLink, vDisplayText, vTarget, vSubMenu){		
			var vMenuNumber = 0;
			vMenuNumber = this.findMenu(vMenuName);
			if(vMenuNumber != -1){
				mMenus[vMenuNumber].addMenuItem(vLink, vDisplayText, vTarget);
				if(vSubMenu != ""){mMenus[vMenuNumber].addSubMenuToLast(vSubMenu);}
			}
		}
	
		this.createNewMenu = function(vName, vTop, vLeft, vWidth){
			mMenus[mNumberOfMenus] = new objMenu();
			mMenus[mNumberOfMenus].setMenuName(vName);
			mMenus[mNumberOfMenus].setLinkPath(mImageLink);
			mPositionProp.setTop(vTop);
			mPositionProp.setLeft(vLeft);
			mPositionProp.setWidth(vWidth);
			mMenus[mNumberOfMenus].setCellProperty(mCellProp);
			mMenus[mNumberOfMenus].setLinkProperty(mLinkProp);
			mMenus[mNumberOfMenus].setRowProperty(mRowProp);
			mMenus[mNumberOfMenus].setTableProperty(mTableProp);
			mMenus[mNumberOfMenus].setPositionProp(mPositionProp);
			mNumberOfMenus++;
		}
		
		this.findMenu = function(vName){
			var i=0;
			
			for(i=0; i < mNumberOfMenus; i++){
				if (mMenus[i].getMenuName() == vName){
					return i;
				}
			}
			return -1;
		}
		
		this.showMenu = function (vMenu){
			var menuIndex = this.findMenu(vMenu);
			if(menuIndex != -1){
				mMenus[menuIndex].showNav();	
			}
			if (mTimerInterval != 0){
				//Sets Timers
				window.clearInterval(mTimer);
				mTimer = window.setInterval("objMenus.updateRootMenus('');", mTimerInterval);
			}
		}
		
		this.updateMenu = function (vMenu, vDontClose){
			var menuIndex = this.findMenu(vMenu);
			var tempArray = new Array();
			var i = 0;
			if(menuIndex != -1){
				mMenus[menuIndex].getSubMenuArray(tempArray);	
			}
			for(i=0; i<tempArray.length; i++){
				if (vDontClose != ""){
					if (tempArray[i] != vDontClose){
						this.closeMenu(tempArray[i]);
					}
				}else{
					this.closeMenu(tempArray[i]);	
				}
			} 
		}
		this.closeMenu = function (vMenu){
			var menuIndex = this.findMenu(vMenu);
			var tempArray = new Array();
			var i = 0;
			if(menuIndex != -1){
				if (mMenus[menuIndex].isMenuOpen()){
					mMenus[menuIndex].getSubMenuArray(tempArray);	
					for(i=0; i<tempArray.length; i++){
						this.closeMenu(tempArray[i]);
					}
					mMenus[menuIndex].hideNav();
				}
			}			
		}
		
		this.genMenus = function(){
			var i;
			for(i=0; i<mNumberOfMenus; i++){
				mMenus[i].genMenu();
			}	
		}
		this.setCellProperty = function(vProperty){mCellProp = vProperty;}
		this.setLinkProperty = function(vProperty){mLinkProp = vProperty;}
		this.setRowProperty = function(vProperty){mRowProp = vProperty;}
		this.setTableProperty = function(vProperty){mTableProp = vProperty;}
		this.setPositionProp = function(vProperty){mPositionProp = vProperty;}
		this.setImageLink = function(vLink){mImageLink = vLink;}
		this.setTimer = function(vMSeconds){mTimerInterval = vMSeconds;}
	}
//********************************************************************************************************	
	function clearMenus(){
		if (!menuTimerSet){
			menuTimer = window.setInterval("runEvent()", 250);
			menuTimerSet = true;
		}
	}
//********************************************************************************************************	
	function runEvent(){
		if (menuTimerSet){
			window.clearInterval(menuTimer);
			objMenus.updateRootMenus('');
			menuTimerSet = false;
		}
	}
//********************************************************************************************************	
	//Prototypes
	objHTML.prototype = new objReadProperty();
	objMenuItem.prototype = new objHTML();
	objMenu.prototype = new objHTML();
//********************************************************************************************************	
	var menuTimer;
	var menuTimerSet = false;
	var objMenus = new objMainNav();
//********************************************************************************************************
	var objLinkProperties = new objProperies();
	var objRowProperties = new objProperies();
	var objCellProperties = new objProperies();
	var objTableProperties = new objProperies();
	var objPositionTagProperties = new objProperies();
	
	//Set the properties of the Table, Links, Rows and cells
	objTableProperties.setBackGroundColor("#E1E1E1");
	objTableProperties.setWidth("100%");
	objTableProperties.setBorderSize(1);
	objTableProperties.setBorderColor("#D4D4D5");
	objTableProperties.setCellPadding(3);
	objTableProperties.setCellSpacing(0);
	objLinkProperties.setStyleClass("MenuText");
	objCellProperties.setvAlign("middle");
	objCellProperties.setAlign("left");
	objCellProperties.setHeight(21);
	objPositionTagProperties.setBackGroundColor("");
	objMenus.setImageLink("/Images/Arrow.gif");
	objMenus.setTimer(6000);
	objMenus.setCellProperty(objCellProperties);
	objMenus.setLinkProperty(objLinkProperties);
	objMenus.setRowProperty(objRowProperties);
	objMenus.setTableProperty(objTableProperties);
	objMenus.setPositionProp(objPositionTagProperties);	
//********************************************************************************************************	
	
	var RootMenuHeight
	var SubMenuHeight = 21;
	
	RootMenuHeight = 21;
	if (document.getElementById){
	//Netscape 6 specific code
		if (window.navigator.appName != "Microsoft Internet Explorer"){
			RootMenuHeight = 22;
		}
	}

	objTableProperties.setBackGroundColor("#E1E1E1");
	objLinkProperties.setStyleClass("MenuText");
//********************************************************************************************************	
