
subnavs = 'inline' // 'kickout'
var navs;
window.addEvent('domready', function(){
		hnavs = $$('.horizontal-nav');			
		vnavs = $$('.vertical-nav');
		navs= hnavs.concat(vnavs);
		
		if(navs.length>0){
			$each(navs, function(nav){
				LIs = nav.getElements('li');
				
				$each(LIs, function(obj){
					obj.addClass('navItem');
					if(obj.getParent().get('tag') !='ol'){
						obj.addEvent('mouseenter',function(event){	
							NavItemMouseEnter(this,event);
						});
					}else{
						obj.addEvent('mouseenter',function(){
							this.addClass('over');		
						});
					}
					
					if(obj.getParent().get('tag') !='ol'){
						obj.addEvent('mouseleave',function(){
							NavItemMouseLeave(this);
						});	
					}else{
						obj.addEvent('mouseleave',function(){
							this.removeClass('over');
						});
					}
					obj.addEvent('click',function(){
							this.removeClass('clicked');
							NavItemClick(this);
					});
				});
			});	
		
			$each(navs, function(topLevelNav){
				$each(topLevelNav.getElements("ul") , function(ul){	
					
					animations = getObjAnimationStyle(ul);
					$each(animations , function(anim){
						if(anim=="fadeIn"){
							ul.setStyle('opacity' , 0);
						}	
						if(anim=="rollOut"){
							ul.openH = ul.getCoordinates().height;
							ul.openH = ul.openH - parseInt(ul.getStyle("padding-top")) - parseInt(ul.getStyle("padding-bottom"));
							ul.setStyle('overflow' , "hidden");
							ul.setStyle("height",0);
						}
						
						if(anim=="slideOut"){
							ul.openH = ul.getCoordinates().height;
							ul.openH = ul.openH - parseInt(ul.getStyle("padding-top")) - parseInt(ul.getStyle("padding-bottom"));
							ul.setStyle('margin-top' , -(ul.openH));
							ul.addClass('invisible');
						}
						
					});
					
					ul.setUp = function(obj,event){
						
						obj.reset(obj,event);
						animations = getObjAnimationStyle(obj);
						obj.fadeIn = false;
						obj.rollOut = false;
						obj.slideOut = false;
						$each(animations , function(anim){
							if(anim == "rollOut"){
								obj.rollOut = true; 
							}	
							
							if(anim == "fadeIn"){
								obj.fadeIn = true; 
							}	
							
							if(anim == "slideOut"){
								obj.slideOut = true; 
							}	
							
						});
						
						obj.addClass('invisible');
						
						if(getObjSubNavStyle(obj,'kickout')){
							obj.setStyle('position' , 'absolute');
							
							/*if(obj.getParent().getParent().getStyle('position') == 'absolute'){
								obj.setStyle('top' ,obj.getParent().getCoordinates().top - obj.getParent().getParent().getCoordinates().top);
								obj.setStyle('left' ,obj.getParent().getCoordinates().right - obj.getParent().getParent().getCoordinates().left);
							}else{
								obj.setStyle('top' ,obj.getParent().getCoordinates().top);
								obj.setStyle('left' ,obj.getParent().getCoordinates().right);						
							}*/
							
							if(obj.getParent().getParent().getStyle('position') == 'absolute'){
								obj.setStyle('top' ,obj.getParent().getCoordinates().top - obj.getParent().getParent().getCoordinates().top);
								obj.setStyle('left' ,obj.getParent().getCoordinates().right - obj.getParent().getParent().getCoordinates().left);
							}else{
								/*infoPanel(obj.getCoordinates().top + ' ' +obj.getParent().getCoordinates().top)
								obj.setStyle('top' ,obj.getParent().getCoordinates().top);
								obj.setStyle('left' ,obj.getParent().getCoordinates().right);
								*/
								obj.setStyle('top' ,"auto");
								
								if(obj.getCoordinates().left !=obj.getParent().getCoordinates().right){
									obj.setStyle('left' , (obj.getCoordinates().left>obj.getParent().getCoordinates().right ? parseInt(obj.getStyle('left')) - (obj.getCoordinates().left - obj.getParent().getCoordinates().right) : parseInt(obj.getStyle('left')) + (obj.getParent().getCoordinates().right - obj.getCoordinates().left)))
								}
								//infoPanel(obj.getCoordinates().top + ' ' +obj.getParent().getCoordinates().top)
								if(obj.getCoordinates().top !=obj.getParent().getCoordinates().top){
									obj.setStyle('top' , (obj.getCoordinates().top>obj.getParent().getCoordinates().top ? parseInt(obj.getStyle('top')) - (obj.getCoordinates().top - obj.getParent().getCoordinates().top) : parseInt(obj.getStyle('top')) + (obj.getParent().getCoordinates().top - obj.getCoordinates().top)))
								}
								//infoPanel(obj.getCoordinates().top + ' ' +obj.getParent().getCoordinates().top)
								
								
							}
						}						
						
						if(getObjSubNavStyle(obj,'layover')){
							obj.setStyle('position' , 'absolute');
							obj.setStyle('top' ,obj.getParent().getCoordinates().bottom);
							obj.setStyle('left' ,obj.getParent().getCoordinates().left);					
						}
												
						if(getObjSubNavStyle(obj,'inline')){
							if(obj.getParent().hasClass("slideWrapper")==false){
								obj.getParent().addClass('inline');
								obj.getParent("ul").setStyle("height","auto");
							}else{
								obj.getParent().getParent().addClass('inline');	
							}
							
							if(obj.getParents(".slideWrapper").length >0){
								obj.getParents(".slideWrapper")[0].setStyle("overflow","visible");
							}
							
						}
						
						if(obj.getParents(".slideWrapper").length >0){
							obj.getParents(".slideWrapper")[0].setStyle("overflow","visible");
						}
						
						/*obj.openH = obj.getCoordinates().height;
						obj.openH = obj.openH - parseInt(obj.getStyle("padding-top")) - parseInt(obj.getStyle("padding-bottom"));
						*/
						
						if(obj.slideOut == true){
							obj.openH = obj.getCoordinates().height;
							obj.openH = obj.openH - parseInt(obj.getStyle("padding-top")) - parseInt(obj.getStyle("padding-bottom"));	
						}
						
						if(obj.rollOut == true){
							arrivalHeight = obj.getCoordinates().height;
							obj.setStyle("height","auto");
							obj.openH = obj.getCoordinates().height;
							obj.openH = obj.openH - parseInt(obj.getStyle("padding-top")) - parseInt(obj.getStyle("padding-bottom"));
							obj.setStyle("overflow","hidden");
							if((arrivalHeight - parseInt(obj.getStyle("padding-top")) - parseInt(obj.getStyle("padding-bottom")))==obj.openH){
								obj.setStyle("height",0);
							}else{
								obj.setStyle("height",arrivalHeight);
							}
							//infoPanel(arrivalHeight + ' ' + obj.openH)
							
						}
						
											
						if(obj.slideOut == true){
							
							$each(obj.getParents('.slideWrapper'), function(pSlideWrapper){
								if(getObjSubNavStyle(obj,'kickout')){											
									pSlideWrapper.setStyle("overflow","visible");
								}
							})
							if(obj.getParent().hasClass("slideWrapper")==false){
								slideWrapper = new Element('div',{
									"styles":{
										"height" : obj.openH + parseInt(obj.getStyle("padding-top")) + parseInt(obj.getStyle("padding-bottom")),
										"width" : obj.getCoordinates().width,
										"overflow" : "hidden",
										"position" : obj.getStyle('position'),
										"top" : obj.getStyle('top'),
										"left" : obj.getStyle('left'),
										"border" : "solid 0px #000000",
										"clear" : "left"
									},
									"class" : "slideWrapper"
								});
								obj.setStyle('left',0);
								obj.setStyle('top',0);
								slideWrapper.inject(obj.getParent());
								slideWrapper.wraps(obj);
							}else{
								obj.getParent().setStyles({
									"height" : obj.openH + parseInt(obj.getStyle("padding-top")) + parseInt(obj.getStyle("padding-bottom")),
									"width" : obj.getCoordinates().width,
									"overflow" : "hidden",
									"position" : obj.getStyle('position'),
									"border" : "solid 0px #000000",
									"clear" : "left"					  
								});
								obj.setStyle('left',0);
								obj.setStyle('top',0);
							}
						}
						
						
						if(getObjAnimationStyle(obj).length >0){
							obj.anim(obj);
						}else{
							obj.removeClass('invisible');
						}
						
					}
					
					
					ul.reset = function(ul,event){
						pRentLI = ul.getParent('li');
						parentLIs = ul.getParents('li');
						$each(parentLIs , function(liObj){
							liObj.addClass('over');
							liObjSibs = liObj.getAllPrevious().concat(liObj.getAllNext());
										
							$each(liObjSibs , function(liObjSib){
								liObjSib.removeClass('over');
							});
						});
						
						
						
												
						$each(pRentLI.getAllPrevious().concat(pRentLI.getAllNext()) , function(pRentLISib){
							pRentLISib.removeClass('over');																					
							if(pRentLISib.hasClass("over") == false){
								$each(pRentLISib.getElements("ul") , function(sibUL){										  
									sibUL.animBack(sibUL,event);									  
								});
							}
						});
					}
					
					
				
					
					
					ul.myEffect = new Fx.Morph(ul, {link : "chain" , duration : 500, transition: Fx.Transitions.Sine.easeOut});
					ul.anim = function(ul){
						
						ul.myEffect.pause();
						ul.myEffect.clearChain();
						ul.removeClass('invisible');
						
						effectObj = new Array();
						animations = getObjAnimationStyle(ul);
						$each(animations , function(anim){
							if(anim == "fadeIn"){
								effectObj.push(['opacity', (0,1)]);
							}
							
							if(anim == "rollOut"){
								effectObj.push(['height',ul.openH /*(ul.openH + "," + 0)*/]);
								ul.myEffect.chain(function(){
									ul.setStyles({"overflow":"visible"/*, "height":"auto"*/});
									
								});
							}
							
							if(anim == "slideOut"){
								effectObj.push(['marginTop', (0 + "," + (-(ul.openH)))]);
								
							}
							
						});
						
						if(animations.length==0){
							ul.removeClass('invisible');
						}else{
							compiledObj = new Object();
							$each(effectObj , function(obj){
								eval("compiledObj." + obj[0] + " = "  +obj[1]);		   
							});
							ul.myEffect.start(compiledObj);
						}
					};
					
					ul.animBack = function animBack(ul,event){
						ul.myEffect.pause();
						ul.myEffect.clearChain();
						ul.myEffect.chain(function(){
							postNavItemRoll(ul,event);
						});
						
						effectObj = new Array();
					
						if(ul.fadeIn == true){
							effectObj.push(['opacity', (1,0)]);
						}
						
						if(ul.rollOut == true){
							ul.setStyle("overflow","hidden");
							effectObj.push(['height', (0 + "," + ul.openH)]);
						}
						
						if(ul.slideOut == true){
							ul.getParent().setStyle('overflow',"hidden");
							effectObj.push(['marginTop', (-(ul.openH) + "," + 0)]);
						}
						
						animations = getObjAnimationStyle(ul);
						if(animations.length==0){
							postNavItemRoll(ul,event);
						}else{
							compiledObj = new Object();
							$each(effectObj , function(obj){
								eval("compiledObj." + obj[0] + " = "  +obj[1]);		   
							});
							ul.myEffect.start(compiledObj);
						}
						
					}
						
					
				});
			});
		}
	});

NavItemClick = function(obj){
	
}

NavItemMouseLeave = function(obj){
	obj.removeClass('over')
}


NavItemMouseEnter = function(obj,event){
	
	rollOutKiller();
	// if there is a subnav to reveal make it invisible then position it
	if(obj.getChildren('ul').length>0 || obj.getChildren(".slideWrapper").length>0){
		rolledObj = obj.getChildren('ul').length>0 ? obj.getChildren('ul')[0] : obj.getChildren(".slideWrapper")[0].getChildren("ul")[0];
		//obj.getChildren('ul')[0].setUp(obj.getChildren('ul')[0]);
		rolledObj.setUp(rolledObj,event);
		
	}else{
		obj.addClass('over');
		$each(obj.getAllPrevious().concat(obj.getAllNext()) , function(pRentLISib){
			pRentLISib.removeClass('over');																					
			if(pRentLISib.hasClass("over") == false){
				$each(pRentLISib.getElements("ul") , function(sibUL){										  
					sibUL.animBack(sibUL,event);									  
				});
			}
		});
	}
	
	hotSpots(obj);
}


function postNavItemRoll(obj,event){
	if(obj.slideOut == true && obj.getParent().hasClass("slideWrapper") == true){
		obj.replaces(obj.getParent());
		obj.addClass('invisible');
	}
	obj.setStyle('position','static');
	obj.setStyle('height','auto');
	obj.setStyle('height',obj.getCoordinates().height - parseInt(obj.getStyle("padding-top")) - parseInt(obj.getStyle("padding-bottom")));
	obj.getParent().removeClass("inline");
	$each(obj.getElements('li'), function(ULsLIs){							  
		ULsLIs.removeClass('over');		
	});	
	
	(function(){
	if(obj.hasClass("inline")==true){
		if($chk(obj.getParent("ul").bottomRollout)){
			
			if(obj.getParent("ul").bottomRollout.getCoordinates().top>obj.getParent("ul").getCoordinates().bottom+2 || obj.getParent("ul").bottomRollout.getCoordinates().top<obj.getParent("ul").getCoordinates().bottom-2){
				aUL = obj.getParent("ul");
				
				aUL.bottomRollout.setStyles({
					top:obj.getParent("ul").getCoordinates().bottom+2,
					left:aUL.getCoordinates().left,
					width:aUL.getCoordinates().width, 
					height:(window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - (obj.getParent("ul").getCoordinates().bottom) -2
				})
				
			}
		}
	}
			  }).delay(250)
	
}



//info to collect when starting hotspots();
var topLevelNav;
var activeItemLIs;
var navStyle;
var subNavStyle;
var activatedSubNav;
var docHeight;

/*
	new hotspots functionality
	
	collect above info...
	
	common rolloff func
		set top roll out relative tot eh top level nav
		set main left roll out - relative only to the top level nav
		
		branch 
			tertiary nav actions
				sets subnav's right side roll out
			
			lack of tertiary nav actions
				sets subnav's right side roll out primary subnav
		
		sets top and bottom  rolloffs for all subnavs
			
			
	branch 
		
		HNavs 
			set top rolloffs
			set main left rolloff
			set main right rollout
			set subnavs left rollout
			set bottoms for subnavs
			
			
		VNavs
			set tops and bottoms for subnavs
		
	adds rolloover event to all rollouts	
	

*/

function hotSpots(obj){
	// begin info collection
	//find topLevelNav
	objParents = obj.getParents('ul');
	$each(objParents, function(parentUL){
		if(parentUL.hasClass('horizontal-nav') || parentUL.hasClass('vertical-nav')){
			topLevelNav = parentUL;
		}
	});
	
	
	positionedParents = false;
	
	$each(topLevelNav.getParents() , function(prent){
		if(prent.getStyle('position') == 'relative' || prent.getStyle('position') == 'absolute'){
			positionedParents = true;
		}
											  
	})
	
	
	// find activeItemLIs;
	activeItemLIs = topLevelNav.getElements('.over');
	
	// get nav Style - horizontal vs vertical
	navStyle = topLevelNav.hasClass('horizontal-nav') == true ? 'horizontal-nav' : 'vertical-nav';
	
	activatedSubNav = false;
	subNavStyle =  'kickout';
	objChildULs = (obj.getChildren('.slideWrapper').length >0 ? obj.getChildren('.slideWrapper')[0].getChildren("ul") : obj.getChildren('ul')); 
	
	

	if(objChildULs.length>0){
		// define the activated subnav if there is one
		activatedSubNav = objChildULs[0];
		
		//get subnav style - 'kickout', 'inline', 'layover'  (default)
		subNavStyle = getObjSubNavStyle(activatedSubNav);
	}
	
	
	//get doc height - not the window height
	docHeight = window.document.getCoordinates().height + window.getScroll().y;
	
	// end info collection

	
	// begin common rolloff functionality
	// sets the top roll out above topLevelNav UL
	hotSpotGenerator({top:0,left:0,width:(window.getCoordinates().width-25 > 0 ? window.getCoordinates().width-25 : 0), height:(topLevelNav.getCoordinates().top-2 > 0 ? topLevelNav.getCoordinates().top-2 : 0)})
	

	// sets the main left roll out - relative only to topLevelNav UL
	
	hotSpotGenerator({top:topLevelNav.getCoordinates().top,left:0,width:(topLevelNav.getCoordinates().left - 2 > 0 ? topLevelNav.getCoordinates().left - 2 : 0), height:(window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - topLevelNav.getCoordinates().top})
	
	// navStyle == horizontal-nav
	if(navStyle == 'horizontal-nav'){
		// sets the main right roll out - relative only to topLevelNav UL
		hotSpotGenerator({
			top:topLevelNav.getCoordinates().top,
			left:topLevelNav.getCoordinates().right,
			/*width:(topLevelNav.getCoordinates().left - 2 > 0 ? topLevelNav.getCoordinates().left - 2 : 0), */
			width:(window.getCoordinates().width- 27 - topLevelNav.getCoordinates().right > 0 ? window.getCoordinates().width- 27 - topLevelNav.getCoordinates().right : 0),			
			height:topLevelNav.getCoordinates().height})
	}
	
	// sets  activated subnav's right side roll out
	if(activatedSubNav!=false){
		if(activatedSubNav.getParent().hasClass('slideWrapper') == true){
			activatedSubNav =activatedSubNav.getParent();
		}
		
		hotSpotGenerator({
			top:((subNavStyle != 'layover' && subNavStyle !='inline') ? (activatedSubNav.getCoordinates().top > 0 ? activatedSubNav.getCoordinates().top : 0) : topLevelNav.getCoordinates().top),
			left:(activatedSubNav.getCoordinates().right +2 > 0 ? activatedSubNav.getCoordinates().right +2 : 0),
			width:(window.getCoordinates().width- 27 - activatedSubNav.getCoordinates().right > 0 ? window.getCoordinates().width- 27 - activatedSubNav.getCoordinates().right : 0), 
			height:(
				window.getCoordinates().height-25  > docHeight 
				? 
				window.getCoordinates().height-25 
				:
				docHeight
				) - ((subNavStyle != 'layover' && subNavStyle !='inline') 
				? 
				(
			 	activatedSubNav.getCoordinates().top > 0 
				? 
				activatedSubNav.getCoordinates().top 
				: 
				0
				) 
				: 
				topLevelNav.getCoordinates().top)
		})	
		
		
	}else{
		// actions to take when there are no tertiary subnavs	
		if(activatedSubNav==false){
			// sets subnav's right side roll out primary subnav
			//ISSUE			
			hotSpotGenerator({
				top:(
					(getObjSubNavStyle(obj.getParent(),'layover') == false && getObjSubNavStyle(obj.getParent(),'inline') == false) 
					? 
					obj.getParent().getCoordinates().top 
					: 
					topLevelNav.getCoordinates().top
				),
				left:obj.getParent().getCoordinates().right+2,
				width:(window.getCoordinates().width- 27 - obj.getParent().getCoordinates().right) >0 ? (window.getCoordinates().width- 27 - obj.getParent().getCoordinates().right) : 0, 
				height: (
						window.getCoordinates().height-25  > docHeight 
						? 
						window.getCoordinates().height-25 
						:
						docHeight
					) - (
						(getObjSubNavStyle(obj.getParent(),'layover') == false  && getObjSubNavStyle(obj.getParent(),'inline') == false) 
						? 
						obj.getParent().getCoordinates().top 
						: 
						topLevelNav.getCoordinates().top
					) 
					/*obj.getParent().getCoordinates().height*/
			})
			
			
		}
	}


	//sets top and bottom  rolloffs for all subnavs
	/*activeItemLIs = topLevelNav.getElements('.over');
	firstActiveLI = activeItemLIs[0];*/
	activeItemLIs = obj.getParents('.over');
	if(activeItemLIs.length<1){
		firstActiveLI  = obj;
	}else{
		firstActiveLI = activeItemLIs[activeItemLIs.length-1];
	}
	
	
	activeItemLIs = topLevelNav.getElements('.over');
	
	
	
		$each(activeItemLIs, function(LIs){			
			
			activeUL = LIs.getChildren('ul');
			if($chk(LIs.getChildren('.slideWrapper')[0]) == true){
				activeUL.push(LIs.getChildren('.slideWrapper')[0].getChildren('ul')[0]);
			}
			if(activeUL.length>0){
				
				//tops
				if(topLevelNav.hasClass('horizontal-nav')){
					
					//tops for horizontal Navs
					if(getObjSubNavStyle(activeUL[0],'layover') == false && getObjSubNavStyle(activeUL[0],'inline') == false){
						
						hotSpotGenerator({
						 	top:topLevelNav.getCoordinates().bottom,
							left:activeUL[0].getCoordinates().left + 2,
							width:window.getCoordinates().width- 27 - activeUL[0].getCoordinates().left, 
							//height:(activeUL[0].getCoordinates().top - topLevelNav.getCoordinates().bottom -2 > 0 ? activeUL[0].getCoordinates().top - topLevelNav.getCoordinates().bottom -2 : 0)
							height:(
								(activeUL[0].getParent().hasClass("slideWrapper") == true ? activeUL[0].getParent().getCoordinates().top : activeUL[0].getCoordinates().top) - topLevelNav.getCoordinates().bottom-2 > 0 
								? 
								(activeUL[0].getParent().hasClass("slideWrapper") == true ? activeUL[0].getParent().getCoordinates().top : activeUL[0].getCoordinates().top) - topLevelNav.getCoordinates().bottom-2 
								: 
								0
							)
							
						})
						
					}
					//FIXED ISSUE
					
					if(LIs == firstActiveLI){
						hotSpotGenerator({
						 	top:topLevelNav.getCoordinates().bottom,
							left:topLevelNav.getCoordinates().left,
							width:(activeUL[0].getCoordinates().left - topLevelNav.getCoordinates().left -2) > 0  ? (activeUL[0].getCoordinates().left - topLevelNav.getCoordinates().left -2) : 0, 
							height:(window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - topLevelNav.getCoordinates().bottom
						})
					
					}
	
					
				}else{
					
					//tops for vertical navs			
					if(getObjSubNavStyle(activeUL[0],'layover') == false && getObjSubNavStyle(activeUL[0],'inline') == false){
						
						hotSpotGenerator({
						 	top:topLevelNav.getCoordinates().top,
							left:activeUL[0].getCoordinates().left + 2,
							width:(window.getCoordinates().width- 27 - activeUL[0].getCoordinates().left > 0 ? window.getCoordinates().width- 27 - activeUL[0].getCoordinates().left : 0), 
							height:(
								(activeUL[0].getParent().hasClass("slideWrapper") == true ? activeUL[0].getParent().getCoordinates().top : activeUL[0].getCoordinates().top) - topLevelNav.getCoordinates().top-2 > 0 
								? 
								(activeUL[0].getParent().hasClass("slideWrapper") == true ? activeUL[0].getParent().getCoordinates().top : activeUL[0].getCoordinates().top) - topLevelNav.getCoordinates().top-2 
								: 
								0
							)
						})
					
					
					}
					
					
					
					
					//bottom for toplevel vertical navs
					if(getObjSubNavStyle(activeUL[0],'inline') == true){
						hitTop = false;
						ulBottoms = 0;
						$each(activeUL[0].getParents("ul"), function(pUL){
							if(pUL==topLevelNav){
								hitTop=true;
							}
							if(!hitTop){
								if(pUL.getCoordinates().bottom > ulBottoms){
									ulBottoms =pUL.getCoordinates().bottom;
								}
							}
							
						});
						
						hotSpotGenerator({
						 	
							left:topLevelNav.getCoordinates().left,
							width:topLevelNav.getCoordinates().width, 
							
							top:(
								(topLevelNav.getCoordinates().bottom>activeUL[0].getCoordinates().bottom || (topLevelNav.getCoordinates().left +topLevelNav.getCoordinates().width)<activeUL[0].getCoordinates().left)
								? 
								topLevelNav.getCoordinates().bottom >ulBottoms ? topLevelNav.getCoordinates().bottom :ulBottoms
								:
								activeUL[0].getCoordinates().bottom >ulBottoms ? activeUL[0].getCoordinates().bottom : ulBottoms
							),
							
							height:( 
									(window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight)
									- 
									(topLevelNav.getCoordinates().bottom>activeUL[0].getCoordinates().bottom ? (topLevelNav.getCoordinates().bottom >ulBottoms ? topLevelNav.getCoordinates().bottom :ulBottoms) : (activeUL[0].getCoordinates().bottom >ulBottoms ? activeUL[0].getCoordinates().bottom : ulBottoms)) > 0 ? (window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - (topLevelNav.getCoordinates().bottom>activeUL[0].getCoordinates().bottom ? (topLevelNav.getCoordinates().bottom >ulBottoms ? topLevelNav.getCoordinates().bottom :ulBottoms) : (activeUL[0].getCoordinates().bottom >ulBottoms ? activeUL[0].getCoordinates().bottom : ulBottoms)) : 0)
						})
					}
					
					if(getObjSubNavStyle(activeUL[0],'kickout') == true){
						hitTop = false;
						ulBottoms = 0;
						$each(activeUL[0].getParents("ul"), function(pUL){
							if(pUL==topLevelNav){
								hitTop=true;
							}
							if(!hitTop){
								if(pUL.getCoordinates().bottom > ulBottoms){
									ulBottoms =pUL.getCoordinates().bottom;
								}
							}
							
						});
						
						hotSpotGenerator({
						 	
							left:topLevelNav.getCoordinates().left,
							width:topLevelNav.getCoordinates().width, 
							
							top:(ulBottoms > topLevelNav.getCoordinates().bottom ? ulBottoms : topLevelNav.getCoordinates().bottom),
							
							height:( (window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - (ulBottoms > topLevelNav.getCoordinates().bottom ? ulBottoms : topLevelNav.getCoordinates().bottom) > 0 ? (window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - (ulBottoms > topLevelNav.getCoordinates().bottom ? ulBottoms : topLevelNav.getCoordinates().bottom) : 0)
						})
						
					}
				}
				
				
				
				//bottoms
				$each(activeUL , function(aUL){
					if(!getObjSubNavStyle(aUL, 'inline')){
						//aULContainer = (aUL.slideOut == true ? (aUL.getParent().getCoordinates().height) : aUL.openH)
						//infoPanel(aUL.openH);
						
						oOpenH = aUL.openH;
						
						aUL = aUL.slideOut == true ? aUL.getParent() : aUL;
						aUL.openH = aUL.hasClass("slideWrapper") == true ? aUL.getCoordinates().height : aUL.openH;
						
						/*
						if(aUL.getElements(".over").length>0 && aUL.getElements(".over .slideWrapper").length>0 && aUL.getElements(".over .slideWrapper .inline").length>0){
													
							if(aUL.getElements(".over")[aUL.getElements(".over").length-1].getChildren(".slideWrapper").length >0){
								offSet = aUL.getElements(".over")[aUL.getElements(".over").length-1].getChildren(".slideWrapper")[0].getCoordinates().height
							}else{
								offSet = aUL.getElements(".over .slideWrapper .inline")[0].openH;
							}
							aUL.openH += offSet;
						}
						*/
						
						if(aUL.getElements(".over").length>0 && aUL.getElements(".over  .inline").length>0){
													
							if(aUL.getElements(".over")[aUL.getElements(".over").length-1].getChildren(".slideWrapper").length >0){
								if(aUL.getElements(".over")[aUL.getElements(".over").length-1].getChildren(".slideWrapper")[0].getCoordinates().left ==aUL.getCoordinates().left){
									offSet = aUL.getElements(".over")[aUL.getElements(".over").length-1].getChildren(".slideWrapper")[0].getCoordinates().height
								}else{
									offSet = 0;
								}
							}else{
								
								if(aUL.getElements(".over .inline")[0].getCoordinates().left == aUL.getCoordinates().left){
									offSet = aUL.getElements(".over .inline")[0].openH;
								}else{
									offSet = 0;
								}
							}
							
							aUL.openH += offSet;
						}
						
						
						
						//infoPanel(aUL.openH);
						aUL.bottomRollout = hotSpotGenerator({
							top:(
								$chk(aUL.openH)==true 
								? 
								aUL.getCoordinates().top + aUL.openH + (parseInt(aUL.getStyle("padding-top")) + parseInt(aUL.getStyle("padding-bottom"))) 
								: 
								aUL.getCoordinates().bottom
								) +2,
							left:aUL.getCoordinates().left,
							width:aUL.getCoordinates().width, 
							height:(window.getCoordinates().height-25  > docHeight ? window.getCoordinates().height-25 : docHeight) - ($chk(aUL.openH)==true ? aUL.getCoordinates().top + aUL.openH + (parseInt(aUL.getStyle("padding-top")) + parseInt(aUL.getStyle("padding-bottom"))) :aUL.getCoordinates().bottom) -2
						});						
						aUL.openH = oOpenH;
					}
				});
			}
			
			
		});

	
	
	
	// adds rollover event to all rollouts
	$each($$('.hotSpot'),function(obj2){
		obj2.addEvent('mouseover' , function(event){
			navReset(obj,event);
			$each(topLevelNav.getElements('li'), function(LIs){
				LIs.removeClass('over');
			});
	
		});
	});
}

function hotSpotGenerator(args,className){
	rollout = new Element('div' , {
						 	'class' : 'hotSpot' + (className!= null ? (" " + className) : ""),
							'styles':{
								'top' : (args.top>0 ? args.top : 0),
								'left' : (args.left>0 ? args.left : 0),
								'width' : (args.width>0 ? args.width : 0),
								'height' : (args.height>0 ? args.height : 0)
							}						 
						 });
	
	rollout.inject($$('body')[0]);
	return rollout;
}

function rollOutKiller(){
	if($$('.hotSpot').length>0){
		$$('.hotSpot').destroy();
	}
}

function getObjSubNavStyle(obj,style){
	if(style == null){
		if(obj.hasClass('inline')){
			return 'inline'
		}
	
		if(obj.hasClass('layover')){
			return 'layover'
		}
	
		if(obj.hasClass('kickout')){
			return 'kickout'
		}
	}else{
		return obj.hasClass(style)
	}
}

function getObjAnimationStyle(obj,style){
	var animation = new Array();
	
	if(style == null){
		if(obj.hasClass('slideOut')){
			animation.push('slideOut');
		}
		
		if(obj.hasClass('rollOut')){
			animation.push('rollOut');
		}
		
		if(obj.hasClass('fadeIn')){
			animation.push('fadeIn');
		}
		
		return animation;
	
	}else{
		return obj.hasClass(style)
	}
}

function navReset(obj , event){
	rollOutKiller();
	if(event.target.hasClass("hotSpot") == true){
		pRentULS = obj.getParents("ul").concat(obj.getElements("ul"));
		$each(pRentULS,function(ULs){
			if(getObjAnimationStyle(ULs).length >0){
				ULs.animBack(ULs,event);	
			}
		});
	}
	
}

function infoPanel(stuff){
	$('controlPanel').setStyle("visibility","visible");
		update=new Element("div" ,{
			"styles" :{
					"border-bottom" : "solid 1px #000000",
					"padding" : 6,
					"z-index" : 55555555555555555555555555555
				} ,
			
			"html" : stuff 
		});
		update.inject($('controlPanel') , "top")	;
}


