// oNav - BMW Version
// (c) 2003 James Alcide Park (jalcide@jalcide.com). All Rights Reserved.
// a dynamic navigation/menuing creation object that is driven by an object-oriented/nested data structure.
// ver 1.0.2 BMW Version
// last updated: 2003.11.14
// required libs: standardECMAprototypes, dynapi, tTween, broadcaster, rpenner easing equations
// comments or bugs to jim.park@fallon.com/jalcide@jalcide.com

// oNav class constructor
NavClass = function() {
	this.nav = new Object();
	this.version = '1.0.0 AJNH Version';
};
// public methods
NavClass.prototype.getVersion = function(){
	return this.version;
};
NavClass.prototype.showVersion = function(){
	alert(this.getVersion());
};
String.prototype.crunch = function(){
	var sResult = this;
	var aryChars = [" ", ".", "-", "/", "_", "&", "#", "'", "?", ":", "*", "`", "ª", "\""];
	for(var i=0; i<aryChars.length; i++){
		sResult = sResult.split(aryChars[i]).join("").toLowerCase();
	}
	return sResult;	
};
NavClass.prototype.init = function(o){
	var sBgColor = "#"+window._oColors.colours.palette[window._sColorPaletteId].top_area.background.hex_value;
	var args = this._getUrlArgs();
	this._disableAnim = true;
	//this.setDebug(true);
	if(args.oNav_debug){
		_debug = args.oNav_debug;
	}
	else {
		_debug = false;
	}
	var _vis;
	_vis = true;
	if(args.oNav_vis){
		if(typeof args.oNav_vis == "string"){
			if(args.oNav_vis == 'true'){
				_vis = true;
			}
			else {
				_vis = false;
			}
		}
		else {
			_vis = args.oNav_vis;
		}
	}
	if(args.oNav_disableDescNavigation){
		_disableDescNavigation = args.oNav_disableDescNavigation;
	}
	else {
		_disableDescNavigation = false;
	}
	if(!this._getDebug()){
		if(!_debug){
			this.setDebug(false);
		}
		else {
			this.setDebug(_debug);
		}
	}
	if(this._getDebug()){alert('oNav init called.');}
	this._createRelationshipProps(o);
	this.nav = o;
	if(typeof _disableDescNavigation == "string"){
		if(_disableDescNavigation == 'true'){
			b = true;
		}
		else {
			b = false;
		}
	}
	else {
		b = _disableDescNavigation;
	}
	this._disableDescNavigation = b; // disable First Time SetLoc _setURL
	this.nav._crumbsBroadcaster = new Object();
	this._setLocQ_ary = new Array();
	if(!window.Broadcaster){
		window.Broadcaster = new BroadcasterClass();
	}
	window.Broadcaster.initialize(this.nav._crumbsBroadcaster);
	if(window.lp){
		this._setStyle_c(window.lp);
	}
	this.nav._crumbs = new Object();
	//this.nav._navLyr = new DynLayer('nav_lyr',this.nav._navAttribs.NAV_X,this.nav._navAttribs.NAV_Y,178,240,'#ffffff');
	this.nav._navLyr = window.document.createElement("DIV");
	$(this.nav._navLyr).setAttribute("id", "nav_lyr");
	this.nav._navLyr.setStyle({
		cssFloat:"left",
		position:"relative",
		left:"0px",
		top:"0px",
		width:"100%",
		height:"10px"
	});
	$("divMainNavArea").appendChild(this.nav._navLyr);
	
	//this.nav._navLyr.setSelectable(false);
	//this.nav._navLyr.setZIndex(999); // set on top of all layers
	if(_vis == true){
		this.nav._navLyr.show();
	}
	if(_vis == false){
		this.nav._navLyr.hide();
	}
	
	//this.nav._navLyr._bgLyr = new DynLayer('bg_lyr',0,0,178,240,'#ffffff');
	this.nav._navLyr._bgLyr = window.document.createElement("DIV");
	$(this.nav._navLyr._bgLyr).setAttribute("id", "bg_lyr");
	this.nav._navLyr._bgLyr.setStyle({
		cssFloat:"left",
		position:"relative",
		left:"0px",
		top:"0px",
		width:"100%",
		height:"10px"
	});
	this.nav._navLyr.appendChild(this.nav._navLyr._bgLyr);
	//this.nav._navLyr._bgLyr.setSelectable(false);
	this.nav._navLyr._bgLyr._moveUp = function(amt){
		window.oNav.nav._navLyr._bgLyr._move(amt,-1);
	};
	this.nav._navLyr._bgLyr._moveDown = function(amt){
		window.oNav.nav._navLyr._bgLyr._move(amt,1);
	};
	
	this.nav._navLyr._bgLyr._move = function(amt, dir){
		if(window.oNav._disableAnim != true){
			window.oNav.nav._navLyr._bgLyr.tween('_y',styleStrToNum(window.oNav.nav._navLyr._bgLyr.getStyle("top"))+(amt*dir),260,'easeInOutCirc');
		}
		else {
			window.oNav.nav._navLyr._bgLyr.setStyle({top:styleStrToNum(window.oNav.nav._navLyr._bgLyr.getStyle("top"))+(amt*dir)}); // TEST ONLY DELETE THIS LATER
		}
	};

	this._inAnim = false;
	this._inAnimItr = 0;
	this._addLyrs(o);
	if(window.cms_oNav_loc){
		this.setLoc(window.cms_oNav_loc);
	}
	else {
		if(args.oNav_loc){
			//this._cbQ_push(50,this,'setLoc',args.oNav_loc);
			this.setLoc(args.oNav_loc);
		}
	}
	if(args.oNav_locGoto){
		//this._cbQ_push(50,this,'d',args.oNav_locGoto);
		this.setLocGoto(args.oNav_locGoto);
	}
	
};
NavClass.prototype.setLocGoto = function(str){
	if(this._getDebug()){alert('oNav setLocGoto called: '+str);}
	this._locGoto = true;
	this.setLoc(str);
};
NavClass.prototype.setLoc = function(str){
	if(this._getDebug()){alert('oNav setLoc called: '+str);}
	if(!this._locGoto || this._locGoto == false){
		this._loc = true;
	}
	else {
		this._loc = false;
	}
	var sIframeGotoUrlViaBookmark;
	if(!str){
		// TODO _root/backwards handling here
	}
	else {
		if(str.substring(5,0) == '_root'){
			str = str.substring(6,str.length); // strip '_root' from beginning of string
		}
		if(str.indexOf('---') != -1){
			sIframeGotoUrlViaBookmark = str.substring(str.indexOf('---')+3, str.length);
			str = str.substring(0,str.indexOf('---')); // strip '---' sIframeGotoUrlViaBookmark designator from beginning of string
		}
	}
	var oRecur;
	var o_ary = new Array();
	if(str != ''){
		o_ary = str.split('/');
		_recurObj = function(o,i){
			if(i<o_ary.length){
				for(var j=0; j<o["area"].length; j++){
					if(o["area"][j].title){
						//alert(o["area"][j].title.crunch()+" - "+o_ary[i]);
						if(o["area"][j].title.crunch() == o_ary[i]){
							oRecur = o["area"][j];
							oRecur.iframeGotoUrlViaBookmark = sIframeGotoUrlViaBookmark; // a hack for now, since it's only one depth now, we can do this
							if(pageTracker && window._bTrackingEnabled == true){ // if google analytics is found
								pageTracker._trackPageview("/main/"+o_ary[i]);
								//window.status = "/main/"+o_ary[i];
							}
						}
					}
				}
				i++;
				if(oRecur){ // if there is a valid nav node
					window.oNav._setLocQ_push(oRecur);
					_recurObj(oRecur,i);
				}
			}
		};
		if(!this._getLoc()){
			_recurObj(this.nav,0);
		}
		else {
			//_recurObj(this._getLoc(),0);
			_recurObj(this.nav,0);
		}
		this._setLocQ_pop();
	}
};
NavClass.prototype.getLoc = function(){
	if(this._getDebug()){alert('oNav getLoc called.');}
	return this._curLoc._namespc;
};
NavClass.prototype._getLoc = function(){
	if(this._getDebug()){alert('oNav _getLoc called.');}
	return this._curLoc;
};
NavClass.prototype.setVis = function(bool){
	if(this._getDebug()){alert('oNav setVis called: '+bool);}
	var b;
	if(typeof bool == "string"){
		if(bool == 'true'){
			b = true;
		}
		else {
			b = false;
		}
	}
	else {
		b = bool;
	}
	this._visible = b;
	if(b){
		this.nav._navLyr.setStyle({left:"0px"});
	}
	else {
		this.nav._navLyr.setStyle({left:"-300px"});
	}
	if(b){
		this.nav._navLyr.show();
	}
	else{
		this.nav._navLyr.hide();
	}
};
NavClass.prototype.getVis = function(){
	if(this._getDebug()){alert('oNav getVis called.');}
	return this._visible;
};
/*NavClass.prototype.hide = function(){
	if(this._getDebug()){alert('oNav hide called.');}
	this.setVis(false);
};
NavClass.prototype.show = function(){
	if(this._getDebug()){alert('oNav show called.');}
	this.setVis(true);
};*/
NavClass.prototype.setDebug = function(bool){
	var b;
	if(typeof bool == "string"){
		if(bool == 'true'){
			b = true;
		}
		else {
			b = false;
		}
	}
	else {
		b = bool;
	}
	this._debug = b;
};
// Priv methods
NavClass.prototype._getUrlArgs = function(){
	if(this._getDebug()){alert('oNav _getUrlArgs called.');}
	var args = new Object();
	var query = window.document.location.search.substring(1);
	var pairs = query.split("&");
	for(var i=0; i<pairs.length; i++){
		var pos = pairs[i].indexOf('=');
		if (pos == -1){
			continue;
		}
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);
	}
	return args;
};
NavClass.prototype._getDebug = function(){
	return this._debug;
};
NavClass.prototype._setLocQ_push = function(o){
	this._setLocQ_ary.push(o);
};
NavClass.prototype._setLocQ_pop = function(){
	if(this._setLocQ_ary.length != 0){
		o = this._setLocQ_ary.shift();	
		//alert('|||popping: '+o._name);
		if(o._name){
			if(this._getDebug()){alert('oNav _setLocQ_pop called on: '+o._name);}
		}
		if(this._setLocQ_ary.length != 0){
			this._disableSetURL = true;
		}
		else {
			this._disableSetURL = false;
		}
		if(o._numOfChildren != 0){
			o._parent._myBcaster.broadcastMessage('_onNavOff',o);
		}
		else {
			o._parent._myBcaster.broadcastMessage('_onSelctd',o);
		}
	}
};
NavClass.prototype._setCurLoc = function(o){
	if(this._getDebug()){alert('oNav _setCurLoc called on: '+o._namespc);}
	this._curLoc = o;
};
NavClass.prototype._getCurLoc = function(){
	if(this._getDebug()){alert('oNav _getCurLoc called on: '+o._namespc);}
	return this._curLoc._namespc;
};
NavClass.prototype._createRelationshipProps = function(o){
	var type;
	var i=0;
	o._numOfChildren = this._getCount(o);
	for (var p in o){
		if(p.substring(0,4) == "area"){
			if(!o[p][0]){ // if only one area, or if each area is named something different
				alert("NavClass.js line 333: Should not get here.");
				type = typeof o[p];
				if (type == "object"){
					i++;
					if(!o._parent){
						rootParent = new Object();
						rootParent._name = '_god';
						rootParent._numOfChildren = this._getCount(this.nav);
						o._numOfParents = 0;
						rootParent._ordinal = 0;
						o._parent = this.nav;
						o._numOfParents = 1;
						o._name = '_root';
						o._namespc = '_root';
						o._ordinal = 0;
					}
					o[p]._parent = o;
					o[p]._name = o[p].title;
					o[p]._objRefName = p;
					o[p]._namespc = o._namespc+'.'+o[p].title.crunch();
					o[p]._ordinal = i;
					o[p]._numOfParents = o._numOfParents+1;
					this._createRelationshipProps(o[p]); // recur through entire data structure
				}
				else {
					if (type == "string"){
						continue;
					}
				}
			}
			else{ // an array of area nodes (admin tool compliant version)
				for(var j=0; j<o[p].length; j++){
					type = typeof o[p][j];
					//alert(j+" - "+o[p][j].title);
					if (type == "object"){
						if(!o._parent){
							rootParent = new Object();
							rootParent._name = '_god';
							rootParent._numOfChildren = this._getCount(this.nav);
							o._numOfParents = 0;
							rootParent._ordinal = 0;
							o._parent = this.nav;
							o._numOfParents = 1;
							o._name = '_root';
							o._namespc = '_root';
							o._ordinal = 0;
						}
						o[p][j]._parent = o;
						o[p][j]._name = o[p][j].title;
						o[p][j]._objRefName = p;
						o[p][j]._namespc = o._namespc+'.'+o[p][j].title.crunch();
						o[p][j]._ordinal = j;
						o[p][j]._numOfParents = o._numOfParents+1;
						this._createRelationshipProps(o[p][j]); // recur through entire data structure
					}
					else {
						if (type == "string"){
							continue;
						}
					}
				}
			}
		}
	}
};
NavClass.prototype._addLyrs = function(o){
	if(this._getDebug()){alert('oNav _addLyrs called on: '+o._name);}
	var type;
	for (var p in o){
		if(!o[p][0]){ // if only one area, or if each area is named something different
			/*alert("NavClass.js line 404: Should not get here.");
			if(p.substring(0,4) == "area"){
				type = typeof o[p];
				if (type == "object"){
					this._addLyrs_divs(o,p);
					//this._addLyrs(o[p]); // recur through entire data structure
				}
				else {
					if (type == "string"){
						continue;
					}
				}
			}*/
		}
		else{ // an array of area nodes (admin tool compliant version)
			if(p.substring(0,4) == "area"){
				for(var j=0; j<o[p].length; j++){
					this._addLyrs_divs(o[p],j);
					//this._addLyrs(o[p]); // recur through entire data structure
				}
			}
		}
	}
	//o._myBcaster.broadcastMessage('_onNavOn',o);
};
NavClass.prototype._addLyrs_divs = function(o,p){
	
	/*var sBgColor = "#"+window._oColors.colours.palette[window._sColorPaletteId].top_area.background.hex_value;
	var iColOffsetAmt = 110.5;
	var iElementYPos = ((parseInt(o[p]._ordinal)-1)%3)*15;
	if(this._getDebug()){alert('oNav _addLyrs_divs called on: '+o._name);}
	if(!o._myBcaster){
		o._myBcaster = new Object();
		window.Broadcaster.initialize(o._myBcaster);
	}
	var topMargin = 3;
	//alert("yo");
	if(o[p]._elLyr){
		alert('layer _elLyr on '+o[p]._name+' already exists. Making visible.');
		o[p]._elLyr.show();
	}
	else {
		o[p]._origOffsetY = ((this._getCountId(o[p]))*14)+topMargin;
		//o[p]._elLyr = new DynLayer('el_'+p,15,0,165,15);
		//o[p]._elLyr.setSelectable(false);
		//this.nav._navLyr._bgLyr.addChild(o[p]._elLyr);

		o[p]._elLyr = window.document.createElement("DIV");
		$(o[p]._elLyr).setAttribute("id", "el_"+o[p]._ordinal);
		if(!this._iCurrentColOffset){
			this._iCurrentColOffset = (iColOffsetAmt+1)*-1;
		}
		if(parseInt(o[p]._ordinal)%3 == 1){
			this._iCurrentColOffset = this._iCurrentColOffset + iColOffsetAmt;
		}
		//alert(o[p]._ordinal+" - "+o[p].title+" - "+this._iCurrentColOffset+" - y: "+iElementYPos);
		o[p]._elLyr.setStyle({
			position: "absolute",
			left: this._iCurrentColOffset,
			top: iElementYPos,
			width: 125,
			height: 15
		});
		this.nav._navLyr._bgLyr.appendChild(o[p]._elLyr);
		this._setStyle_a(o[p]._elLyr);
		o[p]._onNavOff = function(so){
			window.oNav._navOff(o,p,so);
		};
		o[p]._onNavOn = function(so){
			window.oNav._navOn(o,p,so);
		};
		o[p]._onSelctd = function(so){
			//alert("broadcast rec on: "+o[p]._name+" - so: "+so._name);
			window.oNav._setSelctd(o[p],so);
		};
		o._myBcaster.addListener(o[p]);
		this._addLyrs_evnts(o,p);
	}
	o[p]._elLyr.update(o[p].title);*/

	var sBgColor = "#"+window._oColors.colours.palette[window._sColorPaletteId].top_area.background.hex_value;
	var iColOffsetAmt = 110.5;
	var iElementYPos = ((parseInt(o[p]._ordinal)-0)%3)*15;
	if(this._getDebug()){alert('oNav _addLyrs_divs called on: '+o._name);}
	if(!o[p]._parent._myBcaster){
		o[p]._parent._myBcaster = new Object();
		window.Broadcaster.initialize(o[p]._parent._myBcaster);
	}
	var topMargin = 3;
	if(o[p]._elLyr){
		//alert('layer _elLyr on '+o[p]._name+' already exists. Making visible.');
		o[p]._elLyr.show();
	}
	else {
		o[p]._origOffsetY = ((this._getCountId(o[p]))*14)+topMargin;
		//o[p]._elLyr = new DynLayer('el_'+p,15,0,165,15);
		//o[p]._elLyr.setSelectable(false);
		//this.nav._navLyr._bgLyr.addChild(o[p]._elLyr);

		o[p]._elLyr = window.document.createElement("DIV");
		$(o[p]._elLyr).setAttribute("id", "el_"+o[p]._ordinal);
		if(!this._iCurrentColOffset){
			this._iCurrentColOffset = (iColOffsetAmt+1)*-1;
		}
		if(parseInt(o[p]._ordinal)%3 == 0){
			this._iCurrentColOffset = this._iCurrentColOffset + iColOffsetAmt;
		}
		//alert(o[p]._ordinal+" - "+o[p].title+" - "+this._iCurrentColOffset+" - y: "+iElementYPos);
		o[p]._elLyr.setStyle({
			position:"absolute",
			left:(this._iCurrentColOffset).toString()+"px",
			top:(iElementYPos).toString()+"px",
			width:"125px",
			height:"15px"
		});
		this.nav._navLyr._bgLyr.appendChild(o[p]._elLyr);
		this._setStyle_a(o[p]._elLyr);
		o[p]._onNavOff = function(so){
			window.oNav._navOff(o,p,so);
		};
		o[p]._onNavOn = function(so){
			window.oNav._navOn(o,p,so);
		};
		o[p]._onSelctd = function(so){
			//alert("broadcast rec on: "+o[p]._name+" - so: "+so._name);
			window.oNav._setSelctd(o[p],so);
		};
		o[p]._parent._myBcaster.addListener(o[p]);
		this._addLyrs_evnts(o,p);
	}
	o[p]._elLyr.update(o[p].title);

};
NavClass.prototype._addLyrs_evnts = function(o,p){
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	var sRolloverColor = sRolloutColor; // top_area.main_nav_area.rollover.hex_value
	if(this._getDebug()){alert('oNav _addLyrs_evnts called on: '+o._name);}
	this.onmousedown = function(){
		if(!this._inAnim){
			o[p]._elLyr.setStyle({textDecoration:"underline"});
		}
	}
	this.onmouseup = function(){
		if(!this._inAnim){
			window.oNav._loc = false;
			window.oNav._locGoto = false;
			window.oNav._disableAnim = false;
			var numOfChildren = window.oNav._getCount(o[p]);
			if(numOfChildren != 0){
				o[p]._elLyr.setStyle({textDecoration:"underline"});
				o[p]._parent._myBcaster.broadcastMessage('_onNavOff',o[p]);
			}
			else {
				o[p]._parent._myBcaster.broadcastMessage('_onSelctd',o[p]);
			}
		}
	}
	this.onmouseover = function(){
		if(!this._inAnim && !o[p]._isSelctd){
			o[p]._elLyr.setStyle({textDecoration:"underline"});
			if(o[p]._u){
				window.status = o[p]._u;
			}
		}
	}
	this.onmouseout = function(){
		if(!this._inAnim && !o[p]._isSelctd){
			o[p]._elLyr.setStyle({textDecoration:"none"});
			window.status = "";
		}
	}
	Event.observe(o[p]._elLyr, "mouseover", this.onmouseover.bindAsEventListener(this));
	Event.observe(o[p]._elLyr, "mouseout", this.onmouseout.bindAsEventListener(this));
	Event.observe(o[p]._elLyr, "mousedown", this.onmousedown.bindAsEventListener(this));
	Event.observe(o[p]._elLyr, "mouseup", this.onmouseup.bindAsEventListener(this));
	
};
NavClass.prototype._rmvLyrs = function(o){
	if(this._getDebug()){alert('_rmvLyrs called on: '+o._name);}
	var type;
	for (var p in o){
		if(p.substring(0,4) == "area"){
			type = typeof o[p];
			if (type == "object"){
				//alert('Hiding layer _elLyr on '+o[p]._name+'.');
				o[p]._elLyr.hide();
				//this.nav._navLyr._bgLyr.removeChild(o[p]._elLyr);
				//o[p]._elLyr.deleteFromParent();
				o[p]._elLyr.removeAllEventListeners();
				//o[p]._elLyr.del();
				delete o[p]._elLyr;
			}
		}
	}
};
NavClass.prototype._addCrumb = function(o){
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	var sRolloverColor = sRolloutColor; // top_area.main_nav_area.rollover.hex_value
	if(this._getDebug()){alert('oNav _addCrumb called on: '+o._name);}
	this.nav._navLyr._bgLyr.setStyle({zIndex:styleStrToNum(this.nav._navLyr._bgLyr.getStyle("zIndex"))+1});
	if(!this.nav._crumbs_ary){
		this.nav._crumbs_ary = new Array();
	}
	//this.nav._navLyr._bgLyr.setBgImage('_images/crumb_btm5px.gif');
	//this.nav._navLyr._bgLyr.css.backgroundRepeat='no-repeat';
	var _crumb = new Object();
	_crumb._name = o._name;
	_crumb._o = o;
	_crumb._ordinal = this.nav._crumbs_ary.length;
	o._crumb_id = _crumb._ordinal;
	//_crumb._holderLyr = new DynLayer('holder_'+o._name,0,this.nav._navLyr._bgLyr.getY(),178,20);
	//_crumb._holderLyr.setSelectable(false);
	//this.nav._navLyr.addChild(_crumb._holderLyr);
	
	_crumb._holderLyr = window.document.createElement("DIV");
	$(_crumb._holderLyr).setAttribute("id", "holder_"+o._name);
	_crumb._holderLyr.setStyle({
		left:"0px",
		top:styleStrToNum(this.nav._navLyr._bgLyr.getStyle("top")),
		width:"138px",
		height:"20px"
	});
	this.nav._navLyr.appendChild(_crumb._holderLyr);
	
	
	//_crumb._arrowsLyr = new DynLayer('arrows_'+o._name,145,4,24,11);
	//_crumb._arrowsLyr.setSelectable(false);
	//_crumb._holderLyr.addChild(_crumb._arrowsLyr);
	
	_crumb._arrowsLyr = window.document.createElement("DIV");
	$(_crumb._arrowsLyr).setAttribute("id", "arrows_"+o._name);
	_crumb._holderLyr.setStyle({
		left:"145px",
		top:"4px",
		width:"24px",
		height:"11px"
	});
	_crumb._holderLyr.appendChild(_crumb._arrowsLyr);
	
	//_crumb._arrowsLyr.setBgImage('_images/arrows.gif');
	//_crumb._txtLyr = new DynLayer('txt_'+o._name,0,0,158,20);
	//_crumb._txtLyr.setSelectable(false);
	//_crumb._holderLyr.addChild(_crumb._txtLyr);
	
	_crumb._txtLyr = window.document.createElement("DIV");
	$(_crumb._txtLyr).setAttribute("id", "txt_"+o._name);
	_crumb._holderLyr.setStyle({
		left:"0px",
		top:"0px",
		width:"118px",
		height:"20px"
	});
	_crumb._holderLyr.appendChild(_crumb._txtLyr);
	
	if(this.nav._crumbs_ary.length == 0){
		//_crumb._holderLyr.setBgImage('_images/crumb_active_whenOnlyCrumb.gif');
		_crumb._holderLyr.setStyle({backgroundColor:"#999999"});
	}
	else {
		//_crumb._holderLyr.setBgImage('_images/crumb_active.gif');
		_crumb._holderLyr.setStyle({backgroundColor:"#999999"});
		_crumbPrev = this.nav._crumbs_ary[_crumb._ordinal-1];
		//_crumbPrev._holderLyr.setBgImage('_images/crumb_inactive.gif');
		_crumbPrev._holderLyr.setStyle({backgroundColor:"#888888"});
	}
	_crumb._txtLyr._oRef = o;
	this._setStyle_b(_crumb._txtLyr);
	_crumb._txtLyr.update(o.title);
	this.nav._crumbs_ary.push(_crumb);
	

	this.onmousedown = function(){
		_crumb._txtLyr.setStyle({color:sRolloverColor});
	}
	this.onmouseup = function(){
		window.oNav._loc = false;
		window.oNav._locGoto = false;
		window.oNav._disableAnim = false;
		_crumb._txtLyr.setStyle({color:sRolloverColor});
		window.oNav._rmvCrumb(lyr._oRef, lyr._oRef._crumb_id);
	}
	this.onmouseover = function(){
		_crumb._txtLyr.update(o._rovr);
		_crumb._txtLyr.setStyle({textAlign:"left"});
		_crumb._txtLyr.setStyle({color:sRolloverColor});
		//window.oNav.nav._crumbs_ary[lyr._oRef._crumb_id]._arrowsLyr.setBgImage('_images/arrows_over.gif');
	}
	this.onmouseout = function(){
		_crumb._txtLyr.setStyle({textAlign:"left"});
		_crumb._txtLyr.setStyle({color:sRolloutColor});
		_crumb._txtLyr.update(o.title);
		//window.oNav.nav._crumbs_ary[lyr._oRef._crumb_id]._arrowsLyr.setBgImage('_images/arrows.gif');
	}
	Event.observe(_crumb._txtLyr, "mouseover", this.onmouseover.bindAsEventListener(this));
	Event.observe(_crumb._txtLyr, "mouseout", this.onmouseout.bindAsEventListener(this));
	Event.observe(_crumb._txtLyr, "mousedown", this.onmousedown.bindAsEventListener(this));
	Event.observe(_crumb._txtLyr, "mouseup", this.onmouseup.bindAsEventListener(this));
	
	this.nav._navLyr._bgLyr._moveDown(20);
};
NavClass.prototype._rmvCrumb = function(o, array_id){
	if(this._getDebug()){alert('oNav _rmvCrumb called on: '+o._name+' - array_id: '+array_id);}
	this._disableDescNavigation = true; // This gives us the decending-exclusive setURL behavior, it disables asending
	var _tmp;
	if(this.nav._crumbs_ary[array_id]){
		_crumb = this.nav._crumbs_ary[array_id];
		this._setCurLoc(_crumb._o);
		var numToRemove = this.nav._crumbs_ary.length - (array_id);
		_crumbPrev = this.nav._crumbs_ary[_crumb._ordinal-1];
		if(_crumbPrev){
			if(this.nav._crumbs_ary.length-numToRemove == 1){
				//_crumbPrev._holderLyr.setBgImage('_images/crumb_active_whenOnlyCrumb.gif');
				_crumbPrev._holderLyr.setStyle({backgroundColor:"#999999"});
			}
			else {
				//_crumbPrev._holderLyr.setBgImage('_images/crumb_active.gif');
				_crumbPrev._holderLyr.setStyle({backgroundColor:"#999999"});
			}
		}
		else {
			//this.nav._navLyr._bgLyr.setBgImage('');
		}
		this.nav._navLyr._bgLyr._moveUp(20*numToRemove);
		this.nav._disableAddCrumb = true;
		_tmp = this.nav._crumbs_ary.pop();
		this.nav._disableAddCrumbRef = _tmp._o;
		_tmp._o._myBcaster.broadcastMessage('_onNavOff',_crumb._o);
		this.nav._navLyr.removeChild(_crumb._holderLyr);
		for(i=0;i<numToRemove-1;i++){
			_tmp = this.nav._crumbs_ary.pop();
		}
	}
};
NavClass.prototype._callMeth = function(o){
	if(o._m){
		if(this._getDebug()){alert('oNav _callMeth called on: '+o._name);}
		if(o._m.substring(5,0) == 'oNav.'){
			if(!o._mArg){
				this[o._m.substring(o._m.length,5)]();
			}
			else {
				this[o._m.substring(o._m.length,5)](o._mArg);
			}
		}
		else {
			if(window[o._m]){
				if(!o._mArg){
					window[o._m]();
				}
				else {
					window[o._m](o._mArg);
				}
			}
			else {
				alert('oNav notification: method \"'+o._m+'\" does not exist.');
			}
		}
	}
};
NavClass.prototype._cbQ_push = function(dly,func_obj,func_str,func_argObj){
	if(!this._cbQ){
		this._cbQ = new Object();
	}
	var myDate = new Date();
	var id = myDate.getTime();
	this._cbQ['cb_'+id] = new Object();
	this._cbQ['cb_'+id].id = id;
	this._cbQ['cb_'+id].dly = dly;
	this._cbQ['cb_'+id].func_obj = func_obj;
	this._cbQ['cb_'+id].func_str = func_str;
	this._cbQ['cb_'+id].func_argObj = func_argObj;
	this._cbQ['cb_'+id].setTimoutId = window.setTimeout('window.oNav._cbQ_pop('+id+')',dly);
	if(this._getDebug()){
		//status='_cbQ_push called - id: '+id;
	}
};
NavClass.prototype._cbQ_pop = function(id){
	//window.status = id;
	var cb = new Object();
	cb = this._cbQ['cb_'+id];
	if(this._getDebug()){
		//status = '_cbQ_pop called - id: '+id;
	}
	window.clearTimeout(cb.setTimeoutId);
	if(cb.func_argObj){
		cb.func_obj[cb.func_str](cb.func_argObj);
	}
	else {
		cb.func_obj[cb.func_str]();
	}
	delete this._cbQ['cb_'+id];
	delete cb;
};
NavClass.prototype._navOff = function(o,p,so){
	return;
	if(this._getDebug()){alert('oNav _navOff called on: '+o[p]._name+' - so: '+so._name+' - id: '+o[p]._ordinal+' of '+o._numOfChildren);}
	this._inAnim = true;
	var lyr = o[p]._elLyr;
	if(o[p] != so){
		//lyr.setStyle({color:this.nav._navAttribs.E_TXT_SUBDUED_HEX});
		lyr.setStyle({sIndex:222});
	}
	else {
		//lyr.setStyle({color:this.nav._navAttribs.E_TXT_ROV_HEX});
		lyr.setStyle({zIndex:888});
	}
	if(o[p]._ordinal < o._numOfChildren){
		if(this._disableAnim != true){
			//lyr.hide();
			lyr.setStyle({top:"200px"});
			//lyr.tween("_y", 0, 600, "easeInOutCirc");
		}
		else {
			lyr.setStyle({top:"0px"}); // TEST ONLY DELETE THIS LATER
		}
	}
	else {
		if(this._disableAnim != true){
			//lyr.hide();
			//this._postOffEvnts(so);
			//lyr.tween("_y", 0, 600, "easeInOutCirc", "_postOffEvnts", this, 100, so);
		}
		else {
			lyr.setStyle({top:"0px"}); // TEST ONLY DELETE THIS LATER
			//this._cbQ_push(50,this,'_postOffEvnts',so); // TEST ONLY DELETE THIS LATER
			this._postOffEvnts(so);
		}
	}
};
NavClass.prototype._navOn = function(o,p,so){
	return;
	if(this._getDebug()){alert('oNav _navOn called on: '+o[p]._name+' - so: '+so._name);}
	this._inAnim = true;
	var lyr = o[p]._elLyr;
	//lyr.css.color=this.nav._navAttribs.E_TXT_SUBDUED_HEX;
	if(o[p] != so){
		o[p]._isSelctd = false;
	}
	else {
		o[p]._isSelctd = true;
	}
	if(o[p]._ordinal < o._numOfChildren){
		if(this._disableAnim != true){
			lyr.show();
			//lyr.tween('_y',o[p]._origOffsetY,this.nav._navAttribs.NAV_SLIDEIN_DUR,this.nav._navAttribs.NAV_SLIDEIN_EQ);
		}
		else {
			lyr.setStyle({top:(o[p]._origOffsetY).toString()+"px"}); // TEST ONLY DELETE THIS LATER
		}
	}
	else {
		if(this._disableAnim != true){
			lyr.show();
			this._postOnEvnts(so);
			//lyr.tween('_y',o[p]._origOffsetY,this.nav._navAttribs.NAV_SLIDEIN_DUR,this.nav._navAttribs.NAV_SLIDEIN_EQ,'_postOnEvnts',this,100,so);
		}
		else {
			lyr.setStyle({top:(o[p]._origOffsetY).toString()+"px"}); // TEST ONLY DELETE THIS LATER
			//this._cbQ_push(50,this,'_postOnEvnts',so); // TEST ONLY DELETE THIS LATER
			this._postOnEvnts(so);
		}
	}
};
NavClass.prototype._postOffEvnts = function(o){
	//alert('|||_postOffEvnts: '+o._name);
	if(this._getDebug()){alert('oNav _postOffEvnts called on: '+o._name);}
	if(!this.nav._disableAddCrumb){
		this._addCrumb(o);
		this._rmvLyrs(o._parent);
		this._addLyrs(o);
	}
	else {
		this._rmvLyrs(this.nav._disableAddCrumbRef);
		this._addLyrs(o._parent);
	}
};
NavClass.prototype._setURL = function(o){
	if(this._getDebug()){alert('oNav _setURL called on: '+o._name);}
	// This method is under construction
	if(!this._disableSetURL){
		if(!this._disableDescNavigation){
			if(o._u){
				var sep;
				if(o._u.indexOf('?',0) != -1){ // if the url has arguments already, add to them
					sep = '&';
				}
				else {
					sep = '?';
				}
				//window.document.location.href = o._u+sep+'oNav_loc='+this.getLoc();
				//window.document.location.href = 'index_basic.html'+sep+'oNav_loc='+this.getLoc(); // for testing only
				window.document.title = o.title+' - ('+o.title+')'; // for testing only
				
			}
			else {
				//this._cbQ_push(50,this,'_callMeth',o);
				this._callMeth(o);
			}
		}
		else {
			this._disableDescNavigation = false;
		}
	}
};
NavClass.prototype._postOnEvnts = function(so){
	if(this._getDebug()){alert('oNav _postOnEvnts called - so: '+so._name);}
	this._inAnim = false;
	this.nav._disableAddCrumb = false;
	this._setCurLoc(so);
	//this.setVis(this.getVis());
	if(this._loc == false){
		//this._cbQ_push(25,this,'_setURL',so);
		//this._setURL(so);
	}
	this._setLocQ_pop();
};
NavClass.prototype._setSelctd = function(o, so){
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	var sRolloverColor = sRolloutColor; // top_area.main_nav_area.rollover.hex_value
	var iMoreToLoad = 0;
	var bMoreToLoad = false;
	var sRequestXml;
	if(this._getDebug()){alert('oNav _setSelctd called on: '+o._name+' - so: '+so._name+' - so == o: '+(o==so));}
	if(o == so){
		//$("divContentArea_0").iTotalHeight = 0;
		o._isSelctd = true;
		o._elLyr.setStyle({textDecoration:"underline"});
		this.nav._disableAddCrumb = false;
		this._disableDescNavigation = false;
		this._setCurLoc(so); // append the cur location id in the _loc object
		if(this._loc == false){
			this._cbQ_push(25,this,'_setURL',so);
			//this._setURL(so);
		}
		//$("divCurrentNavSelection")._setTxt(so._name);
		window._setCurrentNavId(so._name);
		if(pageTracker && window._bTrackingEnabled == true){ // if google analytics is found
			pageTracker._trackPageview("/main/"+so._name);
			//window.status = "/main/"+o_ary[i];
			//alert("/main/"+so._name);
		}
		if(!so.iframeGotoUrlViaBookmark){
			if(so.iframeGotoUrl){
				//loadUrlIntoContentArea(so.iframeGotoUrl);
				window.setTimeout("loadUrlIntoContentArea('"+so.iframeGotoUrl+"')", 250);
			}
		}
		else{ // found a bookmark attribute, use it for this first time, then remove it.
			window.setTimeout("loadUrlIntoContentArea('"+so.iframeGotoUrlViaBookmark+"')", 250);
			delete so.iframeGotoUrlViaBookmark;
		}
		if(so.invokeVideoTab){
			if(so.invokeVideoTab == "true"){
				destroyContentArea();
				loadVideoTabIntoContentArea();
			}
		}
		if(so.requestXml){
			if(typeof(so.requestXml) == "array"){
				sRequestXml = so.requestXml[0];
				if(iMoreToLoad < so.requestXml.length){
					bMoreToLoad = true;
					iMoreToLoad++;
				}
			}
			else{
				sRequestXml = so.requestXml;
				bMoreToLoad = true;
			}
		}
		if(!so.templates){
			if(so.requestXml && bMoreToLoad == true){
				new Ajax.Request(getJsonViaGetProxyUrl(sRequestXml), {method:'get',
					onSuccess: function(transport){
						var oJson;
						if(transport){
							if(transport.responseText){
								oJson = eval('('+transport.responseText+')');
								so.templates = oJson.xml;
								//alert(so.templates.template[0].attachId);
								window.oTemplates.attachTemplates(so.templates, undefined, 0);
							}
						}
					},
					onFailure: function(){
						onErr();
					}
				});
			}
		}
		else{
			//alert(so.templates.template[0].attachId);
			window.oTemplates.attachTemplates(so.templates, undefined, 0);
		}
		//$("divTabNav_8").tabNav0MouseUp();
		if(!document.location.search || document.location.search == ""){ // if no params are being passed then use the #, this will be upgraded to a param-free format when the goto.ajobnearhome.com abstractor is enchaced to map calls into the real bookmarking system
			$("divTabNav_3").fire("customEventNamespace:mouseup");
		}
		window.updateAddress(window.getAddress()+"/"+so._name.crunch());
	}
	else {
		//alert(o._name);
		o._isSelctd = false;
		o._elLyr.setStyle({textDecoration:"none"});
	}
};
NavClass.prototype._setStyle_a = function(lyr) {
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	lyr.setStyle({cursor:"pointer"});
	lyr.setStyle({cursor:"hand"});
	lyr.setStyle({fontFamily:"verdana"});
	lyr.setStyle({fontSize:"9px"});
	lyr.setStyle({fontWeight:"bold"});
	lyr.setStyle({color:sRolloutColor});
	lyr.setStyle({textAlign:"left"});
	lyr.setStyle({verticalAlign:"middle"});
};
NavClass.prototype._setStyle_b = function(lyr) {
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	lyr.setStyle({paddingLeft:"15px"});
	lyr.setStyle({paddingTop:"3px"});
	lyr.setStyle({cursor:"pointer"});
	lyr.setStyle({cursor:"hand"});
	lyr.setStyle({fontFamily:"verdana"});
	lyr.setStyle({fontWeight:"bold"});
	lyr.setStyle({fontSize:"9px"});
	lyr.setStyle({color:sRolloutColor});
	lyr.setStyle({textAlign:"left"});
	lyr.setStyle({verticalAlign:"middle"});
};
NavClass.prototype._setStyle_c = function(lyr) {
	var sRolloutColor; // top_area.main_nav_area.rollout
	var aryO1;
	var o1;
	if(window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(0,14) == "currentpalette"){
		aryO1 = window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.substr(15, window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value.length).split(".");
		for(var i=0; i<aryO1.length; i++){
			if(!o1){
				o1 = window._oColors.colours.palette[window._sColorPaletteId][aryO1[i]];
			}
			else{
				o1 = o1[aryO1[i]];
			}
		}
		sRolloutColor = "#"+o1.hex_value;
	}
	else{
		sRolloutColor = "#"+window.oTheme.general.topArea.mainNav.navElement.primary.titleUnselected.hex_value;
	}
	lyr.setStyle({marginLeft:"15px"});
	lyr.setStyle({cursor:"pointer"});
	lyr.setStyle({cursor:"hand"});
	lyr.setStyle({fontFamily:"arial"});
	lyr.setStyle({fontWeight:"bold"});
	lyr.setStyle({fontSize:"18px"});
	lyr.setStyle({color:sRolloutColor});
	lyr.setStyle({textAlign:"left"});
	lyr.setStyle({verticalAlign:"middle"});
};
String.prototype._getSuffix = function(){
	return this.substring(this.indexOf('_',0)+1, this.length);
};
String.prototype._isPriv = function(){
	if (this.substring(0,1) == '_' || this == 'title' || this == 'requestXml' || this == 'guid' || this == 'requestXmlImmediately' || this == 'fileName' || this == 'templates' || this == 'template'){
		return true;
	}
	else {
		return false;
	}
};
String.prototype.toBool = function(){
	if(this == 'true'){
		return true;
	}
	else {
		return false;
	}
};
NavClass.prototype._getCount = function(o){
	var i = 0;
	for(p in o){
		if(p.substring(0,4) == "area"){
			if(!o[p][0]){ // if only one area, or if each area is named something different
				i++;
			}
			else{ // an array of area nodes (admin tool compliant version)
				i = o[p].length;
			}
		}
	}
	return i;
};
NavClass.prototype._getCountId = function(o){
	var i = 0;
	var result;
	/*for(p in o){
		if(p.substring(0,4) == "area"){
			//alert(o[p][0].title);
			if(!o[p][0]){ // if only one area, or if each area is named something different
				if(o._parent[p] == o){
					result = i;
				}
				i++;
			}
			else{ // an array of area nodes (admin tool compliant version)
				for(var j=0; j<o[p].length; j++){
					//alert(j);
					if(o._parent[p][j] == o){
						result = j;
					}
				}
			
			}
		}
	}*/
	result = 1;
	return result;
};
